aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-09-09 06:30:02 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-13 16:52:58 -0400
commit844db450e6e2cf710752af1a019a877af390b541 (patch)
tree0c43bce1f503d14cabdad012ff00b6a9c6ad41b8
parentff8f25d326da5e7cf6216f368116744341fceb12 (diff)
[media] gspca: Update / fix various comments wrt workqueue usb_lock usage
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/usb/gspca/finepix.c9
-rw-r--r--drivers/media/usb/gspca/jl2005bcd.c12
-rw-r--r--drivers/media/usb/gspca/sn9c20x.c2
-rw-r--r--drivers/media/usb/gspca/sonixj.c2
-rw-r--r--drivers/media/usb/gspca/sq905.c11
-rw-r--r--drivers/media/usb/gspca/sq905c.c12
-rw-r--r--drivers/media/usb/gspca/vicam.c13
-rw-r--r--drivers/media/usb/gspca/zc3xx.c4
8 files changed, 36 insertions, 29 deletions
diff --git a/drivers/media/usb/gspca/finepix.c b/drivers/media/usb/gspca/finepix.c
index fb68a2934255..52bdb569760b 100644
--- a/drivers/media/usb/gspca/finepix.c
+++ b/drivers/media/usb/gspca/finepix.c
@@ -77,7 +77,14 @@ static int command(struct gspca_dev *gspca_dev,
77 12, FPIX_TIMEOUT); 77 12, FPIX_TIMEOUT);
78} 78}
79 79
80/* workqueue */ 80/*
81 * This function is called as a workqueue function and runs whenever the camera
82 * is streaming data. Because it is a workqueue function it is allowed to sleep
83 * so we can use synchronous USB calls. To avoid possible collisions with other
84 * threads attempting to use gspca_dev->usb_buf we take the usb_lock when
85 * performing USB operations using it. In practice we don't really need this
86 * as the camera doesn't provide any controls.
87 */
81static void dostream(struct work_struct *work) 88static void dostream(struct work_struct *work)
82{ 89{
83 struct usb_fpix *dev = container_of(work, struct usb_fpix, work_struct); 90 struct usb_fpix *dev = container_of(work, struct usb_fpix, work_struct);
diff --git a/drivers/media/usb/gspca/jl2005bcd.c b/drivers/media/usb/gspca/jl2005bcd.c
index c4b4a9598db4..62ba80d9b998 100644
--- a/drivers/media/usb/gspca/jl2005bcd.c
+++ b/drivers/media/usb/gspca/jl2005bcd.c
@@ -306,15 +306,13 @@ static int jl2005c_stop(struct gspca_dev *gspca_dev)
306 return retval; 306 return retval;
307} 307}
308 308
309/* This function is called as a workqueue function and runs whenever the camera 309/*
310 * This function is called as a workqueue function and runs whenever the camera
310 * is streaming data. Because it is a workqueue function it is allowed to sleep 311 * is streaming data. Because it is a workqueue function it is allowed to sleep
311 * so we can use synchronous USB calls. To avoid possible collisions with other 312 * so we can use synchronous USB calls. To avoid possible collisions with other
312 * threads attempting to use the camera's USB interface the gspca usb_lock is 313 * threads attempting to use gspca_dev->usb_buf we take the usb_lock when
313 * used when performing the one USB control operation inside the workqueue, 314 * performing USB operations using it. In practice we don't really need this
314 * which tells the camera to close the stream. In practice the only thing 315 * as the camera doesn't provide any controls.
315 * which needs to be protected against is the usb_set_interface call that
316 * gspca makes during stream_off. Otherwise the camera doesn't provide any
317 * controls that the user could try to change.
318 */ 316 */
319static void jl2005c_dostream(struct work_struct *work) 317static void jl2005c_dostream(struct work_struct *work)
320{ 318{
diff --git a/drivers/media/usb/gspca/sn9c20x.c b/drivers/media/usb/gspca/sn9c20x.c
index b9c6f17eabb2..41f769fe340c 100644
--- a/drivers/media/usb/gspca/sn9c20x.c
+++ b/drivers/media/usb/gspca/sn9c20x.c
@@ -2197,8 +2197,10 @@ static void qual_upd(struct work_struct *work)
2197 struct gspca_dev *gspca_dev = &sd->gspca_dev; 2197 struct gspca_dev *gspca_dev = &sd->gspca_dev;
2198 s32 qual = v4l2_ctrl_g_ctrl(sd->jpegqual); 2198 s32 qual = v4l2_ctrl_g_ctrl(sd->jpegqual);
2199 2199
2200 /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */
2200 mutex_lock(&gspca_dev->usb_lock); 2201 mutex_lock(&gspca_dev->usb_lock);
2201 PDEBUG(D_STREAM, "qual_upd %d%%", qual); 2202 PDEBUG(D_STREAM, "qual_upd %d%%", qual);
2203 gspca_dev->usb_err = 0;
2202 set_quality(gspca_dev, qual); 2204 set_quality(gspca_dev, qual);
2203 mutex_unlock(&gspca_dev->usb_lock); 2205 mutex_unlock(&gspca_dev->usb_lock);
2204} 2206}
diff --git a/drivers/media/usb/gspca/sonixj.c b/drivers/media/usb/gspca/sonixj.c
index 150b2df40f7f..5a86047b846f 100644
--- a/drivers/media/usb/gspca/sonixj.c
+++ b/drivers/media/usb/gspca/sonixj.c
@@ -2380,8 +2380,10 @@ static void qual_upd(struct work_struct *work)
2380 struct sd *sd = container_of(work, struct sd, work); 2380 struct sd *sd = container_of(work, struct sd, work);
2381 struct gspca_dev *gspca_dev = &sd->gspca_dev; 2381 struct gspca_dev *gspca_dev = &sd->gspca_dev;
2382 2382
2383 /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */
2383 mutex_lock(&gspca_dev->usb_lock); 2384 mutex_lock(&gspca_dev->usb_lock);
2384 PDEBUG(D_STREAM, "qual_upd %d%%", sd->quality); 2385 PDEBUG(D_STREAM, "qual_upd %d%%", sd->quality);
2386 gspca_dev->usb_err = 0;
2385 setjpegqual(gspca_dev); 2387 setjpegqual(gspca_dev);
2386 mutex_unlock(&gspca_dev->usb_lock); 2388 mutex_unlock(&gspca_dev->usb_lock);
2387} 2389}
diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
index 2e05acab304c..1d99f10a3e19 100644
--- a/drivers/media/usb/gspca/sq905.c
+++ b/drivers/media/usb/gspca/sq905.c
@@ -201,14 +201,13 @@ sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock)
201 return 0; 201 return 0;
202} 202}
203 203
204/* This function is called as a workqueue function and runs whenever the camera 204/*
205 * This function is called as a workqueue function and runs whenever the camera
205 * is streaming data. Because it is a workqueue function it is allowed to sleep 206 * is streaming data. Because it is a workqueue function it is allowed to sleep
206 * so we can use synchronous USB calls. To avoid possible collisions with other 207 * so we can use synchronous USB calls. To avoid possible collisions with other
207 * threads attempting to use the camera's USB interface we take the gspca 208 * threads attempting to use gspca_dev->usb_buf we take the usb_lock when
208 * usb_lock when performing USB operations. In practice the only thing we need 209 * performing USB operations using it. In practice we don't really need this
209 * to protect against is the usb_set_interface call that gspca makes during 210 * as the camera doesn't provide any controls.
210 * stream_off as the camera doesn't provide any controls that the user could try
211 * to change.
212 */ 211 */
213static void sq905_dostream(struct work_struct *work) 212static void sq905_dostream(struct work_struct *work)
214{ 213{
diff --git a/drivers/media/usb/gspca/sq905c.c b/drivers/media/usb/gspca/sq905c.c
index 784620c102b1..410cdcbb55d4 100644
--- a/drivers/media/usb/gspca/sq905c.c
+++ b/drivers/media/usb/gspca/sq905c.c
@@ -123,15 +123,13 @@ static int sq905c_read(struct gspca_dev *gspca_dev, u16 command, u16 index,
123 return 0; 123 return 0;
124} 124}
125 125
126/* This function is called as a workqueue function and runs whenever the camera 126/*
127 * This function is called as a workqueue function and runs whenever the camera
127 * is streaming data. Because it is a workqueue function it is allowed to sleep 128 * is streaming data. Because it is a workqueue function it is allowed to sleep
128 * so we can use synchronous USB calls. To avoid possible collisions with other 129 * so we can use synchronous USB calls. To avoid possible collisions with other
129 * threads attempting to use the camera's USB interface the gspca usb_lock is 130 * threads attempting to use gspca_dev->usb_buf we take the usb_lock when
130 * used when performing the one USB control operation inside the workqueue, 131 * performing USB operations using it. In practice we don't really need this
131 * which tells the camera to close the stream. In practice the only thing 132 * as the camera doesn't provide any controls.
132 * which needs to be protected against is the usb_set_interface call that
133 * gspca makes during stream_off. Otherwise the camera doesn't provide any
134 * controls that the user could try to change.
135 */ 133 */
136static void sq905c_dostream(struct work_struct *work) 134static void sq905c_dostream(struct work_struct *work)
137{ 135{
diff --git a/drivers/media/usb/gspca/vicam.c b/drivers/media/usb/gspca/vicam.c
index 57d88f70c399..d6890bc37198 100644
--- a/drivers/media/usb/gspca/vicam.c
+++ b/drivers/media/usb/gspca/vicam.c
@@ -110,7 +110,7 @@ static int vicam_set_camera_power(struct gspca_dev *gspca_dev, int state)
110} 110}
111 111
112/* 112/*
113 * request and read a block of data - see warning on vicam_command. 113 * request and read a block of data
114 */ 114 */
115static int vicam_read_frame(struct gspca_dev *gspca_dev, u8 *data, int size) 115static int vicam_read_frame(struct gspca_dev *gspca_dev, u8 *data, int size)
116{ 116{
@@ -170,14 +170,13 @@ static int vicam_read_frame(struct gspca_dev *gspca_dev, u8 *data, int size)
170 return 0; 170 return 0;
171} 171}
172 172
173/* This function is called as a workqueue function and runs whenever the camera 173/*
174 * This function is called as a workqueue function and runs whenever the camera
174 * is streaming data. Because it is a workqueue function it is allowed to sleep 175 * is streaming data. Because it is a workqueue function it is allowed to sleep
175 * so we can use synchronous USB calls. To avoid possible collisions with other 176 * so we can use synchronous USB calls. To avoid possible collisions with other
176 * threads attempting to use the camera's USB interface we take the gspca 177 * threads attempting to use gspca_dev->usb_buf we take the usb_lock when
177 * usb_lock when performing USB operations. In practice the only thing we need 178 * performing USB operations using it. In practice we don't really need this
178 * to protect against is the usb_set_interface call that gspca makes during 179 * as the cameras controls are only written from the workqueue.
179 * stream_off as the camera doesn't provide any controls that the user could try
180 * to change.
181 */ 180 */
182static void vicam_dostream(struct work_struct *work) 181static void vicam_dostream(struct work_struct *work)
183{ 182{
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 234d9eaa8eea..c47ba14c7619 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -5945,6 +5945,7 @@ static void transfer_update(struct work_struct *work)
5945 for (;;) { 5945 for (;;) {
5946 msleep(100); 5946 msleep(100);
5947 5947
5948 /* To protect gspca_dev->usb_buf and gspca_dev->usb_err */
5948 mutex_lock(&gspca_dev->usb_lock); 5949 mutex_lock(&gspca_dev->usb_lock);
5949#ifdef CONFIG_PM 5950#ifdef CONFIG_PM
5950 if (gspca_dev->frozen) 5951 if (gspca_dev->frozen)
@@ -6831,7 +6832,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
6831 return 0; 6832 return 0;
6832} 6833}
6833 6834
6834/* called on streamoff with alt 0 and on disconnect */ 6835/* called on streamoff with alt==0 and on disconnect */
6836/* the usb_lock is held at entry - restore on exit */
6835static void sd_stop0(struct gspca_dev *gspca_dev) 6837static void sd_stop0(struct gspca_dev *gspca_dev)
6836{ 6838{
6837 struct sd *sd = (struct sd *) gspca_dev; 6839 struct sd *sd = (struct sd *) gspca_dev;