Skip to content

Commit e70988d

Browse files
Milo Kimcooloney
authored andcommitted
leds: lp5521/5523: Remove duplicate mutex
It can be a problem when a pattern is loaded via the firmware interface. LP55xx common driver has already locked the mutex in 'lp55xx_firmware_loaded()'. So it should be deleted. On the other hand, locks are required in store_engine_load() on updating program memory. Reported-by: Pali Rohár <[email protected]> Reported-by: Pavel Machek <[email protected]> Signed-off-by: Milo Kim <[email protected]> Signed-off-by: Bryan Wu <[email protected]> Cc: <[email protected]>
1 parent 802eee9 commit e70988d

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

drivers/leds/leds-lp5521.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,12 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
244244
if (i % 2)
245245
goto err;
246246

247-
mutex_lock(&chip->lock);
248-
249247
for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
250248
ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
251-
if (ret) {
252-
mutex_unlock(&chip->lock);
249+
if (ret)
253250
return -EINVAL;
254-
}
255251
}
256252

257-
mutex_unlock(&chip->lock);
258-
259253
return size;
260254

261255
err:
@@ -427,15 +421,17 @@ static ssize_t store_engine_load(struct device *dev,
427421
{
428422
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
429423
struct lp55xx_chip *chip = led->chip;
424+
int ret;
430425

431426
mutex_lock(&chip->lock);
432427

433428
chip->engine_idx = nr;
434429
lp5521_load_engine(chip);
430+
ret = lp5521_update_program_memory(chip, buf, len);
435431

436432
mutex_unlock(&chip->lock);
437433

438-
return lp5521_update_program_memory(chip, buf, len);
434+
return ret;
439435
}
440436
store_load(1)
441437
store_load(2)

drivers/leds/leds-lp5523.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,12 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
337337
if (i % 2)
338338
goto err;
339339

340-
mutex_lock(&chip->lock);
341-
342340
for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
343341
ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
344-
if (ret) {
345-
mutex_unlock(&chip->lock);
342+
if (ret)
346343
return -EINVAL;
347-
}
348344
}
349345

350-
mutex_unlock(&chip->lock);
351-
352346
return size;
353347

354348
err:
@@ -548,15 +542,17 @@ static ssize_t store_engine_load(struct device *dev,
548542
{
549543
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
550544
struct lp55xx_chip *chip = led->chip;
545+
int ret;
551546

552547
mutex_lock(&chip->lock);
553548

554549
chip->engine_idx = nr;
555550
lp5523_load_engine_and_select_page(chip);
551+
ret = lp5523_update_program_memory(chip, buf, len);
556552

557553
mutex_unlock(&chip->lock);
558554

559-
return lp5523_update_program_memory(chip, buf, len);
555+
return ret;
560556
}
561557
store_load(1)
562558
store_load(2)

0 commit comments

Comments
 (0)