Commit 41f80046 authored by Andy Shevchenko's avatar Andy Shevchenko

platform/x86: thinkpad_acpi: Drop duplicate check for led_classdev_unregister()

led_classdev_unregister() already has the similar check, so,
drop a duplicate in the driver.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent a87406c5
......@@ -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);
}
}
......
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