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

HID: elan: Silence mute LED errors being logged when the device is unplugged

Being integrated into an USB keyboard-dock the mute LED can go away
at any time, leading to the following errors:

[  918.667671] elan 0003:04F3:0755.0002: Failed to set mute led brightness: -19
[  918.667737] leds elan:red:mute: Setting an LED's brightness failed (-19)

Fix this by making the following changes:

1. Don't log an error from elan_mute_led_set_brigtness() when
   ret == -ENODEV
2. Set the LED_HW_PLUGGABLE flag on the mute LED led_classdev

While at it also make sure that elan_mute_led_set_brigtness() returns
an error (-EIO) when ret != 3 but it is not an error (>= 0).
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
...@@ -445,8 +445,9 @@ static int elan_mute_led_set_brigtness(struct led_classdev *led_cdev, ...@@ -445,8 +445,9 @@ static int elan_mute_led_set_brigtness(struct led_classdev *led_cdev,
kfree(dmabuf); kfree(dmabuf);
if (ret != ELAN_LED_REPORT_SIZE) { if (ret != ELAN_LED_REPORT_SIZE) {
if (ret != -ENODEV)
hid_err(hdev, "Failed to set mute led brightness: %d\n", ret); hid_err(hdev, "Failed to set mute led brightness: %d\n", ret);
return ret; return ret < 0 ? ret : -EIO;
} }
drvdata->mute_led_state = led_state; drvdata->mute_led_state = led_state;
...@@ -462,6 +463,7 @@ static int elan_init_mute_led(struct hid_device *hdev) ...@@ -462,6 +463,7 @@ static int elan_init_mute_led(struct hid_device *hdev)
mute_led->brightness_get = elan_mute_led_get_brigtness; mute_led->brightness_get = elan_mute_led_get_brigtness;
mute_led->brightness_set_blocking = elan_mute_led_set_brigtness; mute_led->brightness_set_blocking = elan_mute_led_set_brigtness;
mute_led->max_brightness = LED_ON; mute_led->max_brightness = LED_ON;
mute_led->flags = LED_HW_PLUGGABLE;
mute_led->dev = &hdev->dev; mute_led->dev = &hdev->dev;
return devm_led_classdev_register(&hdev->dev, mute_led); return devm_led_classdev_register(&hdev->dev, mute_led);
......
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