]> git.baikalelectronics.ru Git - kernel.git/commitdiff
platform/x86: thinkpad_acpi: Drop duplicate check for led_classdev_unregister()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 7 May 2020 16:37:23 +0000 (19:37 +0300)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 7 May 2020 17:14:24 +0000 (20:14 +0300)
led_classdev_unregister() already has the similar check, so,
drop a duplicate in the driver.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
drivers/platform/x86/thinkpad_acpi.c

index 31377629ea575f97a0e574cf094b9388c8e5d6c0..f8d4fb4d97ca66189384706e345827c09c7b7808 100644 (file)
@@ -5434,8 +5434,7 @@ static int __init kbdlight_init(struct ibm_init_struct *iibm)
 
 static void kbdlight_exit(void)
 {
-       if (tp_features.kbdlight)
-               led_classdev_unregister(&tpacpi_led_kbdlight.led_classdev);
+       led_classdev_unregister(&tpacpi_led_kbdlight.led_classdev);
 }
 
 static int kbdlight_set_level_and_update(int level)
@@ -5949,20 +5948,14 @@ static void led_exit(void)
 {
        unsigned int i;
 
-       for (i = 0; i < TPACPI_LED_NUMLEDS; i++) {
-               if (tpacpi_leds[i].led_classdev.name)
-                       led_classdev_unregister(&tpacpi_leds[i].led_classdev);
-       }
+       for (i = 0; i < TPACPI_LED_NUMLEDS; i++)
+               led_classdev_unregister(&tpacpi_leds[i].led_classdev);
 
        kfree(tpacpi_leds);
 }
 
 static int __init tpacpi_init_led(unsigned int led)
 {
-       int rc;
-
-       tpacpi_leds[led].led = led;
-
        /* LEDs with no name don't get registered */
        if (!tpacpi_led_names[led])
                return 0;
@@ -5970,17 +5963,12 @@ static int __init tpacpi_init_led(unsigned int led)
        tpacpi_leds[led].led_classdev.brightness_set_blocking = &led_sysfs_set;
        tpacpi_leds[led].led_classdev.blink_set = &led_sysfs_blink_set;
        if (led_supported == TPACPI_LED_570)
-               tpacpi_leds[led].led_classdev.brightness_get =
-                                               &led_sysfs_get;
+               tpacpi_leds[led].led_classdev.brightness_get = &led_sysfs_get;
 
        tpacpi_leds[led].led_classdev.name = tpacpi_led_names[led];
+       tpacpi_leds[led].led = led;
 
-       rc = led_classdev_register(&tpacpi_pdev->dev,
-                               &tpacpi_leds[led].led_classdev);
-       if (rc < 0)
-               tpacpi_leds[led].led_classdev.name = NULL;
-
-       return rc;
+       return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev);
 }
 
 static const struct tpacpi_quirk led_useful_qtable[] __initconst = {
@@ -6090,8 +6078,7 @@ static int __init led_init(struct ibm_init_struct *iibm)
        for (i = 0; i < TPACPI_LED_NUMLEDS; i++) {
                tpacpi_leds[i].led = -1;
 
-               if (!tpacpi_is_led_restricted(i) &&
-                   test_bit(i, &useful_leds)) {
+               if (!tpacpi_is_led_restricted(i) && test_bit(i, &useful_leds)) {
                        rc = tpacpi_init_led(i);
                        if (rc < 0) {
                                led_exit();
@@ -6148,8 +6135,10 @@ static int led_write(char *buf)
                if (sscanf(cmd, "%d", &led) != 1)
                        return -EINVAL;
 
-               if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1) ||
-                               tpacpi_leds[led].led < 0)
+               if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1))
+                       return -ENODEV;
+
+               if (tpacpi_leds[led].led < 0)
                        return -ENODEV;
 
                if (strstr(cmd, "off")) {
@@ -9302,10 +9291,8 @@ static int mute_led_init(struct ibm_init_struct *iibm)
                mute_led_cdev[i].brightness = ledtrig_audio_get(i);
                err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]);
                if (err < 0) {
-                       while (i--) {
-                               if (led_tables[i].state >= 0)
-                                       led_classdev_unregister(&mute_led_cdev[i]);
-                       }
+                       while (i--)
+                               led_classdev_unregister(&mute_led_cdev[i]);
                        return err;
                }
        }
@@ -9317,10 +9304,8 @@ static void mute_led_exit(void)
        int i;
 
        for (i = 0; i < TPACPI_LED_MAX; i++) {
-               if (led_tables[i].state >= 0) {
-                       led_classdev_unregister(&mute_led_cdev[i]);
-                       tpacpi_led_set(i, false);
-               }
+               led_classdev_unregister(&mute_led_cdev[i]);
+               tpacpi_led_set(i, false);
        }
 }