From: Christian Lamparter Date: Fri, 18 Jan 2019 12:51:09 +0000 (+0100) Subject: kernel: 4.19: use upstream usbport led trigger fix X-Git-Tag: v19.07.0-rc1~1524 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b5f6ede3c4e4f7cc0d2127982a0ad320d8ebd164;p=oweals%2Fopenwrt.git kernel: 4.19: use upstream usbport led trigger fix This patch replaces the current hack with a better version of the RFC patch has been accepted upstream. Signed-off-by: Christian Lamparter --- diff --git a/target/linux/generic/backport-4.19/800-v5.0-usb-leds-fix-regression-in-usbport-led-trigger.patch b/target/linux/generic/backport-4.19/800-v5.0-usb-leds-fix-regression-in-usbport-led-trigger.patch new file mode 100644 index 0000000000..112a01a8dc --- /dev/null +++ b/target/linux/generic/backport-4.19/800-v5.0-usb-leds-fix-regression-in-usbport-led-trigger.patch @@ -0,0 +1,91 @@ +From 91f7d2e89868fcac0e750a28230fdb1ad4512137 Mon Sep 17 00:00:00 2001 +From: Christian Lamparter +Date: Fri, 11 Jan 2019 17:29:45 +0100 +Subject: USB: leds: fix regression in usbport led trigger + +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 active usb hub ports under the +"ports" directory in the sysfs class directory, if the usb host drivers +are fully initialized before the usbport trigger was loaded. + +The reason is that the usbport driver tries to register the sysfs +entries during the activate() callback. And this will fail with -2 / +ENOENT because 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 version of the patch reverts parts of the "usb: simplify usbport +trigger" patch and restores usbport trigger's functionality. + +Fixes: 6f7b0bad8839 ("usb: simplify usbport trigger") +Signed-off-by: Christian Lamparter +Cc: stable +Acked-by: Jacek Anaszewski +Signed-off-by: Greg Kroah-Hartman +--- +--- a/drivers/usb/core/ledtrig-usbport.c ++++ b/drivers/usb/core/ledtrig-usbport.c +@@ -119,11 +119,6 @@ static const struct attribute_group ports_group = { + .attrs = ports_attrs, + }; + +-static const struct attribute_group *ports_groups[] = { +- &ports_group, +- NULL +-}; +- + /*************************************** + * Adding & removing ports + ***************************************/ +@@ -307,6 +302,7 @@ static int usbport_trig_notify(struct notifier_block *nb, unsigned long action, + static int usbport_trig_activate(struct led_classdev *led_cdev) + { + struct usbport_trig_data *usbport_data; ++ int err; + + usbport_data = kzalloc(sizeof(*usbport_data), GFP_KERNEL); + if (!usbport_data) +@@ -315,6 +311,9 @@ static int usbport_trig_activate(struct led_classdev *led_cdev) + + /* List of ports */ + INIT_LIST_HEAD(&usbport_data->ports); ++ err = sysfs_create_group(&led_cdev->dev->kobj, &ports_group); ++ if (err) ++ goto err_free; + usb_for_each_dev(usbport_data, usbport_trig_add_usb_dev_ports); + usbport_trig_update_count(usbport_data); + +@@ -322,8 +321,11 @@ static int usbport_trig_activate(struct led_classdev *led_cdev) + usbport_data->nb.notifier_call = usbport_trig_notify; + led_set_trigger_data(led_cdev, usbport_data); + usb_register_notify(&usbport_data->nb); +- + return 0; ++ ++err_free: ++ kfree(usbport_data); ++ return err; + } + + static void usbport_trig_deactivate(struct led_classdev *led_cdev) +@@ -335,6 +337,8 @@ static void usbport_trig_deactivate(struct led_classdev *led_cdev) + usbport_trig_remove_port(usbport_data, port); + } + ++ sysfs_remove_group(&led_cdev->dev->kobj, &ports_group); ++ + usb_unregister_notify(&usbport_data->nb); + + kfree(usbport_data); +@@ -344,7 +348,6 @@ static struct led_trigger usbport_led_trigger = { + .name = "usbport", + .activate = usbport_trig_activate, + .deactivate = usbport_trig_deactivate, +- .groups = ports_groups, + }; + + static int __init usbport_trig_init(void) +-- +cgit 1.2-0.3.lf.el7 + 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 deleted file mode 100644 index e24cac3ddd..0000000000 --- a/target/linux/generic/hack-4.19/160-leds-fix-regression-in-usbport-led-trigger.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 38a3549ffc0033761063cc5c7b994ab075694db8 Mon Sep 17 00:00:00 2001 -From: Christian Lamparter -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 ---- - drivers/leds/led-triggers.c | 19 ++++++++++--------- - 1 file changed, 10 insertions(+), 9 deletions(-) - ---- a/drivers/leds/led-triggers.c -+++ b/drivers/leds/led-triggers.c -@@ -134,6 +134,12 @@ int led_trigger_set(struct led_classdev - 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 - - 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 - - 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;