All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: cx231xx: fix unregister logic
@ 2019-09-10 20:29 Mauro Carvalho Chehab
  0 siblings, 0 replies; only message in thread
From: Mauro Carvalho Chehab @ 2019-09-10 20:29 UTC (permalink / raw)
  To: Linux Media Mailing List
  Cc: Mauro Carvalho Chehab, Mauro Carvalho Chehab, Hans Verkuil,
	Sakari Ailus, Colin Ian King, Greg Kroah-Hartman,
	Geert Uytterhoeven, Thomas Gleixner

Right now, dev->users is not been decremented for VBI nodes,
causing unregister to fail. Fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
---
 drivers/media/usb/cx231xx/cx231xx-video.c | 25 +++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/media/usb/cx231xx/cx231xx-video.c b/drivers/media/usb/cx231xx/cx231xx-video.c
index 6d2f4da3a3fa..69abafaebbf3 100644
--- a/drivers/media/usb/cx231xx/cx231xx-video.c
+++ b/drivers/media/usb/cx231xx/cx231xx-video.c
@@ -1557,6 +1557,18 @@ static int cx231xx_close(struct file *filp)
 
 	_vb2_fop_release(filp, NULL);
 
+	if (--dev->users == 0) {
+		/* Save some power by putting tuner to sleep */
+		call_all(dev, tuner, standby);
+
+		/* do this before setting alternate! */
+		if (dev->USE_ISO)
+			cx231xx_uninit_isoc(dev);
+		else
+			cx231xx_uninit_bulk(dev);
+		cx231xx_set_mode(dev, CX231XX_SUSPEND);
+	}
+
 	/*
 	 * To workaround error number=-71 on EP0 for VideoGrabber,
 	 *	 need exclude following.
@@ -1577,20 +1589,11 @@ static int cx231xx_close(struct file *filp)
 		return 0;
 	}
 
-	if (--dev->users == 0) {
-		/* Save some power by putting tuner to sleep */
-		call_all(dev, tuner, standby);
-
-		/* do this before setting alternate! */
-		if (dev->USE_ISO)
-			cx231xx_uninit_isoc(dev);
-		else
-			cx231xx_uninit_bulk(dev);
-		cx231xx_set_mode(dev, CX231XX_SUSPEND);
-
+	if (dev->users == 0) {
 		/* set alternate 0 */
 		cx231xx_set_alt_setting(dev, INDEX_VIDEO, 0);
 	}
+
 	wake_up_interruptible(&dev->open);
 	return 0;
 }
-- 
2.21.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-10 20:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-10 20:29 [PATCH] media: cx231xx: fix unregister logic Mauro Carvalho Chehab

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.