mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Chen Changcheng <chenchangcheng@kylinos.cn>
Cc: Hans de Goede <hansg@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: uvcvideo: Fail probe when no video device is registered
Date: Wed, 4 Nov 2026 08:04:40 +0200	[thread overview]
Message-ID: <20261104060440.GD3619815@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20261104022146.42954-1-chenchangcheng@kylinos.cn>

On Wed, Nov 04, 2026 at 10:21:46AM +0800, Chen Changcheng wrote:
> When a UVC device is unbound while userspace still holds the video
> device open, the VS interface claims are released only after the last
> file descriptor is closed.  Rebinding before that fails to claim the VS
> interfaces, leaving the VC interface bound without a usable video
> device:
> 
>   [ 3229.189556] uvcvideo: Probing generic UVC device 1
>   [ 3229.190496] uvcvideo: device 2 interface 1 is already claimed
>   ...
>   [ 3229.193758] uvcvideo: Scanning UVC chain: OT 4 <- XU 3 <- PU 2 <- IT 1
>   [ 3229.193766] uvcvideo: Found a valid video chain (1 -> 4).
>   [ 3229.193771] usb 9-1: No streaming interface found for terminal 4.

Please provide the USB descriptors for your device.

> Check after registering all video chains that at least one video device
> was registered, and fail the probe with -ENODEV otherwise.
> 
> Devices with no usable streaming interface at all will now also stay
> unbound instead of being bound without any video device.
> 
> Signed-off-by: Chen Changcheng <chenchangcheng@kylinos.cn>
> ---
>  drivers/media/usb/uvc/uvc_driver.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
> index e289cc71ba98..0943db4eae07 100644
> --- a/drivers/media/usb/uvc/uvc_driver.c
> +++ b/drivers/media/usb/uvc/uvc_driver.c
> @@ -2156,6 +2156,19 @@ static int uvc_register_terms(struct uvc_device *dev,
>  	return 0;
>  }
>  
> +static int uvc_has_video_node(struct uvc_device *dev)
> +{
> +	struct uvc_streaming *stream;
> +
> +	list_for_each_entry(stream, &dev->streams, list)
> +		if (video_is_registered(&stream->queue.vdev))
> +			return 0;
> +
> +	dev_info(&dev->intf->dev,
> +		 "No usable streaming interface found\n");
> +	return -ENODEV;
> +}
> +
>  static int uvc_register_chains(struct uvc_device *dev)
>  {
>  	struct uvc_video_chain *chain;
> @@ -2174,7 +2187,7 @@ static int uvc_register_chains(struct uvc_device *dev)
>  #endif
>  	}
>  
> -	return 0;
> +	return uvc_has_video_node(dev);
>  }
>  
>  /* ------------------------------------------------------------------------
> 
> base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2026-11-04  6:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04  2:21 Chen Changcheng
2026-11-04  6:04 ` Laurent Pinchart [this message]
2026-11-04  7:21   ` Chen Changcheng
2026-11-04  7:41 ` Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261104060440.GD3619815@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=chenchangcheng@kylinos.cn \
    --cc=hansg@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®