]> err.no Git - linux-2.6/commitdiff
leds: Fix leds_list_lock locking issues
authorRichard Purdie <rpurdie@rpsys.net>
Mon, 31 Dec 2007 23:09:44 +0000 (23:09 +0000)
committerRichard Purdie <rpurdie@rpsys.net>
Mon, 31 Dec 2007 23:09:44 +0000 (23:09 +0000)
Covert leds_list_lock to a rw_sempahore to match previous LED trigger
locking fixes, fixing lock ordering.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
drivers/leds/led-class.c
drivers/leds/led-core.c
drivers/leds/led-triggers.c
drivers/leds/leds.h

index ba8b04b03b9f2799eacba45927595553ce4141df..64c66b3769c99edf05af6ae8d104a70a8240f2e1 100644 (file)
@@ -106,9 +106,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
                goto err_out;
 
        /* add to the list of leds */
-       write_lock(&leds_list_lock);
+       down_write(&leds_list_lock);
        list_add_tail(&led_cdev->node, &leds_list);
-       write_unlock(&leds_list_lock);
+       up_write(&leds_list_lock);
 
 #ifdef CONFIG_LEDS_TRIGGERS
        init_rwsem(&led_cdev->trigger_lock);
@@ -155,9 +155,9 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
 
        device_unregister(led_cdev->dev);
 
-       write_lock(&leds_list_lock);
+       down_write(&leds_list_lock);
        list_del(&led_cdev->node);
-       write_unlock(&leds_list_lock);
+       up_write(&leds_list_lock);
 }
 EXPORT_SYMBOL_GPL(led_classdev_unregister);
 
index 9b015f9af351e49526eb52ec0f0c09b4acb21e56..5d1ca10524b6933bc216fb282815ac6f348cc9d0 100644 (file)
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
-#include <linux/spinlock.h>
+#include <linux/rwsem.h>
 #include <linux/leds.h>
 #include "leds.h"
 
-DEFINE_RWLOCK(leds_list_lock);
+DECLARE_RWSEM(leds_list_lock);
 LIST_HEAD(leds_list);
 
 EXPORT_SYMBOL_GPL(leds_list);
index 0bdb786210b1885bee8e6f194ccdcab09e5bdd18..13c9026d68af0af90e246824df1429496afe6814 100644 (file)
@@ -169,7 +169,7 @@ int led_trigger_register(struct led_trigger *trigger)
        up_write(&triggers_list_lock);
 
        /* Register with any LEDs that have this as a default trigger */
-       read_lock(&leds_list_lock);
+       down_read(&leds_list_lock);
        list_for_each_entry(led_cdev, &leds_list, node) {
                down_write(&led_cdev->trigger_lock);
                if (!led_cdev->trigger && led_cdev->default_trigger &&
@@ -177,7 +177,7 @@ int led_trigger_register(struct led_trigger *trigger)
                        led_trigger_set(led_cdev, trigger);
                up_write(&led_cdev->trigger_lock);
        }
-       read_unlock(&leds_list_lock);
+       up_read(&leds_list_lock);
 
        return 0;
 }
@@ -212,14 +212,14 @@ void led_trigger_unregister(struct led_trigger *trigger)
        up_write(&triggers_list_lock);
 
        /* Remove anyone actively using this trigger */
-       read_lock(&leds_list_lock);
+       down_read(&leds_list_lock);
        list_for_each_entry(led_cdev, &leds_list, node) {
                down_write(&led_cdev->trigger_lock);
                if (led_cdev->trigger == trigger)
                        led_trigger_set(led_cdev, NULL);
                up_write(&led_cdev->trigger_lock);
        }
-       read_unlock(&leds_list_lock);
+       up_read(&leds_list_lock);
 }
 
 void led_trigger_unregister_simple(struct led_trigger *trigger)
index f2f3884fe06314b01a3bb647821c6b4e0ea88e89..12b6fe93b1356b980241ef2f7dae3fd325c30090 100644 (file)
@@ -14,6 +14,7 @@
 #define __LEDS_H_INCLUDED
 
 #include <linux/device.h>
+#include <linux/rwsem.h>
 #include <linux/leds.h>
 
 static inline void led_set_brightness(struct led_classdev *led_cdev,
@@ -26,7 +27,7 @@ static inline void led_set_brightness(struct led_classdev *led_cdev,
                led_cdev->brightness_set(led_cdev, value);
 }
 
-extern rwlock_t leds_list_lock;
+extern struct rw_semaphore leds_list_lock;
 extern struct list_head leds_list;
 
 #ifdef CONFIG_LEDS_TRIGGERS