]> git.karo-electronics.de Git - linux-beck.git/commitdiff
leds-lp55xx: clean up deinit_device() in lp5521/5523
authorMilo(Woogyom) Kim <milo.kim@ti.com>
Tue, 5 Feb 2013 08:50:36 +0000 (17:50 +0900)
committerBryan Wu <cooloney@gmail.com>
Wed, 6 Feb 2013 23:59:26 +0000 (15:59 -0800)
 Device de-initialization code is moved to _deinit_device() at each driver.
 This patch is a preceding step for lp55xx common driver architecture.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Bryan Wu <cooloney@gmail.com>
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp5523.c

index 24f439f78bd8edc1289aebefe8229c8dc5c9cd61..fd963fe0a944a8c7a75814428b986044e0086714 100644 (file)
@@ -740,6 +740,16 @@ static int lp5521_init_device(struct lp5521_chip *chip)
        return ret;
 }
 
+static void lp5521_deinit_device(struct lp5521_chip *chip)
+{
+       struct lp5521_platform_data *pdata = chip->pdata;
+
+       if (pdata->enable)
+               pdata->enable(0);
+       if (pdata->release_resources)
+               pdata->release_resources();
+}
+
 static int lp5521_init_led(struct lp5521_led *led,
                                struct i2c_client *client,
                                int chan, struct lp5521_platform_data *pdata)
@@ -865,10 +875,7 @@ fail2:
                cancel_work_sync(&chip->leds[i].brightness_work);
        }
 fail1:
-       if (pdata->enable)
-               pdata->enable(0);
-       if (pdata->release_resources)
-               pdata->release_resources();
+       lp5521_deinit_device(chip);
        return ret;
 }
 
@@ -885,10 +892,7 @@ static int lp5521_remove(struct i2c_client *client)
                cancel_work_sync(&chip->leds[i].brightness_work);
        }
 
-       if (chip->pdata->enable)
-               chip->pdata->enable(0);
-       if (chip->pdata->release_resources)
-               chip->pdata->release_resources();
+       lp5521_deinit_device(chip);
        return 0;
 }
 
index 491ea725bb0b8d5e25e01e412e565a6e1160973a..ddb482aebe143295ff3d41160e202428b409a444 100644 (file)
@@ -923,6 +923,16 @@ static int lp5523_init_device(struct lp5523_chip *chip)
        return lp5523_detect(client);
 }
 
+static void lp5523_deinit_device(struct lp5523_chip *chip)
+{
+       struct lp5523_platform_data *pdata = chip->pdata;
+
+       if (pdata->enable)
+               pdata->enable(0);
+       if (pdata->release_resources)
+               pdata->release_resources();
+}
+
 static int lp5523_probe(struct i2c_client *client,
                        const struct i2c_device_id *id)
 {
@@ -1009,10 +1019,7 @@ fail2:
                flush_work(&chip->leds[i].brightness_work);
        }
 fail1:
-       if (pdata->enable)
-               pdata->enable(0);
-       if (pdata->release_resources)
-               pdata->release_resources();
+       lp5523_deinit_device(chip);
        return ret;
 }
 
@@ -1031,10 +1038,7 @@ static int lp5523_remove(struct i2c_client *client)
                flush_work(&chip->leds[i].brightness_work);
        }
 
-       if (chip->pdata->enable)
-               chip->pdata->enable(0);
-       if (chip->pdata->release_resources)
-               chip->pdata->release_resources();
+       lp5523_deinit_device(chip);
        return 0;
 }