From: David Herrmann <dh.herrmann at gmail.com> There is really no reason to use a mutex to protect a simple list. Convert the list-lock to a simple spinlock instead. The spin-locks prepare for a backlight_find() helper, which should preferably be usable from atomic context. A mutex would prevent that, so use an irq-save spinlock instead. Signed-off-by: David Herrmann <dh.herrmann at gmail.com> --- drivers/video/backlight/backlight.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c index 37f6173..716c091 100644 --- a/drivers/video/backlight/backlight.c +++ b/drivers/video/backlight/backlight.c @@ -16,13 +16,14 @@ #include <linux/err.h> #include <linux/fb.h> #include <linux/slab.h> +#include <linux/spinlock.h> #ifdef CONFIG_PMAC_BACKLIGHT #include <asm/backlight.h> #endif static LIST_HEAD(backlight_dev_list); -static DEFINE_MUTEX(backlight_dev_list_mutex); +static DEFINE_SPINLOCK(backlight_dev_list_lock); static BLOCKING_NOTIFIER_HEAD(backlight_notifier); static const char *const backlight_types[] = { @@ -378,9 +379,9 @@ struct backlight_device *backlight_device_register(const char *name, mutex_unlock(&pmac_backlight_mutex); #endif - mutex_lock(&backlight_dev_list_mutex); + spin_lock_irq(&backlight_dev_list_lock); list_add(&new_bd->entry, &backlight_dev_list); - mutex_unlock(&backlight_dev_list_mutex); + spin_unlock_irq(&backlight_dev_list_lock); blocking_notifier_call_chain(&backlight_notifier, BACKLIGHT_REGISTERED, new_bd); @@ -393,15 +394,16 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type) { bool found = false; struct backlight_device *bd; + unsigned long flags; - mutex_lock(&backlight_dev_list_mutex); + spin_lock_irqsave(&backlight_dev_list_lock, flags); list_for_each_entry(bd, &backlight_dev_list, entry) { if (bd->props.type == type) { found = true; break; } } - mutex_unlock(&backlight_dev_list_mutex); + spin_unlock_irqrestore(&backlight_dev_list_lock, flags); return found ? bd : NULL; } @@ -418,9 +420,9 @@ void backlight_device_unregister(struct backlight_device *bd) if (!bd) return; - mutex_lock(&backlight_dev_list_mutex); + spin_lock_irq(&backlight_dev_list_lock); list_del(&bd->entry); - mutex_unlock(&backlight_dev_list_mutex); + spin_unlock_irq(&backlight_dev_list_lock); #ifdef CONFIG_PMAC_BACKLIGHT mutex_lock(&pmac_backlight_mutex); -- 2.9.3 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel