public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/3] leds: lp5521/5523: Remove duplicate mutex
@ 2013-11-21  6:14 Milo Kim
  2013-12-02 19:40 ` Bryan Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Milo Kim @ 2013-11-21  6:14 UTC (permalink / raw)
  To: Bryan Wu; +Cc: linux-kernel, linux-leds, Milo Kim, Pali Rohár

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.

Cc: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Milo Kim <milo.kim@ti.com>
---
 drivers/leds/leds-lp5521.c |    4 ----
 drivers/leds/leds-lp5523.c |    4 ----
 2 files changed, 8 deletions(-)

diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
index 26f89ac..4c45ed9 100644
--- a/drivers/leds/leds-lp5521.c
+++ b/drivers/leds/leds-lp5521.c
@@ -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:
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index 2ce1723..7a3b369 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] leds: lp5521/5523: Remove duplicate mutex
  2013-11-21  6:14 [PATCH 2/3] leds: lp5521/5523: Remove duplicate mutex Milo Kim
@ 2013-12-02 19:40 ` Bryan Wu
  2013-12-03  1:24   ` Milo Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Bryan Wu @ 2013-12-02 19:40 UTC (permalink / raw)
  To: Milo Kim; +Cc: lkml, Linux LED Subsystem, Pali Rohár

On Wed, Nov 20, 2013 at 10:14 PM, Milo Kim <milo.kim@ti.com> wrote:
> 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

> Cc: Pali Rohár <pali.rohar@gmail.com>
> Signed-off-by: Milo Kim <milo.kim@ti.com>
> ---
>  drivers/leds/leds-lp5521.c |    4 ----
>  drivers/leds/leds-lp5523.c |    4 ----
>  2 files changed, 8 deletions(-)
>
> diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c
> index 26f89ac..4c45ed9 100644
> --- a/drivers/leds/leds-lp5521.c
> +++ b/drivers/leds/leds-lp5521.c
> @@ -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:
> diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
> index 2ce1723..7a3b369 100644
> --- a/drivers/leds/leds-lp5523.c
> +++ b/drivers/leds/leds-lp5523.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/3] leds: lp5521/5523: Remove duplicate mutex
  2013-12-02 19:40 ` Bryan Wu
@ 2013-12-03  1:24   ` Milo Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Milo Kim @ 2013-12-03  1:24 UTC (permalink / raw)
  To: Bryan Wu; +Cc: lkml, Linux LED Subsystem, Pali Rohár

Hi Bryan,

On 12/03/2013 04:40 AM, Bryan Wu wrote:
> On Wed, Nov 20, 2013 at 10:14 PM, Milo Kim <milo.kim@ti.com> wrote:
>> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-12-03  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-21  6:14 [PATCH 2/3] leds: lp5521/5523: Remove duplicate mutex Milo Kim
2013-12-02 19:40 ` Bryan Wu
2013-12-03  1:24   ` Milo Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox