[media] pwc: Get rid of error_status and unplugged variables
Having 2 ways of tracking disconnection is too much, remove both and
instead simply set pdev->udev to NULL on disconnect. Also check for
pdev->udev being NULL in all possible entry paths.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c
index cda3883..8bd0a68 100644
--- a/drivers/media/video/pwc/pwc-v4l.c
+++ b/drivers/media/video/pwc/pwc-v4l.c
@@ -288,6 +288,9 @@
{
int ret, fps, snapshot, compression, pixelformat;
+ if (!pdev->udev)
+ return -ENODEV;
+
ret = pwc_vidioc_try_fmt(pdev, f);
if (ret<0)
return ret;
@@ -346,6 +349,9 @@
struct video_device *vdev = video_devdata(file);
struct pwc_device *pdev = video_drvdata(file);
+ if (!pdev->udev)
+ return -ENODEV;
+
strcpy(cap->driver, PWC_NAME);
strlcpy(cap->card, vdev->name, sizeof(cap->card));
usb_make_path(pdev->udev, cap->bus_info, sizeof(cap->bus_info));
@@ -414,6 +420,9 @@
struct pwc_device *pdev = video_drvdata(file);
int ret;
+ if (!pdev->udev)
+ return -ENODEV;
+
switch (c->id) {
case V4L2_CID_BRIGHTNESS:
c->value = pwc_get_brightness(pdev);
@@ -517,6 +526,9 @@
struct pwc_device *pdev = video_drvdata(file);
int ret;
+ if (!pdev->udev)
+ return -ENODEV;
+
switch (c->id) {
case V4L2_CID_BRIGHTNESS:
c->value <<= 9;
@@ -692,6 +704,9 @@
{
struct pwc_device *pdev = video_drvdata(file);
+ if (!pdev->udev)
+ return -ENODEV;
+
return vb2_qbuf(&pdev->vb_queue, buf);
}
@@ -699,6 +714,9 @@
{
struct pwc_device *pdev = video_drvdata(file);
+ if (!pdev->udev)
+ return -ENODEV;
+
return vb2_dqbuf(&pdev->vb_queue, buf, file->f_flags & O_NONBLOCK);
}
@@ -706,6 +724,9 @@
{
struct pwc_device *pdev = video_drvdata(file);
+ if (!pdev->udev)
+ return -ENODEV;
+
return vb2_streamon(&pdev->vb_queue, i);
}
@@ -713,6 +734,9 @@
{
struct pwc_device *pdev = video_drvdata(file);
+ if (!pdev->udev)
+ return -ENODEV;
+
return vb2_streamoff(&pdev->vb_queue, i);
}