aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx88/cx88-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/cx88/cx88-core.c')
-rw-r--r--drivers/media/video/cx88/cx88-core.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index 194446f28c55..8d6d6a6cf785 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -32,6 +32,7 @@
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/videodev2.h> 34#include <linux/videodev2.h>
35#include <linux/mutex.h>
35 36
36#include "cx88.h" 37#include "cx88.h"
37#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
@@ -75,7 +76,7 @@ MODULE_PARM_DESC(nocomb,"disable comb filter");
75 76
76static unsigned int cx88_devcount; 77static unsigned int cx88_devcount;
77static LIST_HEAD(cx88_devlist); 78static LIST_HEAD(cx88_devlist);
78static DECLARE_MUTEX(devlist); 79static DEFINE_MUTEX(devlist);
79 80
80#define NO_SYNC_LINE (-1U) 81#define NO_SYNC_LINE (-1U)
81 82
@@ -1036,7 +1037,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1036 struct list_head *item; 1037 struct list_head *item;
1037 int i; 1038 int i;
1038 1039
1039 down(&devlist); 1040 mutex_lock(&devlist);
1040 list_for_each(item,&cx88_devlist) { 1041 list_for_each(item,&cx88_devlist) {
1041 core = list_entry(item, struct cx88_core, devlist); 1042 core = list_entry(item, struct cx88_core, devlist);
1042 if (pci->bus->number != core->pci_bus) 1043 if (pci->bus->number != core->pci_bus)
@@ -1047,7 +1048,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1047 if (0 != get_ressources(core,pci)) 1048 if (0 != get_ressources(core,pci))
1048 goto fail_unlock; 1049 goto fail_unlock;
1049 atomic_inc(&core->refcount); 1050 atomic_inc(&core->refcount);
1050 up(&devlist); 1051 mutex_unlock(&devlist);
1051 return core; 1052 return core;
1052 } 1053 }
1053 core = kzalloc(sizeof(*core),GFP_KERNEL); 1054 core = kzalloc(sizeof(*core),GFP_KERNEL);
@@ -1122,13 +1123,13 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
1122 cx88_card_setup(core); 1123 cx88_card_setup(core);
1123 cx88_ir_init(core,pci); 1124 cx88_ir_init(core,pci);
1124 1125
1125 up(&devlist); 1126 mutex_unlock(&devlist);
1126 return core; 1127 return core;
1127 1128
1128fail_free: 1129fail_free:
1129 kfree(core); 1130 kfree(core);
1130fail_unlock: 1131fail_unlock:
1131 up(&devlist); 1132 mutex_unlock(&devlist);
1132 return NULL; 1133 return NULL;
1133} 1134}
1134 1135
@@ -1140,14 +1141,14 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
1140 if (!atomic_dec_and_test(&core->refcount)) 1141 if (!atomic_dec_and_test(&core->refcount))
1141 return; 1142 return;
1142 1143
1143 down(&devlist); 1144 mutex_lock(&devlist);
1144 cx88_ir_fini(core); 1145 cx88_ir_fini(core);
1145 if (0 == core->i2c_rc) 1146 if (0 == core->i2c_rc)
1146 i2c_bit_del_bus(&core->i2c_adap); 1147 i2c_bit_del_bus(&core->i2c_adap);
1147 list_del(&core->devlist); 1148 list_del(&core->devlist);
1148 iounmap(core->lmmio); 1149 iounmap(core->lmmio);
1149 cx88_devcount--; 1150 cx88_devcount--;
1150 up(&devlist); 1151 mutex_unlock(&devlist);
1151 kfree(core); 1152 kfree(core);
1152} 1153}
1153 1154