Skip to content

Commit e0b95ba

Browse files
glneolag-linaro
authored andcommitted
leds: lp8860: Only unlock in lp8860_unlock_eeprom()
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>
1 parent b0d6394 commit e0b95ba

File tree

1 file changed

+18
-30
lines changed

1 file changed

+18
-30
lines changed

drivers/leds/leds-lp8860.c

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -129,39 +129,27 @@ static const struct reg_sequence lp8860_eeprom_disp_regs[] = {
129129
{ LP8860_EEPROM_REG_24, 0x3E },
130130
};
131131

132-
static int lp8860_unlock_eeprom(struct lp8860_led *led, int lock)
132+
static int lp8860_unlock_eeprom(struct lp8860_led *led)
133133
{
134134
int ret;
135135

136136
guard(mutex)(&led->lock);
137137

138-
if (lock == LP8860_UNLOCK_EEPROM) {
139-
ret = regmap_write(led->regmap,
140-
LP8860_EEPROM_UNLOCK,
141-
LP8860_EEPROM_CODE_1);
142-
if (ret) {
143-
dev_err(&led->client->dev, "EEPROM Unlock failed\n");
144-
return ret;
145-
}
146-
147-
ret = regmap_write(led->regmap,
148-
LP8860_EEPROM_UNLOCK,
149-
LP8860_EEPROM_CODE_2);
150-
if (ret) {
151-
dev_err(&led->client->dev, "EEPROM Unlock failed\n");
152-
return ret;
153-
}
154-
ret = regmap_write(led->regmap,
155-
LP8860_EEPROM_UNLOCK,
156-
LP8860_EEPROM_CODE_3);
157-
if (ret) {
158-
dev_err(&led->client->dev, "EEPROM Unlock failed\n");
159-
return ret;
160-
}
161-
} else {
162-
ret = regmap_write(led->regmap,
163-
LP8860_EEPROM_UNLOCK,
164-
LP8860_LOCK_EEPROM);
138+
ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_1);
139+
if (ret) {
140+
dev_err(&led->client->dev, "EEPROM Unlock failed\n");
141+
return ret;
142+
}
143+
144+
ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_2);
145+
if (ret) {
146+
dev_err(&led->client->dev, "EEPROM Unlock failed\n");
147+
return ret;
148+
}
149+
ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_3);
150+
if (ret) {
151+
dev_err(&led->client->dev, "EEPROM Unlock failed\n");
152+
return ret;
165153
}
166154

167155
return ret;
@@ -240,7 +228,7 @@ static int lp8860_init(struct lp8860_led *led)
240228
if (ret)
241229
goto out;
242230

243-
ret = lp8860_unlock_eeprom(led, LP8860_UNLOCK_EEPROM);
231+
ret = lp8860_unlock_eeprom(led);
244232
if (ret) {
245233
dev_err(&led->client->dev, "Failed unlocking EEPROM\n");
246234
goto out;
@@ -253,7 +241,7 @@ static int lp8860_init(struct lp8860_led *led)
253241
goto out;
254242
}
255243

256-
ret = lp8860_unlock_eeprom(led, LP8860_LOCK_EEPROM);
244+
ret = regmap_write(led->regmap, LP8860_EEPROM_UNLOCK, LP8860_LOCK_EEPROM);
257245
if (ret)
258246
goto out;
259247

0 commit comments

Comments
 (0)