HID: wiimote: use cached battery values on I/O failure
authorDavid Herrmann <dh.herrmann@gmail.com>
Sun, 5 May 2013 21:12:49 +0000 (23:12 +0200)
committerJiri Kosina <jkosina@suse.cz>
Mon, 3 Jun 2013 09:07:00 +0000 (11:07 +0200)
commit6b80bb94dc61a7f702df13c6c7e8edee331d0a9a
treedd1802ca633f492420d9b8cfc2b161b35079208b
parentc57ff761be8365599ff9ccdbb205ead4912b2067
HID: wiimote: use cached battery values on I/O failure

Battery reports are sent along every status report of the Wii Remote.
So chances are pretty high that we have an up-to-date battery
cache at any time. Therefore, initialize the battery-cache to 100% and
then return battery values from the cache if the query fails.

This works around a power_supply limitation in that it requires us to be
able to query the device during power_supply registration and
removal. Otherwise, "add" or "remove" udev events are not sent. If
we answer these requests from our cache instead, we avoid dropping these
events and no longer cause warnings printed.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-wiimote-core.c