linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linux-media@vger.kernel.org, linux-leds@vger.kernel.org,
	laurent.pinchart@ideasonboard.com, hverkuil@xs4all.nl
Subject: Re: [RFC 18/19] v4l2-fwnode: Add abstracted sub-device notifiers
Date: Tue, 18 Jul 2017 23:19:22 +0200	[thread overview]
Message-ID: <20170718211922.GI28538@bigcity.dyn.berto.se> (raw)
In-Reply-To: <20170718190401.14797-19-sakari.ailus@linux.intel.com>

Hi Sakari,

Thanks for your hard work!

On 2017-07-18 22:04:00 +0300, Sakari Ailus wrote:
> Add notifiers for sub-devices. The notifiers themselves are not visible for
> the sub-device drivers but instead are accessed through interface functions

I might be missing it, but I can't find a interface function to set the 
bound()/unbind() callbacks on a sub-notifiers :-) Is this intentional or 
only not present in this RFC?

> v4l2_subdev_fwnode_endpoints_parse() and
> v4l2_subdev_fwnode_reference_parse_sensor_common().


> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/v4l2-core/v4l2-async.c  | 27 +++++++++++++++++----
>  drivers/media/v4l2-core/v4l2-subdev.c | 44 +++++++++++++++++++++++++++++++++--
>  include/media/v4l2-fwnode.h           |  1 +
>  include/media/v4l2-subdev.h           | 11 +++++++++
>  4 files changed, 77 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c
> index 55fa7106345c..411deadf5d85 100644
> --- a/drivers/media/v4l2-core/v4l2-async.c
> +++ b/drivers/media/v4l2-core/v4l2-async.c
> @@ -134,10 +134,14 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
>  
>  	if (notifier->bound) {
>  		ret = notifier->bound(notifier, sd, asd);
> -		if (ret < 0) {
> -			v4l2_device_unregister_subdev(sd);
> -			return ret;
> -		}
> +		if (ret < 0)
> +			goto err_unregister;
> +	}
> +
> +	if (sd->subnotifier) {
> +		ret = v4l2_async_subnotifier_register(sd, sd->subnotifier);
> +		if (ret < 0)
> +			goto err_unbind;
>  	}
>  
>  	/* Remove from the waiting list */
> @@ -152,6 +156,15 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
>  		return notifier->complete(notifier);
>  
>  	return 0;
> +
> +err_unbind:
> +	if (notifier->unbind)
> +		notifier->unbind(notifier, sd, asd);
> +
> +err_unregister:
> +	v4l2_device_unregister_subdev(sd);
> +
> +	return ret;
>  }
>  
>  static void v4l2_async_cleanup(struct v4l2_subdev *sd)
> @@ -283,6 +296,9 @@ v4l2_async_do_notifier_unregister(struct v4l2_async_notifier *notifier,
>  		/* If we handled USB devices, we'd have to lock the parent too */
>  		device_release_driver(d);
>  
> +		if (sd->subnotifier)
> +			v4l2_async_subnotifier_unregister(sd->subnotifier);
> +
>  		if (notifier->unbind)
>  			notifier->unbind(notifier, sd, sd->asd);
>  
> @@ -396,6 +412,9 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)
>  
>  	v4l2_async_cleanup(sd);
>  
> +	if (sd->subnotifier)
> +		v4l2_async_subnotifier_unregister(sd->subnotifier);
> +
>  	if (notifier->unbind)
>  		notifier->unbind(notifier, sd, sd->asd);
>  
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index 43fefa73e0a3..a6976d4a52ac 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -25,9 +25,10 @@
>  
>  #include <media/v4l2-ctrls.h>
>  #include <media/v4l2-device.h>
> -#include <media/v4l2-ioctl.h>
> -#include <media/v4l2-fh.h>
>  #include <media/v4l2-event.h>
> +#include <media/v4l2-fh.h>
> +#include <media/v4l2-fwnode.h>
> +#include <media/v4l2-ioctl.h>
>  
>  static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
>  {
> @@ -626,3 +627,42 @@ void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
>  	v4l2_subdev_notify(sd, V4L2_DEVICE_NOTIFY_EVENT, (void *)ev);
>  }
>  EXPORT_SYMBOL_GPL(v4l2_subdev_notify_event);
> +
> +static struct v4l2_async_notifier *v4l2_subdev_get_subnotifier(
> +	struct v4l2_subdev *sd)
> +{
> +	if (sd->subnotifier)
> +		return sd->subnotifier;
> +
> +	return (sd->subnotifier = devm_kzalloc(
> +			sd->dev, sizeof(*sd->subnotifier), GFP_KERNEL));
> +}
> +
> +int v4l2_subdev_fwnode_endpoints_parse(
> +	struct v4l2_subdev *sd,	size_t asd_struct_size,
> +	int (*parse_single)(struct device *dev,
> +			    struct v4l2_fwnode_endpoint *vep,
> +			    struct v4l2_async_subdev *asd))
> +{
> +	struct v4l2_async_notifier *subnotifier =
> +		v4l2_subdev_get_subnotifier(sd);
> +
> +	if (!subnotifier)
> +		return -ENOMEM;
> +
> +	return v4l2_fwnode_endpoints_parse(sd->dev, subnotifier,
> +					   asd_struct_size, parse_single);
> +}
> +EXPORT_SYMBOL_GPL(v4l2_subdev_fwnode_endpoints_parse);
> +
> +int v4l2_subdev_fwnode_reference_parse_sensor_common(struct v4l2_subdev *sd)
> +{
> +	struct v4l2_async_notifier *subnotifier =
> +		v4l2_subdev_get_subnotifier(sd);
> +
> +	if (!subnotifier)
> +		return -ENOMEM;
> +
> +	return v4l2_fwnode_reference_parse_sensor_common(sd->dev, subnotifier);
> +}
> +EXPORT_SYMBOL_GPL(v4l2_subdev_fwnode_reference_parse_sensor_common);
> diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
> index 8cd4f8a75c3d..0a3f869ead52 100644
> --- a/include/media/v4l2-fwnode.h
> +++ b/include/media/v4l2-fwnode.h
> @@ -27,6 +27,7 @@
>  struct fwnode_handle;
>  struct v4l2_async_notifier;
>  struct v4l2_async_subdev;
> +struct v4l2_subdev;
>  
>  /**
>   * struct v4l2_fwnode_bus_mipi_csi2 - MIPI CSI-2 bus data structure
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index 0f92ebd2d710..e309a2e2030b 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -43,6 +43,7 @@ struct v4l2_ctrl_handler;
>  struct v4l2_event;
>  struct v4l2_event_subscription;
>  struct v4l2_fh;
> +struct v4l2_fwnode_endpoint;
>  struct v4l2_subdev;
>  struct v4l2_subdev_fh;
>  struct tuner_setup;
> @@ -793,6 +794,7 @@ struct v4l2_subdev_platform_data {
>   *	list.
>   * @asd: Pointer to respective &struct v4l2_async_subdev.
>   * @notifier: Pointer to the managing notifier.
> + * @subnotifier: Pointer to the async sub-device notifier.
>   * @pdata: common part of subdevice platform data
>   *
>   * Each instance of a subdev driver should create this struct, either
> @@ -823,6 +825,7 @@ struct v4l2_subdev {
>  	struct list_head async_list;
>  	struct v4l2_async_subdev *asd;
>  	struct v4l2_async_notifier *notifier;
> +	struct v4l2_async_notifier *subnotifier;
>  	struct v4l2_subdev_platform_data *pdata;
>  };
>  
> @@ -1001,4 +1004,12 @@ void v4l2_subdev_init(struct v4l2_subdev *sd,
>  void v4l2_subdev_notify_event(struct v4l2_subdev *sd,
>  			      const struct v4l2_event *ev);
>  
> +int v4l2_subdev_fwnode_endpoints_parse(
> +	struct v4l2_subdev *sd,	size_t asd_struct_size,
> +	int (*parse_single)(struct device *dev,
> +			    struct v4l2_fwnode_endpoint *vep,
> +			    struct v4l2_async_subdev *asd));
> +
> +int v4l2_subdev_fwnode_reference_parse_sensor_common(struct v4l2_subdev *sd);
> +
>  #endif
> -- 
> 2.11.0
> 

-- 
Regards,
Niklas Söderlund

  reply	other threads:[~2017-07-18 21:19 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 19:03 [RFC 00/19] Async sub-notifiers and how to use them Sakari Ailus
2017-07-18 19:03 ` [RFC 01/19] device property: Introduce fwnode_property_get_reference_args Sakari Ailus
2017-07-18 19:03 ` [RFC 02/19] v4l: async: add subnotifier registration for subdevices Sakari Ailus
2017-07-18 21:28   ` Niklas Söderlund
2017-07-18 19:03 ` [RFC 03/19] dt: bindings: Add a binding for flash devices associated to a sensor Sakari Ailus
2017-07-18 19:03 ` [RFC 04/19] dt: bindings: Add lens-focus binding for image sensors Sakari Ailus
2017-07-28  8:53   ` Hans Verkuil
2017-07-28 12:45     ` Pavel Machek
2017-08-15 11:24     ` Sakari Ailus
2017-07-18 19:03 ` [RFC 05/19] leds: as3645a: Add LED flash class driver Sakari Ailus
2017-07-19 20:17   ` Jacek Anaszewski
2017-07-19 21:21     ` Sakari Ailus
2017-07-18 19:03 ` [RFC 06/19] leds: as3645a: Separate flash and indicator LED sub-devices Sakari Ailus
2017-07-18 19:03 ` [RFC 07/19] v4l: fwnode: Support generic parsing of graph endpoints in V4L2 Sakari Ailus
2017-07-18 19:03 ` [RFC 08/19] arm: dts: omap3: N9/N950: Add AS3645A camera flash Sakari Ailus
2017-07-18 19:16   ` Sakari Ailus
2017-07-22  9:40   ` Pavel Machek
2017-07-18 19:03 ` [RFC 09/19] v4l2-fwnode: Add conveniences function for parsing generic references Sakari Ailus
2017-07-18 19:03 ` [RFC 10/19] v4l2-fwnode: Add convenience function for parsing common external refs Sakari Ailus
2017-07-18 19:03 ` [RFC 11/19] v4l2-async: Register sub-devices before calling bound callback Sakari Ailus
2017-07-19 11:24   ` Hans Verkuil
2017-07-20 16:09     ` Sakari Ailus
2017-07-20 16:23       ` Hans Verkuil
2017-07-20 19:23         ` Sakari Ailus
2017-07-21  7:14           ` Hans Verkuil
2017-07-20 23:53         ` Kieran Bingham
2017-07-18 19:03 ` [RFC 12/19] v4l2-subdev: Support registering V4L2 sub-device nodes one by one Sakari Ailus
2017-07-18 19:03 ` [RFC 13/19] v4l2-device: Register sub-device nodes at sub-device registration time Sakari Ailus
2017-07-18 19:03 ` [RFC 14/19] omap3isp: Move sub-device link creation to notifier bound callback Sakari Ailus
2017-07-18 19:03 ` [RFC 15/19] omap3isp: Initialise "crashed" media entity enum in probe Sakari Ailus
2017-07-18 19:03 ` [RFC 16/19] omap3isp: Move media device registration to probe Sakari Ailus
2017-07-18 19:03 ` [RFC 17/19] omap3isp: Drop the async notifier callback Sakari Ailus
2017-07-18 19:04 ` [RFC 18/19] v4l2-fwnode: Add abstracted sub-device notifiers Sakari Ailus
2017-07-18 21:19   ` Niklas Söderlund [this message]
2017-07-19 22:20     ` Sakari Ailus
2017-07-19 22:33     ` [RFC 1/1] v4l2-subdev: Add a function to set sub-device notifier callbacks Sakari Ailus
2017-07-26 17:48       ` Mauro Carvalho Chehab
2017-07-18 19:04 ` [RFC 19/19] smiapp: Add support for flash and lens devices Sakari Ailus
2017-07-19 11:42 ` [RFC 00/19] Async sub-notifiers and how to use them Hans Verkuil
2017-07-20 16:14   ` Sakari Ailus
2017-07-21  6:57     ` Niklas Söderlund
2017-08-04 18:25       ` Sakari Ailus
2017-08-23  9:09         ` Hans Verkuil
2017-08-23 11:34           ` Pavel Machek
2017-08-23 12:02             ` Hans Verkuil
2017-08-23 12:29           ` Laurent Pinchart
2017-08-23 15:40             ` Hans Verkuil
2017-08-23 12:59           ` Niklas Söderlund
2017-08-23 13:32             ` Laurent Pinchart
2017-08-23 15:23               ` Hans Verkuil

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=20170718211922.GI28538@bigcity.dyn.berto.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).