Re: [PATCH] Input: apanel - switch to using brightness_set_blocking()
From: Sven Van Asbroeck
Date: Sun Feb 10 2019 - 18:30:04 EST
Hi Dmitry,
On Sat, Feb 9, 2019 at 12:19 PM Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> wrote:
>
> Now that LEDs core allows "blocking" flavor of "set brightness" method we
> can use it and get rid of private work item. As a bonus, we are no longer
> forgetting to cancel it when we unbind the driver.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
This is the blocking set_brightness callback after applying the patch :
(it's not immediately obvious when looking at only the patch)
struct apanel {
...
u16 led_bits;
...
};
static int mail_led_set(struct led_classdev *led,
enum led_brightness value)
{
struct apanel *ap = container_of(led, struct apanel, mail_led);
if (value != LED_OFF)
ap->led_bits |= 0x8000;
else
ap->led_bits &= ~0x8000;
return i2c_smbus_write_word_data(ap->client, 0x10, ap->led_bits);
}
ap->led_bits was previously used as a 'mailslot' between the
set_brightness callback and the deferred work, right?
After the patch, it's used only in this function. Maybe it could be
replaced by a local variable? As a bonus, that would make
the driver's private struct slightly smaller.