Commit 77717d27 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds

* 'for-linus' of git://git.o-hand.com/linux-rpurdie-leds:
  leds: Fix locomo LED driver oops
  leds: Fix leds_list_lock locking issues
parents 57ed3eda 8f115cd5
...@@ -106,9 +106,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) ...@@ -106,9 +106,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
goto err_out; goto err_out;
/* add to the list of leds */ /* add to the list of leds */
write_lock(&leds_list_lock); down_write(&leds_list_lock);
list_add_tail(&led_cdev->node, &leds_list); list_add_tail(&led_cdev->node, &leds_list);
write_unlock(&leds_list_lock); up_write(&leds_list_lock);
#ifdef CONFIG_LEDS_TRIGGERS #ifdef CONFIG_LEDS_TRIGGERS
init_rwsem(&led_cdev->trigger_lock); init_rwsem(&led_cdev->trigger_lock);
...@@ -155,9 +155,9 @@ void led_classdev_unregister(struct led_classdev *led_cdev) ...@@ -155,9 +155,9 @@ void led_classdev_unregister(struct led_classdev *led_cdev)
device_unregister(led_cdev->dev); device_unregister(led_cdev->dev);
write_lock(&leds_list_lock); down_write(&leds_list_lock);
list_del(&led_cdev->node); list_del(&led_cdev->node);
write_unlock(&leds_list_lock); up_write(&leds_list_lock);
} }
EXPORT_SYMBOL_GPL(led_classdev_unregister); EXPORT_SYMBOL_GPL(led_classdev_unregister);
......
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h> #include <linux/rwsem.h>
#include <linux/leds.h> #include <linux/leds.h>
#include "leds.h" #include "leds.h"
DEFINE_RWLOCK(leds_list_lock); DECLARE_RWSEM(leds_list_lock);
LIST_HEAD(leds_list); LIST_HEAD(leds_list);
EXPORT_SYMBOL_GPL(leds_list); EXPORT_SYMBOL_GPL(leds_list);
......
...@@ -169,7 +169,7 @@ int led_trigger_register(struct led_trigger *trigger) ...@@ -169,7 +169,7 @@ int led_trigger_register(struct led_trigger *trigger)
up_write(&triggers_list_lock); up_write(&triggers_list_lock);
/* Register with any LEDs that have this as a default trigger */ /* 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) { list_for_each_entry(led_cdev, &leds_list, node) {
down_write(&led_cdev->trigger_lock); down_write(&led_cdev->trigger_lock);
if (!led_cdev->trigger && led_cdev->default_trigger && if (!led_cdev->trigger && led_cdev->default_trigger &&
...@@ -177,7 +177,7 @@ int led_trigger_register(struct led_trigger *trigger) ...@@ -177,7 +177,7 @@ int led_trigger_register(struct led_trigger *trigger)
led_trigger_set(led_cdev, trigger); led_trigger_set(led_cdev, trigger);
up_write(&led_cdev->trigger_lock); up_write(&led_cdev->trigger_lock);
} }
read_unlock(&leds_list_lock); up_read(&leds_list_lock);
return 0; return 0;
} }
...@@ -212,14 +212,14 @@ void led_trigger_unregister(struct led_trigger *trigger) ...@@ -212,14 +212,14 @@ void led_trigger_unregister(struct led_trigger *trigger)
up_write(&triggers_list_lock); up_write(&triggers_list_lock);
/* Remove anyone actively using this trigger */ /* 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) { list_for_each_entry(led_cdev, &leds_list, node) {
down_write(&led_cdev->trigger_lock); down_write(&led_cdev->trigger_lock);
if (led_cdev->trigger == trigger) if (led_cdev->trigger == trigger)
led_trigger_set(led_cdev, NULL); led_trigger_set(led_cdev, NULL);
up_write(&led_cdev->trigger_lock); 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) void led_trigger_unregister_simple(struct led_trigger *trigger)
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
static void locomoled_brightness_set(struct led_classdev *led_cdev, static void locomoled_brightness_set(struct led_classdev *led_cdev,
enum led_brightness value, int offset) enum led_brightness value, int offset)
{ {
struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->dev); struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->dev->parent);
unsigned long flags; unsigned long flags;
local_irq_save(flags); local_irq_save(flags);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define __LEDS_H_INCLUDED #define __LEDS_H_INCLUDED
#include <linux/device.h> #include <linux/device.h>
#include <linux/rwsem.h>
#include <linux/leds.h> #include <linux/leds.h>
static inline void led_set_brightness(struct led_classdev *led_cdev, 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, ...@@ -26,7 +27,7 @@ static inline void led_set_brightness(struct led_classdev *led_cdev,
led_cdev->brightness_set(led_cdev, value); 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; extern struct list_head leds_list;
#ifdef CONFIG_LEDS_TRIGGERS #ifdef CONFIG_LEDS_TRIGGERS
......
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