diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-04-07 16:07:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-05-19 11:58:28 -0400 |
commit | 5013318ca4fd22e30fd891f234b60daa3ca2f62d (patch) | |
tree | 5aa4c5aa1b1c39463267d03c46635a7a732718d9 /drivers | |
parent | d922b8ea33afad725920375b2d3bd65218cdb133 (diff) |
V4L/DVB: em28xx: fix locks during dvb init sequence
Serialize DVB initialization, to avoid it to happen while analog
initialization is still happening.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-core.c | 13 | ||||
-rw-r--r-- | drivers/media/video/em28xx/em28xx-dvb.c | 10 |
2 files changed, 10 insertions, 13 deletions
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 258041d0be9e..d3813ed789d9 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
@@ -1178,21 +1178,18 @@ void em28xx_add_into_devlist(struct em28xx *dev) | |||
1178 | */ | 1178 | */ |
1179 | 1179 | ||
1180 | static LIST_HEAD(em28xx_extension_devlist); | 1180 | static LIST_HEAD(em28xx_extension_devlist); |
1181 | static DEFINE_MUTEX(em28xx_extension_devlist_lock); | ||
1182 | 1181 | ||
1183 | int em28xx_register_extension(struct em28xx_ops *ops) | 1182 | int em28xx_register_extension(struct em28xx_ops *ops) |
1184 | { | 1183 | { |
1185 | struct em28xx *dev = NULL; | 1184 | struct em28xx *dev = NULL; |
1186 | 1185 | ||
1187 | mutex_lock(&em28xx_devlist_mutex); | 1186 | mutex_lock(&em28xx_devlist_mutex); |
1188 | mutex_lock(&em28xx_extension_devlist_lock); | ||
1189 | list_add_tail(&ops->next, &em28xx_extension_devlist); | 1187 | list_add_tail(&ops->next, &em28xx_extension_devlist); |
1190 | list_for_each_entry(dev, &em28xx_devlist, devlist) { | 1188 | list_for_each_entry(dev, &em28xx_devlist, devlist) { |
1191 | if (dev) | 1189 | if (dev) |
1192 | ops->init(dev); | 1190 | ops->init(dev); |
1193 | } | 1191 | } |
1194 | printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); | 1192 | printk(KERN_INFO "Em28xx: Initialized (%s) extension\n", ops->name); |
1195 | mutex_unlock(&em28xx_extension_devlist_lock); | ||
1196 | mutex_unlock(&em28xx_devlist_mutex); | 1193 | mutex_unlock(&em28xx_devlist_mutex); |
1197 | return 0; | 1194 | return 0; |
1198 | } | 1195 | } |
@@ -1208,10 +1205,8 @@ void em28xx_unregister_extension(struct em28xx_ops *ops) | |||
1208 | ops->fini(dev); | 1205 | ops->fini(dev); |
1209 | } | 1206 | } |
1210 | 1207 | ||
1211 | mutex_lock(&em28xx_extension_devlist_lock); | ||
1212 | printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); | 1208 | printk(KERN_INFO "Em28xx: Removed (%s) extension\n", ops->name); |
1213 | list_del(&ops->next); | 1209 | list_del(&ops->next); |
1214 | mutex_unlock(&em28xx_extension_devlist_lock); | ||
1215 | mutex_unlock(&em28xx_devlist_mutex); | 1210 | mutex_unlock(&em28xx_devlist_mutex); |
1216 | } | 1211 | } |
1217 | EXPORT_SYMBOL(em28xx_unregister_extension); | 1212 | EXPORT_SYMBOL(em28xx_unregister_extension); |
@@ -1220,26 +1215,26 @@ void em28xx_init_extension(struct em28xx *dev) | |||
1220 | { | 1215 | { |
1221 | struct em28xx_ops *ops = NULL; | 1216 | struct em28xx_ops *ops = NULL; |
1222 | 1217 | ||
1223 | mutex_lock(&em28xx_extension_devlist_lock); | 1218 | mutex_lock(&em28xx_devlist_mutex); |
1224 | if (!list_empty(&em28xx_extension_devlist)) { | 1219 | if (!list_empty(&em28xx_extension_devlist)) { |
1225 | list_for_each_entry(ops, &em28xx_extension_devlist, next) { | 1220 | list_for_each_entry(ops, &em28xx_extension_devlist, next) { |
1226 | if (ops->init) | 1221 | if (ops->init) |
1227 | ops->init(dev); | 1222 | ops->init(dev); |
1228 | } | 1223 | } |
1229 | } | 1224 | } |
1230 | mutex_unlock(&em28xx_extension_devlist_lock); | 1225 | mutex_unlock(&em28xx_devlist_mutex); |
1231 | } | 1226 | } |
1232 | 1227 | ||
1233 | void em28xx_close_extension(struct em28xx *dev) | 1228 | void em28xx_close_extension(struct em28xx *dev) |
1234 | { | 1229 | { |
1235 | struct em28xx_ops *ops = NULL; | 1230 | struct em28xx_ops *ops = NULL; |
1236 | 1231 | ||
1237 | mutex_lock(&em28xx_extension_devlist_lock); | 1232 | mutex_lock(&em28xx_devlist_mutex); |
1238 | if (!list_empty(&em28xx_extension_devlist)) { | 1233 | if (!list_empty(&em28xx_extension_devlist)) { |
1239 | list_for_each_entry(ops, &em28xx_extension_devlist, next) { | 1234 | list_for_each_entry(ops, &em28xx_extension_devlist, next) { |
1240 | if (ops->fini) | 1235 | if (ops->fini) |
1241 | ops->fini(dev); | 1236 | ops->fini(dev); |
1242 | } | 1237 | } |
1243 | } | 1238 | } |
1244 | mutex_unlock(&em28xx_extension_devlist_lock); | 1239 | mutex_unlock(&em28xx_devlist_mutex); |
1245 | } | 1240 | } |
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c index e7b3d5371558..cf1d8c3655fc 100644 --- a/drivers/media/video/em28xx/em28xx-dvb.c +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
@@ -467,6 +467,7 @@ static int dvb_init(struct em28xx *dev) | |||
467 | } | 467 | } |
468 | dev->dvb = dvb; | 468 | dev->dvb = dvb; |
469 | 469 | ||
470 | mutex_lock(&dev->lock); | ||
470 | em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); | 471 | em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); |
471 | /* init frontend */ | 472 | /* init frontend */ |
472 | switch (dev->model) { | 473 | switch (dev->model) { |
@@ -590,15 +591,16 @@ static int dvb_init(struct em28xx *dev) | |||
590 | if (result < 0) | 591 | if (result < 0) |
591 | goto out_free; | 592 | goto out_free; |
592 | 593 | ||
593 | em28xx_set_mode(dev, EM28XX_SUSPEND); | ||
594 | em28xx_info("Successfully loaded em28xx-dvb\n"); | 594 | em28xx_info("Successfully loaded em28xx-dvb\n"); |
595 | return 0; | 595 | ret: |
596 | em28xx_set_mode(dev, EM28XX_SUSPEND); | ||
597 | mutex_unlock(&dev->lock); | ||
598 | return result; | ||
596 | 599 | ||
597 | out_free: | 600 | out_free: |
598 | em28xx_set_mode(dev, EM28XX_SUSPEND); | ||
599 | kfree(dvb); | 601 | kfree(dvb); |
600 | dev->dvb = NULL; | 602 | dev->dvb = NULL; |
601 | return result; | 603 | goto ret; |
602 | } | 604 | } |
603 | 605 | ||
604 | static int dvb_fini(struct em28xx *dev) | 606 | static int dvb_fini(struct em28xx *dev) |