Commit bbf62645 authored by Hans de Goede's avatar Hans de Goede Committed by Jiri Kosina

HID: lenovo: Use brightness_set_blocking callback for setting LEDs brightness

The lenovo_led_brightness_set function may sleep, so we should have the
the led_class_dev's brightness_set_blocking callback point to it, rather
then the regular brightness_set callback.

When toggled through sysfs this is not a problem, but the brightness_set
callback may be called from atomic context when using LED-triggers.

Fixes: bc04b37e ("HID: lenovo: Add ThinkPad 10 Ultrabook Keyboard support")
Reviewed-by: default avatarMarek Behún <kabel@kernel.org>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 69aea9d2
...@@ -777,7 +777,7 @@ static enum led_brightness lenovo_led_brightness_get( ...@@ -777,7 +777,7 @@ static enum led_brightness lenovo_led_brightness_get(
: LED_OFF; : LED_OFF;
} }
static void lenovo_led_brightness_set(struct led_classdev *led_cdev, static int lenovo_led_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value) enum led_brightness value)
{ {
struct device *dev = led_cdev->dev->parent; struct device *dev = led_cdev->dev->parent;
...@@ -802,6 +802,8 @@ static void lenovo_led_brightness_set(struct led_classdev *led_cdev, ...@@ -802,6 +802,8 @@ static void lenovo_led_brightness_set(struct led_classdev *led_cdev,
lenovo_led_set_tp10ubkbd(hdev, tp10ubkbd_led[led_nr], value); lenovo_led_set_tp10ubkbd(hdev, tp10ubkbd_led[led_nr], value);
break; break;
} }
return 0;
} }
static int lenovo_register_leds(struct hid_device *hdev) static int lenovo_register_leds(struct hid_device *hdev)
...@@ -822,7 +824,7 @@ static int lenovo_register_leds(struct hid_device *hdev) ...@@ -822,7 +824,7 @@ static int lenovo_register_leds(struct hid_device *hdev)
data->led_mute.name = name_mute; data->led_mute.name = name_mute;
data->led_mute.brightness_get = lenovo_led_brightness_get; data->led_mute.brightness_get = lenovo_led_brightness_get;
data->led_mute.brightness_set = lenovo_led_brightness_set; data->led_mute.brightness_set_blocking = lenovo_led_brightness_set;
data->led_mute.dev = &hdev->dev; data->led_mute.dev = &hdev->dev;
ret = led_classdev_register(&hdev->dev, &data->led_mute); ret = led_classdev_register(&hdev->dev, &data->led_mute);
if (ret < 0) if (ret < 0)
...@@ -830,7 +832,7 @@ static int lenovo_register_leds(struct hid_device *hdev) ...@@ -830,7 +832,7 @@ static int lenovo_register_leds(struct hid_device *hdev)
data->led_micmute.name = name_micm; data->led_micmute.name = name_micm;
data->led_micmute.brightness_get = lenovo_led_brightness_get; data->led_micmute.brightness_get = lenovo_led_brightness_get;
data->led_micmute.brightness_set = lenovo_led_brightness_set; data->led_micmute.brightness_set_blocking = lenovo_led_brightness_set;
data->led_micmute.dev = &hdev->dev; data->led_micmute.dev = &hdev->dev;
ret = led_classdev_register(&hdev->dev, &data->led_micmute); ret = led_classdev_register(&hdev->dev, &data->led_micmute);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment