On Thu, Apr 30, 2015 at 7:09 AM, Martin Pieuchot <[email protected]> wrote:
> On 24/04/15(Fri) 20:48, David Higgs wrote: > > This is the final patch in the series. > > > > Utilize the pending flags and report callback for their intended purpose > - to process async behavior. > > > > Apply splusb() to ensure report callbacks can't fire before their data > structures have been properly updated. This only needs to happen in > upd_refresh(); all other calls to upd_request_children() are from a report > callback. > > This is some good work. I don't think your patch #6 makes sense without > #7, so I merged them. > Sounds good, thanks for all the help. I don't think you need a "pending" flags for the sensors, since what you > are querying are the reports. You basically do not want to send to > requests for the same report at once. > In general the code tries to avoid requesting reports more than once, but this prevents sensor dependencies from causing some nasty problems. In the example below, I don't want the update of C to re-update A and trigger an infinite loop by requesting B. Sensor A (report 1) -> Sensor B (report 2) -> Sensor C (report 1) The alternative is to allow inconsistent sensor values. If the value of B affects the value of C, I would rather perform a 2nd request for report 1 once I have the value of B, than to put garbage/bogus values into C. I prefer to keep sensor values consistent, to ensure nobody's sensorsd starts to panic and because I doubt many real devices have this kind of annoying HID descriptor layout. > I'd also take the simpler approach of not deactivating all sensors if > you fail to *submit* a transfer. When such thing happens it's either > because the device/bus is going away or because we cannot allocate > memory. > This sounds fine for the bus/device case or if M_NOWAIT would trigger a panic. How about if the usb device itself runs out of memory/buffers; will the rest of the system stay happy? Again, I prefer to err on the side of consistency and invalidate child sensors so sensorsd isn't looking at stale values. > I tweaked your diff below, included some comments and your copyright. > This is untested but I hope you'll correct/improve it. > I'll take a look over the next week. > I'm also curious, which new reports/sensors do you want to add? > I haven't looked at this in some months. My consumer-grade device had several useful sensors that aren't currently handled. There are some "internal" reports (CapacityMode, AtRate) that aren't suitable as sensors, but might fix other sensor values being mis-reported. And there are interactive things that can be done via reports - silencing the audible alarm, requesting self-tests - that would be good as sysctls or ioctls someday. I'll be happy to look at lsusb output if anyone has a device in mind. Thanks. --david
