Skip to contentSkip to conversation

leds: lp5521/5523: Remove duplicate mutex

PATCH In review Milo Kim 2 participants 3 messages Nov 21, 2013 – Dec 3, 2013 LED

lore
Share & tools
lore

Milo Kim

author
#0 lore raw

PATCH 2/3 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.

---
 drivers/leds/leds-lp5521.c |    4 ----
 drivers/leds/leds-lp5523.c |    4 ----
 2 files changed, 8 deletions(-)
drivers/leds/leds-lp5521.c +0 -4
index 26f89ac..4c45ed9 100644
@@ -258,8 +258,6 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
 	if (i % 2)
 		goto err;
 
-	mutex_lock(&chip->lock);
-
 	for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
 		ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
 		if (ret) {
@@ -268,8 +266,6 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
 		}
 	}
 
-	mutex_unlock(&chip->lock);
-
 	return size;
 
 err:
drivers/leds/leds-lp5523.c +0 -4
index 2ce1723..7a3b369 100644
@@ -351,8 +351,6 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
 	if (i % 2)
 		goto err;
 
-	mutex_lock(&chip->lock);
-
 	for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
 		ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
 		if (ret) {
@@ -361,8 +359,6 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
 		}
 	}
 
-	mutex_unlock(&chip->lock);
-
 	return size;
 
 err:
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 4 lines · Milo Kim

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.

Looks like lp5521_update_program_memory() will be called by store_engine_load() without holding a lock after this change, is this correct? I think you need also update store_engine_load() to hold the lock when calling lp5521_update_program_memory().

Thanks,
-Bryan

Quoted 54 lines
---
 drivers/leds/leds-lp5521.c |    4 ----
 drivers/leds/leds-lp5523.c |    4 ----
 2 files changed, 8 deletions(-)
drivers/leds/leds-lp5521.c +0 -4
index 26f89ac..4c45ed9 100644
@@ -258,8 +258,6 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
        if (i % 2)
                goto err;
 
-       mutex_lock(&chip->lock);
-
        for (i = 0; i < LP5521_PROGRAM_LENGTH; i++) {
                ret = lp55xx_write(chip, addr[idx] + i, pattern[i]);
                if (ret) {
@@ -268,8 +266,6 @@ static int lp5521_update_program_memory(struct lp55xx_chip *chip,
                }
        }
 
-       mutex_unlock(&chip->lock);
-
        return size;
 
 err:
drivers/leds/leds-lp5523.c +0 -5
index 2ce1723..7a3b369 100644
@@ -351,8 +351,6 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
        if (i % 2)
                goto err;
 
-       mutex_lock(&chip->lock);
-
        for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
                ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
                if (ret) {
@@ -361,8 +359,6 @@ static int lp5523_update_program_memory(struct lp55xx_chip *chip,
                }
        }
 
-       mutex_unlock(&chip->lock);
-
        return size;
 
 err:
--

1.7.9.5

author
#2 lore raw

Hi Bryan,

Quoted 10 lines · Bryan Wu
Quoted 4 lines · Milo Kim

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.

Looks like lp5521_update_program_memory() will be called by store_engine_load() without holding a lock after this change, is this correct? I think you need also update store_engine_load() to hold the lock when calling lp5521_update_program_memory().

Thanks, good point! I've just sent the patch-v2.

Best regards,
Milo