From: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: Hans Verkuil <hverkuil@xs4all.nl>,
linux-media@vger.kernel.org,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv13 05/28] media-request: add media_request_object_find
Date: Mon, 7 May 2018 14:05:13 -0300 [thread overview]
Message-ID: <20180507140513.5d71664b@vento.lan> (raw)
In-Reply-To: <20180504124307.sddriagirmig4yf4@valkosipuli.retiisi.org.uk>
Em Fri, 4 May 2018 15:43:07 +0300
Sakari Ailus <sakari.ailus@iki.fi> escreveu:
> On Thu, May 03, 2018 at 04:52:55PM +0200, Hans Verkuil wrote:
> > From: Hans Verkuil <hans.verkuil@cisco.com>
> >
> > Add media_request_object_find to find a request object inside a
> > request based on ops and/or priv values.
> >
> > Objects of the same type (vb2 buffer, control handler) will have
> > the same ops value. And objects that refer to the same 'parent'
> > object (e.g. the v4l2_ctrl_handler that has the current driver
> > state) will have the same priv value.
> >
> > The caller has to call media_request_object_put() for the returned
> > object since this function increments the refcount.
> >
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > ---
> > drivers/media/media-request.c | 25 +++++++++++++++++++++++++
> > include/media/media-request.h | 24 ++++++++++++++++++++++++
> > 2 files changed, 49 insertions(+)
> >
> > diff --git a/drivers/media/media-request.c b/drivers/media/media-request.c
> > index edc1c3af1959..c7e11e816e27 100644
> > --- a/drivers/media/media-request.c
> > +++ b/drivers/media/media-request.c
> > @@ -322,6 +322,31 @@ static void media_request_object_release(struct kref *kref)
> > obj->ops->release(obj);
> > }
> >
> > +struct media_request_object *
> > +media_request_object_find(struct media_request *req,
> > + const struct media_request_object_ops *ops,
> > + void *priv)
> > +{
> > + struct media_request_object *obj;
> > + struct media_request_object *found = NULL;
> > + unsigned long flags;
> > +
> > + if (WARN_ON(!ops || !priv))
> > + return NULL;
> > +
> > + spin_lock_irqsave(&req->lock, flags);
> > + list_for_each_entry(obj, &req->objects, list) {
> > + if (obj->ops == ops && obj->priv == priv) {
> > + media_request_object_get(obj);
> > + found = obj;
> > + break;
> > + }
> > + }
> > + spin_unlock_irqrestore(&req->lock, flags);
> > + return found;
> > +}
> > +EXPORT_SYMBOL_GPL(media_request_object_find);
> > +
> > void media_request_object_put(struct media_request_object *obj)
> > {
> > kref_put(&obj->kref, media_request_object_release);
> > diff --git a/include/media/media-request.h b/include/media/media-request.h
> > index 997e096d7128..5367b4a2f91c 100644
> > --- a/include/media/media-request.h
> > +++ b/include/media/media-request.h
> > @@ -196,6 +196,22 @@ static inline void media_request_object_get(struct media_request_object *obj)
> > */
> > void media_request_object_put(struct media_request_object *obj);
> >
> > +/**
> > + * media_request_object_find - Find an object in a request
> > + *
> > + * @ops: Find an object with this ops value
> > + * @priv: Find an object with this priv value
> > + *
> > + * Both @ops and @priv must be non-NULL.
> > + *
> > + * Returns NULL if not found or the object pointer. The caller must
>
> I'd describe the successful case first. I.e. "Returns the object pointer or
> NULL it not found".
It would be good to also tell that this routine internally uses the
spin lock.
>
> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
>
> > + * call media_request_object_put() once it finished using the object.
> > + */
> > +struct media_request_object *
> > +media_request_object_find(struct media_request *req,
> > + const struct media_request_object_ops *ops,
> > + void *priv);
> > +
> > /**
> > * media_request_object_init - Initialise a media request object
> > *
> > @@ -241,6 +257,14 @@ static inline void media_request_object_put(struct media_request_object *obj)
> > {
> > }
> >
> > +static inline struct media_request_object *
> > +media_request_object_find(struct media_request *req,
> > + const struct media_request_object_ops *ops,
> > + void *priv)
> > +{
> > + return NULL;
> > +}
> > +
> > static inline void media_request_object_init(struct media_request_object *obj)
> > {
> > obj->ops = NULL;
>
Thanks,
Mauro
next prev parent reply other threads:[~2018-05-07 17:05 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 14:52 [PATCHv13 00/28] Request API Hans Verkuil
2018-05-03 14:52 ` [PATCHv13 01/28] v4l2-device.h: always expose mdev Hans Verkuil
2018-05-04 10:51 ` Sakari Ailus
2018-05-07 15:46 ` Mauro Carvalho Chehab
2018-05-08 8:34 ` Hans Verkuil
2018-05-16 3:40 ` Laurent Pinchart
2018-05-03 14:52 ` [PATCHv13 02/28] uapi/linux/media.h: add request API Hans Verkuil
2018-05-04 10:51 ` Sakari Ailus
2018-05-18 14:49 ` Laurent Pinchart
2018-05-03 14:52 ` [PATCHv13 03/28] media-request: implement media requests Hans Verkuil
2018-05-04 12:27 ` Sakari Ailus
2018-05-08 10:21 ` Mauro Carvalho Chehab
2018-05-08 10:52 ` Sakari Ailus
2018-05-08 12:41 ` Mauro Carvalho Chehab
2018-05-08 13:21 ` Sakari Ailus
2018-05-24 11:19 ` Hans Verkuil
2018-05-24 9:26 ` Hans Verkuil
2018-05-03 14:52 ` [PATCHv13 04/28] media-request: add media_request_get_by_fd Hans Verkuil
2018-05-04 12:26 ` Sakari Ailus
2018-05-07 17:01 ` Mauro Carvalho Chehab
2018-05-08 7:34 ` Hans Verkuil
2018-05-08 10:38 ` Mauro Carvalho Chehab
2018-05-03 14:52 ` [PATCHv13 05/28] media-request: add media_request_object_find Hans Verkuil
2018-05-04 12:43 ` Sakari Ailus
2018-05-07 17:05 ` Mauro Carvalho Chehab [this message]
2018-05-24 9:36 ` Hans Verkuil
2018-05-08 10:54 ` Sakari Ailus
2018-05-24 9:28 ` Hans Verkuil
2018-05-03 14:52 ` [PATCHv13 06/28] v4l2-dev: lock req_queue_mutex Hans Verkuil
2018-05-07 17:20 ` Mauro Carvalho Chehab
2018-05-08 7:45 ` Hans Verkuil
2018-05-08 10:45 ` Mauro Carvalho Chehab
2018-05-24 9:51 ` Hans Verkuil
2018-05-03 14:52 ` [PATCHv13 07/28] videodev2.h: add request_fd field to v4l2_ext_controls Hans Verkuil
2018-05-03 14:52 ` [PATCHv13 08/28] v4l2-ctrls: v4l2_ctrl_add_handler: add from_other_dev Hans Verkuil
2018-05-03 14:52 ` [PATCHv13 09/28] v4l2-ctrls: prepare internal structs for request API Hans Verkuil
2018-05-07 17:35 ` Mauro Carvalho Chehab
2018-05-08 7:49 ` Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 10/28] v4l2-ctrls: alloc memory for p_req Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 11/28] v4l2-ctrls: use ref in helper instead of ctrl Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 12/28] v4l2-ctrls: add core request support Hans Verkuil
2018-05-07 18:06 ` Mauro Carvalho Chehab
2018-05-08 8:07 ` Hans Verkuil
2018-05-08 10:49 ` Mauro Carvalho Chehab
2018-05-24 10:27 ` Hans Verkuil
2018-05-16 10:19 ` Sakari Ailus
2018-05-16 10:46 ` Sakari Ailus
2018-05-16 10:55 ` Hans Verkuil
2018-05-16 11:18 ` Sakari Ailus
2018-05-03 14:53 ` [PATCHv13 13/28] v4l2-ctrls: support g/s_ext_ctrls for requests Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 14/28] videodev2.h: Add request_fd field to v4l2_buffer Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 15/28] vb2: store userspace data in vb2_v4l2_buffer Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 16/28] videobuf2-core: embed media_request_object Hans Verkuil
2018-05-08 9:54 ` Mauro Carvalho Chehab
2018-05-03 14:53 ` [PATCHv13 17/28] videobuf2-core: integrate with media requests Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 18/28] videobuf2-v4l2: " Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 19/28] videobuf2-core: add request helper functions Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 20/28] videobuf2-v4l2: add vb2_request_queue/validate helpers Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 21/28] v4l2-mem2mem: add vb2_m2m_request_queue Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 22/28] Documentation: v4l: document request API Hans Verkuil
2018-05-18 14:46 ` Laurent Pinchart
2018-05-24 4:32 ` Tomasz Figa
2018-05-24 7:55 ` Hans Verkuil
2018-05-24 14:46 ` Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 23/28] media: vim2m: add media device Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 24/28] vim2m: use workqueue Hans Verkuil
2018-05-04 11:34 ` Sakari Ailus
2018-05-03 14:53 ` [PATCHv13 25/28] vim2m: support requests Hans Verkuil
2018-05-17 20:41 ` Sakari Ailus
2018-05-03 14:53 ` [PATCHv13 26/28] vivid: add mc Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 27/28] vivid: add request support Hans Verkuil
2018-05-03 14:53 ` [PATCHv13 28/28] RFC: media-requests: add debugfs node Hans Verkuil
2018-05-08 10:26 ` [PATCHv13 00/28] Request API Mauro Carvalho Chehab
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=20180507140513.5d71664b@vento.lan \
--to=mchehab+samsung@kernel.org \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@iki.fi \
/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