]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: lp8860: Only unlock in lp8860_unlock_eeprom()
authorAndrew Davis <afd@ti.com>
Mon, 7 Apr 2025 18:35:54 +0000 (13:35 -0500)
committerLee Jones <lee@kernel.org>
Wed, 14 May 2025 08:24:55 +0000 (09:24 +0100)
Locking is a single register write, so no need to have the unlock
function also lock. This removes the need to pass in the option
and reduces the nesting level in the function.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20250407183555.409687-5-afd@ti.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-lp8860.c

index 2ceebdb5820e5bf5589243cfcd3f49d0e0bc59b6..8b3660f80f4cf8867f3e0708b5798e75d839f311 100644 (file)
@@ -129,39 +129,27 @@ static const struct reg_sequence lp8860_eeprom_disp_regs[] = {
        { LP8860_EEPROM_REG_24, 0x3E },
 };
 
-static int lp8860_unlock_eeprom(struct lp8860_led *led, int lock)
+static int lp8860_unlock_eeprom(struct lp8860_led *led)
 {
        int ret;
 
        guard(mutex)(&led->lock);
 
-       if (lock == LP8860_UNLOCK_EEPROM) {
-               ret = regmap_write(led->regmap,
-                       LP8860_EEPROM_UNLOCK,
-                       LP8860_EEPROM_CODE_1);
-               if (ret) {
-                       dev_err(&led->client->dev, "EEPROM Unlock failed\n");
-                       return ret;
-               }
-
-               ret = regmap_write(led->regmap,
-                       LP8860_EEPROM_UNLOCK,
-                       LP8860_EEPROM_CODE_2);
-               if (ret) {
-                       dev_err(&led->client->dev, "EEPROM Unlock failed\n");
-                       return ret;
-               }
-               ret = regmap_write(led->regmap,
-                       LP8860_EEPROM_UNLOCK,
-                       LP8860_EEPROM_CODE_3);
-               if (ret) {
-                       dev_err(&led->client->dev, "EEPROM Unlock failed\n");
-                       return ret;
-               }
-       } else {
-               ret = regmap_write(led->regmap,
-                       LP8860_EEPROM_UNLOCK,
-                       LP8860_LOCK_EEPROM);
+       ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_1);
+       if (ret) {
+               dev_err(&led->client->dev, "EEPROM Unlock failed\n");
+               return ret;
+       }
+
+       ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_2);
+       if (ret) {
+               dev_err(&led->client->dev, "EEPROM Unlock failed\n");
+               return ret;
+       }
+       ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_3);
+       if (ret) {
+               dev_err(&led->client->dev, "EEPROM Unlock failed\n");
+               return ret;
        }
 
        return ret;
@@ -240,7 +228,7 @@ static int lp8860_init(struct lp8860_led *led)
        if (ret)
                goto out;
 
-       ret = lp8860_unlock_eeprom(led, LP8860_UNLOCK_EEPROM);
+       ret = lp8860_unlock_eeprom(led);
        if (ret) {
                dev_err(&led->client->dev, "Failed unlocking EEPROM\n");
                goto out;
@@ -253,7 +241,7 @@ static int lp8860_init(struct lp8860_led *led)
                goto out;
        }
 
-       ret = lp8860_unlock_eeprom(led, LP8860_LOCK_EEPROM);
+       ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_LOCK_EEPROM);
        if (ret)
                goto out;