Commit 4ae18398 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] tm6000: Use just one lock for devlist

This avoids a race condition
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 06f08e3a
...@@ -644,7 +644,6 @@ void tm6000_add_into_devlist(struct tm6000_core *dev) ...@@ -644,7 +644,6 @@ void tm6000_add_into_devlist(struct tm6000_core *dev)
*/ */
static LIST_HEAD(tm6000_extension_devlist); static LIST_HEAD(tm6000_extension_devlist);
static DEFINE_MUTEX(tm6000_extension_devlist_lock);
int tm6000_call_fillbuf(struct tm6000_core *dev, enum tm6000_ops_type type, int tm6000_call_fillbuf(struct tm6000_core *dev, enum tm6000_ops_type type,
char *buf, int size) char *buf, int size)
...@@ -668,14 +667,12 @@ int tm6000_register_extension(struct tm6000_ops *ops) ...@@ -668,14 +667,12 @@ int tm6000_register_extension(struct tm6000_ops *ops)
struct tm6000_core *dev = NULL; struct tm6000_core *dev = NULL;
mutex_lock(&tm6000_devlist_mutex); mutex_lock(&tm6000_devlist_mutex);
mutex_lock(&tm6000_extension_devlist_lock);
list_add_tail(&ops->next, &tm6000_extension_devlist); list_add_tail(&ops->next, &tm6000_extension_devlist);
list_for_each_entry(dev, &tm6000_devlist, devlist) { list_for_each_entry(dev, &tm6000_devlist, devlist) {
ops->init(dev); ops->init(dev);
printk(KERN_INFO "%s: Initialized (%s) extension\n", printk(KERN_INFO "%s: Initialized (%s) extension\n",
dev->name, ops->name); dev->name, ops->name);
} }
mutex_unlock(&tm6000_extension_devlist_lock);
mutex_unlock(&tm6000_devlist_mutex); mutex_unlock(&tm6000_devlist_mutex);
return 0; return 0;
} }
...@@ -691,10 +688,8 @@ void tm6000_unregister_extension(struct tm6000_ops *ops) ...@@ -691,10 +688,8 @@ void tm6000_unregister_extension(struct tm6000_ops *ops)
ops->fini(dev); ops->fini(dev);
} }
mutex_lock(&tm6000_extension_devlist_lock);
printk(KERN_INFO "tm6000: Remove (%s) extension\n", ops->name); printk(KERN_INFO "tm6000: Remove (%s) extension\n", ops->name);
list_del(&ops->next); list_del(&ops->next);
mutex_unlock(&tm6000_extension_devlist_lock);
mutex_unlock(&tm6000_devlist_mutex); mutex_unlock(&tm6000_devlist_mutex);
} }
EXPORT_SYMBOL(tm6000_unregister_extension); EXPORT_SYMBOL(tm6000_unregister_extension);
...@@ -703,26 +698,26 @@ void tm6000_init_extension(struct tm6000_core *dev) ...@@ -703,26 +698,26 @@ void tm6000_init_extension(struct tm6000_core *dev)
{ {
struct tm6000_ops *ops = NULL; struct tm6000_ops *ops = NULL;
mutex_lock(&tm6000_extension_devlist_lock); mutex_lock(&tm6000_devlist_mutex);
if (!list_empty(&tm6000_extension_devlist)) { if (!list_empty(&tm6000_extension_devlist)) {
list_for_each_entry(ops, &tm6000_extension_devlist, next) { list_for_each_entry(ops, &tm6000_extension_devlist, next) {
if (ops->init) if (ops->init)
ops->init(dev); ops->init(dev);
} }
} }
mutex_unlock(&tm6000_extension_devlist_lock); mutex_unlock(&tm6000_devlist_mutex);
} }
void tm6000_close_extension(struct tm6000_core *dev) void tm6000_close_extension(struct tm6000_core *dev)
{ {
struct tm6000_ops *ops = NULL; struct tm6000_ops *ops = NULL;
mutex_lock(&tm6000_extension_devlist_lock); mutex_lock(&tm6000_devlist_mutex);
if (!list_empty(&tm6000_extension_devlist)) { if (!list_empty(&tm6000_extension_devlist)) {
list_for_each_entry(ops, &tm6000_extension_devlist, next) { list_for_each_entry(ops, &tm6000_extension_devlist, next) {
if (ops->fini) if (ops->fini)
ops->fini(dev); ops->fini(dev);
} }
} }
mutex_unlock(&tm6000_extension_devlist_lock); mutex_lock(&tm6000_devlist_mutex);
} }
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