aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Lamparter <chunkeey@gmail.com>2018-12-25 21:54:42 +0100
committerChristian Lamparter <chunkeey@gmail.com>2018-12-27 14:36:23 +0100
commit96d55f9fd990beed06b79a65100ef7c942dc125d (patch)
tree2290d9321a61f8d33019f8a20991315e8af71624
parentef5ff08662532a6b1770214569e4c27b05e1dc35 (diff)
downloadupstream-96d55f9fd990beed06b79a65100ef7c942dc125d.tar.gz
upstream-96d55f9fd990beed06b79a65100ef7c942dc125d.tar.bz2
upstream-96d55f9fd990beed06b79a65100ef7c942dc125d.zip
kernel: 4.19: fix usbport led trigger regression
|In the patch "usb: simplify usbport trigger" together with |"leds: triggers: add device attribute support" caused an |regression for the usbport trigger. it will no longer |enumerate any "ports" (i.e the sysfs directory stays empty) |if the usb host drivers are fully initialized before the |usbport trigger was loaded. <https://marc.info/?l=linux-usb&m=154577101631079> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
-rw-r--r--target/linux/generic/hack-4.19/160-leds-fix-regression-in-usbport-led-trigger.patch84
1 files changed, 84 insertions, 0 deletions
diff --git a/target/linux/generic/hack-4.19/160-leds-fix-regression-in-usbport-led-trigger.patch b/target/linux/generic/hack-4.19/160-leds-fix-regression-in-usbport-led-trigger.patch
new file mode 100644
index 0000000000..c0eb5a78aa
--- /dev/null
+++ b/target/linux/generic/hack-4.19/160-leds-fix-regression-in-usbport-led-trigger.patch
@@ -0,0 +1,84 @@
+From 38a3549ffc0033761063cc5c7b994ab075694db8 Mon Sep 17 00:00:00 2001
+From: Christian Lamparter <chunkeey@gmail.com>
+Date: Tue, 25 Dec 2018 21:11:08 +0100
+Subject: [RFC PATCH] leds: fix regression in usbport led trigger
+
+In the patch "usb: simplify usbport trigger" together with
+"leds: triggers: add device attribute support" caused an
+regression for the usbport trigger. it will no longer
+enumerate any "ports" (i.e the sysfs directory stays empty)
+if the usb host drivers are fully initialized before the
+usbport trigger was loaded.
+
+The reason is that the usbport driver registers the sysfs
+entries in the ports subdirectory during the activate()
+callback. Whereas the patch
+"leds: triggers: add device attribute support" made it so
+that the sysfs "ports" group was only being added after
+the activate() callback succeeded.
+
+This patch moves the device_add_groups() in front of the
+call to the trigger's activate() function in order to
+solve the problem.
+
+Fixes: 6f7b0bad8839 ("usb: simplify usbport trigger")
+Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
+---
+ drivers/leds/led-triggers.c | 19 ++++++++++---------
+ 1 file changed, 10 insertions(+), 9 deletions(-)
+
+diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
+index 17d73db1456e..08e7c724a9dc 100644
+--- a/drivers/leds/led-triggers.c
++++ b/drivers/leds/led-triggers.c
+@@ -134,6 +134,12 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
+ led_set_brightness(led_cdev, LED_OFF);
+ }
+ if (trig) {
++ ret = device_add_groups(led_cdev->dev, trig->groups);
++ if (ret) {
++ dev_err(led_cdev->dev, "Failed to add trigger attributes\n");
++ goto err_add_groups;
++ }
++
+ write_lock_irqsave(&trig->leddev_list_lock, flags);
+ list_add_tail(&led_cdev->trig_list, &trig->led_cdevs);
+ write_unlock_irqrestore(&trig->leddev_list_lock, flags);
+@@ -146,12 +152,6 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
+
+ if (ret)
+ goto err_activate;
+-
+- ret = device_add_groups(led_cdev->dev, trig->groups);
+- if (ret) {
+- dev_err(led_cdev->dev, "Failed to add trigger attributes\n");
+- goto err_add_groups;
+- }
+ }
+
+ if (event) {
+@@ -165,17 +165,18 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
+
+ return 0;
+
+-err_add_groups:
+-
++err_activate:
++ device_remove_groups(led_cdev->dev, trig->groups);
+ if (trig->deactivate)
+ trig->deactivate(led_cdev);
+-err_activate:
+
+ led_cdev->trigger = NULL;
+ led_cdev->trigger_data = NULL;
+ write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
+ list_del(&led_cdev->trig_list);
+ write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags);
++
++err_add_groups:
+ led_set_brightness(led_cdev, LED_OFF);
+
+ return ret;
+--
+2.20.1
+