leds: leds-ns2: fix locking
PATCH 1/1 leds: leds-ns2: fix locking
From: sguinot <sguinot@e0769a12-487d-4b36-8fb5-9ece92c58341>
This patch replace all the lock functions with the irq safe variant. The ns2_led_{set,get}_mode() functions must be safe in all context.
For example, the trigger timer call led_set_brightness() in a softirq context.
--- drivers/leds/leds-ns2.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/leds/leds-ns2.c +5 -4
@@ -81,7 +81,7 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat,int cmd_level;int slow_level; -read_lock (&led_dat->rw_lock); +read_lock_irq (&led_dat->rw_lock); cmd_level =gpio_get_value (led_dat->cmd); slow_level =gpio_get_value (led_dat->slow);
@@ -95,7 +95,7 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat, } } -read_unlock (&led_dat->rw_lock); +read_unlock_irq (&led_dat->rw_lock);return ret; }
@@ -104,8 +104,9 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, enum ns2_led_modes mode) {int i; +unsigned long flags; -write_lock (&led_dat->rw_lock); +write_lock_irqsave (&led_dat->rw_lock, flags);for (i =0 ; i <ARRAY_SIZE (ns2_led_modval); i++) {if (mode == ns2_led_modval[i].mode) {
@@ -116,7 +117,7 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, } } -write_unlock (&led_dat->rw_lock); +write_unlock_irqrestore (&led_dat->rw_lock, flags); } static void ns2_led_set(struct led_classdev *led_cdev,
Signature · 1 line
1.6.3.1
PATCH 1/1 leds: leds-ns2: fix locking
Quoted 1 line · Simon Guinot
From: sguinot <sguinot@e0769a12-487d-4b36-8fb5-9ece92c58341>
Sorry for the bad author field. I will resend this patch.
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100919/6d84c11a/attachment.sig>
PATCH 1/1 leds: leds-ns2: fix locking
From: Simon Guinot <[email protected]>
This patch replace all the lock functions with the irq safe variant. The ns2_led_{set,get}_mode() functions must be safe in all context.
For example, the trigger timer call led_set_brightness() in a softirq context.
--- drivers/leds/leds-ns2.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/leds/leds-ns2.c +5 -4
@@ -81,7 +81,7 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat,int cmd_level;int slow_level; -read_lock (&led_dat->rw_lock); +read_lock_irq (&led_dat->rw_lock); cmd_level =gpio_get_value (led_dat->cmd); slow_level =gpio_get_value (led_dat->slow);
@@ -95,7 +95,7 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat, } } -read_unlock (&led_dat->rw_lock); +read_unlock_irq (&led_dat->rw_lock);return ret; }
@@ -104,8 +104,9 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, enum ns2_led_modes mode) {int i; +unsigned long flags; -write_lock (&led_dat->rw_lock); +write_lock_irqsave (&led_dat->rw_lock, flags);for (i =0 ; i <ARRAY_SIZE (ns2_led_modval); i++) {if (mode == ns2_led_modval[i].mode) {
@@ -116,7 +117,7 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, } } -write_unlock (&led_dat->rw_lock); +write_unlock_irqrestore (&led_dat->rw_lock, flags); } static void ns2_led_set(struct led_classdev *led_cdev,
Signature · 1 line
1.6.3.1
PATCH 1/1 leds: leds-ns2: fix locking
In reply to Simon GuinotQuoted 1 line · Simon Guinot
From: sguinot <sguinot@e0769a12-487d-4b36-8fb5-9ece92c58341>
You should find out why your Git setup produces the above. Your identity was most likely misconfigured when making this commit.
I've fixed it up locally.
Quoted 56 lines
This patch replace all the lock functions with the irq safe variant. The ns2_led_{set,get}_mode() functions must be safe in all context.
For example, the trigger timer call
led_set_brightness()in a softirq context.Signed-off-by Simon Guinot <[email protected]>--- drivers/leds/leds-ns2.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)drivers/leds/leds-ns2.c +5
-4@@ -81,7 +81,7 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat,int cmd_level;int slow_level; -read_lock (&led_dat->rw_lock); +read_lock_irq (&led_dat->rw_lock); cmd_level =gpio_get_value (led_dat->cmd); slow_level =gpio_get_value (led_dat->slow);@@ -95,7 +95,7 @@ static int ns2_led_get_mode(struct ns2_led_data *led_dat, } } -read_unlock (&led_dat->rw_lock); +read_unlock_irq (&led_dat->rw_lock);return ret; }@@ -104,8 +104,9 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, enum ns2_led_modes mode) {int i; +unsigned long flags; -write_lock (&led_dat->rw_lock); +write_lock_irqsave (&led_dat->rw_lock, flags);for (i =0 ; i <ARRAY_SIZE (ns2_led_modval); i++) {if (mode == ns2_led_modval[i].mode) {@@ -116,7 +117,7 @@ static void ns2_led_set_mode(struct ns2_led_data *led_dat, } } -write_unlock (&led_dat->rw_lock); +write_unlock_irqrestore (&led_dat->rw_lock, flags); } static void ns2_led_set(struct led_classdev *led_cdev,Signature · 1 line
1.6.3.1