Commit e70988d1 authored by Milo Kim's avatar Milo Kim Committed by Bryan Wu

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: default avatarPali Rohár <pali.rohar@gmail.com>
Reported-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarMilo Kim <milo.kim@ti.com>
Signed-off-by: default avatarBryan Wu <cooloney@gmail.com>
Cc: <stable@vger.kernel.org>
parent 802eee95
...@@ -244,17 +244,11 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip, ...@@ -244,17 +244,11 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
if (i % 2) if (i % 2)
goto err; goto err;
mutex_lock(&chip->lock);
for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) { for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
ret = lp55xx_write(chip, addr[idx] + i, pattern[i]); ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
if (ret) { if (ret)
mutex_unlock(&chip->lock);
return -EINVAL; return -EINVAL;
} }
}
mutex_unlock(&chip->lock);
return size; return size;
...@@ -427,15 +421,17 @@ static ssize_t store_engine_load(struct device *dev, ...@@ -427,15 +421,17 @@ static ssize_t store_engine_load(struct device *dev,
{ {
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip; struct lp55xx_chip *chip = led->chip;
int ret;
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
chip->engine_idx = nr; chip->engine_idx = nr;
lp5521_load_engine(chip); lp5521_load_engine(chip);
ret = lp5521_update_program_memory(chip, buf, len);
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
return lp5521_update_program_memory(chip, buf, len); return ret;
} }
store_load(1) store_load(1)
store_load(2) store_load(2)
......
...@@ -337,17 +337,11 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip, ...@@ -337,17 +337,11 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
if (i % 2) if (i % 2)
goto err; goto err;
mutex_lock(&chip->lock);
for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) { for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]); ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
if (ret) { if (ret)
mutex_unlock(&chip->lock);
return -EINVAL; return -EINVAL;
} }
}
mutex_unlock(&chip->lock);
return size; return size;
...@@ -548,15 +542,17 @@ static ssize_t store_engine_load(struct device *dev, ...@@ -548,15 +542,17 @@ static ssize_t store_engine_load(struct device *dev,
{ {
struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev)); struct lp55xx_led *led = i2c_get_clientdata(to_i2c_client(dev));
struct lp55xx_chip *chip = led->chip; struct lp55xx_chip *chip = led->chip;
int ret;
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
chip->engine_idx = nr; chip->engine_idx = nr;
lp5523_load_engine_and_select_page(chip); lp5523_load_engine_and_select_page(chip);
ret = lp5523_update_program_memory(chip, buf, len);
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
return lp5523_update_program_memory(chip, buf, len); return ret;
} }
store_load(1) store_load(1)
store_load(2) store_load(2)
......
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