aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/usb/gspca/zc3xx.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-09-09 05:30:02 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-13 16:42:17 -0400
commit345321dc9c52b774f42c934339f9b3e2f0a39395 (patch)
treea86e8fde0d50634c467c0c9d75b37776037e27d7 /drivers/media/usb/gspca/zc3xx.c
parent8c96f0a207bedb6f06089fde9adc7abe8136a087 (diff)
[media] gspca: Don't set gspca_dev->dev to NULL before stop0
In commit a3d6e8cc0e6ddc8b3cfdeb3c979f07ed1aa528b3 gspca_dev->dev is set to NULL on disconnect, before calling stop0. The plan was to get rid of gspca_dev->present and instead simply check for gspca_dev->dev everywhere where we were checking for present. This should be race free since all users of gspca_dev->dev hold the usb_lock, or so I thought. But I was wrong, drivers which use a work-queue + synchronous bulk transfers to get the video data don't hold the usb_lock while doing so, their stop0 callbacks stop the workqueue, so they won't be using gspca_dev->dev anymore after the stop0 call, but they might be dereferincing it before, so we should not set gspca_dev->dev to NULL on disconnect before calling stop0. This also means that the workqueue functions in these drivers cannot use gspca_dev->dev to check if they need to stop because of disconnection, so we will need to keep gspca_dev->present around, and set that to 0 on disconnect, before calling stop0. Unfortunately as part of the plan to remove gspca_dev->present, these workqueues where already moved over to checking for gspca_dev->dev instead of gspca_dev->present as part of commit 254902b01d2acc6aced99ec17caa4c6cd890cdea, so this patch also reverts those parts of that commit. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/gspca/zc3xx.c')
-rw-r--r--drivers/media/usb/gspca/zc3xx.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index f0bacee33ef9..234d9eaa8eea 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -5950,7 +5950,7 @@ static void transfer_update(struct work_struct *work)
5950 if (gspca_dev->frozen) 5950 if (gspca_dev->frozen)
5951 goto err; 5951 goto err;
5952#endif 5952#endif
5953 if (!gspca_dev->dev || !gspca_dev->streaming) 5953 if (!gspca_dev->present || !gspca_dev->streaming)
5954 goto err; 5954 goto err;
5955 5955
5956 /* Bit 0 of register 11 indicates FIFO overflow */ 5956 /* Bit 0 of register 11 indicates FIFO overflow */
@@ -6842,7 +6842,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
6842 mutex_lock(&gspca_dev->usb_lock); 6842 mutex_lock(&gspca_dev->usb_lock);
6843 sd->work_thread = NULL; 6843 sd->work_thread = NULL;
6844 } 6844 }
6845 if (!gspca_dev->dev) 6845 if (!gspca_dev->present)
6846 return; 6846 return;
6847 send_unknown(gspca_dev, sd->sensor); 6847 send_unknown(gspca_dev, sd->sensor);
6848} 6848}