From: Hans de Goede <hdegoede@redhat.com>
To: Ricardo Ribalda <ribalda@chromium.org>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Guennadi Liakhovetski <guennadi.liakhovetski@intel.com>
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Subject: Re: [PATCH v4 1/5] media: uvcvideo: Keep streaming state in the file handle
Date: Mon, 3 Mar 2025 15:07:22 +0100 [thread overview]
Message-ID: <3b64dbbb-d5b4-4813-9dce-aa6e361133cf@redhat.com> (raw)
In-Reply-To: <20250226-uvc-granpower-ng-v4-1-3ec9be906048@chromium.org>
Hi,
On 26-Feb-25 15:23, Ricardo Ribalda wrote:
> Add a variable in the file handle state to figure out if a camera is in
> the streaming state or not. This variable will be used in the future for
> power management policies.
>
> Now that we are at it, make use of guards to simplify the code.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Thanks, patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/media/usb/uvc/uvc_v4l2.c | 18 +++++++++++++-----
> drivers/media/usb/uvc/uvcvideo.h | 1 +
> 2 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 93c6cdb23881..f9cd6db759c5 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -835,11 +835,18 @@ static int uvc_ioctl_streamon(struct file *file, void *fh,
> if (!uvc_has_privileges(handle))
> return -EBUSY;
>
> - mutex_lock(&stream->mutex);
> + guard(mutex)(&stream->mutex);
> +
> + if (handle->is_streaming)
> + return 0;
> +
> ret = uvc_queue_streamon(&stream->queue, type);
> - mutex_unlock(&stream->mutex);
> + if (ret)
> + return ret;
>
> - return ret;
> + handle->is_streaming = true;
> +
> + return 0;
> }
>
> static int uvc_ioctl_streamoff(struct file *file, void *fh,
> @@ -851,9 +858,10 @@ static int uvc_ioctl_streamoff(struct file *file, void *fh,
> if (!uvc_has_privileges(handle))
> return -EBUSY;
>
> - mutex_lock(&stream->mutex);
> + guard(mutex)(&stream->mutex);
> +
> uvc_queue_streamoff(&stream->queue, type);
> - mutex_unlock(&stream->mutex);
> + handle->is_streaming = false;
>
> return 0;
> }
> diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
> index 5e388f05f3fc..bc87e1f2c669 100644
> --- a/drivers/media/usb/uvc/uvcvideo.h
> +++ b/drivers/media/usb/uvc/uvcvideo.h
> @@ -618,6 +618,7 @@ struct uvc_fh {
> struct uvc_streaming *stream;
> enum uvc_handle_state state;
> unsigned int pending_async_ctrls;
> + bool is_streaming;
> };
>
> struct uvc_driver {
>
next prev parent reply other threads:[~2025-03-03 14:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 14:23 [PATCH v4 0/5] media: uvcvideo: Implement Granular Power Saving Ricardo Ribalda
2025-02-26 14:23 ` [PATCH v4 1/5] media: uvcvideo: Keep streaming state in the file handle Ricardo Ribalda
2025-03-03 14:07 ` Hans de Goede [this message]
2025-02-26 14:23 ` [PATCH v4 2/5] media: uvcvideo: Create uvc_pm_(get|put) functions Ricardo Ribalda
2025-03-03 14:26 ` Hans de Goede
2025-02-26 14:23 ` [PATCH v4 3/5] media: uvcvideo: Increase/decrease the PM counter per IOCTL Ricardo Ribalda
2025-03-03 14:34 ` Hans de Goede
2025-02-26 14:23 ` [PATCH v4 4/5] media: uvcvideo: Make power management granular Ricardo Ribalda
2025-03-03 14:37 ` Hans de Goede
2025-02-26 14:23 ` [PATCH v4 5/5] media: uvcvideo: Do not turn on the camera for some ioctls Ricardo Ribalda
2025-03-03 14:42 ` Hans de Goede
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=3b64dbbb-d5b4-4813-9dce-aa6e361133cf@redhat.com \
--to=hdegoede@redhat.com \
--cc=guennadi.liakhovetski@intel.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=mchehab@kernel.org \
--cc=ribalda@chromium.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®