Re: [PATCH v10 19/24] v4l: fwnode: Add convenience function for parsing common external refs

2017-09-11 Thread Sakari Ailus
On Mon, Sep 11, 2017 at 01:17:46PM +0200, Pavel Machek wrote:
> On Mon 2017-09-11 11:00:03, Sakari Ailus wrote:
> > Add v4l2_fwnode_parse_reference_sensor_common for parsing common
> > sensor properties that refer to adjacent devices such as flash or lens
> > driver chips.
> > 
> > As this is an association only, there's little a regular driver needs to
> > know about these devices as such.
> > 
> > Signed-off-by: Sakari Ailus 
> > Acked-by: Hans Verkuil 
> > ---
> >  drivers/media/v4l2-core/v4l2-fwnode.c | 35 
> > +++
> >  include/media/v4l2-fwnode.h   | 13 +
> >  2 files changed, 48 insertions(+)
> > 
> >  
> > +/**
> > + * v4l2_fwnode_reference_parse_sensor_common - parse common references on
> > + *sensors for async sub-devices
> > + * @dev: the device node the properties of which are parsed for references
> > + * @notifier: the async notifier where the async subdevs will be added
> > + *
> > + * Return: 0 on success
> > + *-ENOMEM if memory allocation failed
> > + *-EINVAL if property parsing failed
> > + */
> 
> Returns: would sound more correct to me, but it seems kernel is split
> on that.

I think in V4L2 there are roughly as many of each instances. I'll keep it
as it is.

> 
> Acked-by: Pavel Machek 

Thanks!

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH v10 19/24] v4l: fwnode: Add convenience function for parsing common external refs

2017-09-11 Thread Pavel Machek
On Mon 2017-09-11 11:00:03, Sakari Ailus wrote:
> Add v4l2_fwnode_parse_reference_sensor_common for parsing common
> sensor properties that refer to adjacent devices such as flash or lens
> driver chips.
> 
> As this is an association only, there's little a regular driver needs to
> know about these devices as such.
> 
> Signed-off-by: Sakari Ailus 
> Acked-by: Hans Verkuil 
> ---
>  drivers/media/v4l2-core/v4l2-fwnode.c | 35 
> +++
>  include/media/v4l2-fwnode.h   | 13 +
>  2 files changed, 48 insertions(+)
> 
>  
> +/**
> + * v4l2_fwnode_reference_parse_sensor_common - parse common references on
> + *  sensors for async sub-devices
> + * @dev: the device node the properties of which are parsed for references
> + * @notifier: the async notifier where the async subdevs will be added
> + *
> + * Return: 0 on success
> + *  -ENOMEM if memory allocation failed
> + *  -EINVAL if property parsing failed
> + */

Returns: would sound more correct to me, but it seems kernel is split
on that.

Acked-by: Pavel Machek 
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v10 19/24] v4l: fwnode: Add convenience function for parsing common external refs

2017-09-11 Thread Sakari Ailus
On Mon, Sep 11, 2017 at 11:47:11AM +0200, Hans Verkuil wrote:
> On 09/11/2017 10:00 AM, Sakari Ailus wrote:
> > Add v4l2_fwnode_parse_reference_sensor_common for parsing common
> > sensor properties that refer to adjacent devices such as flash or lens
> > driver chips.
> > 
> > As this is an association only, there's little a regular driver needs to
> > know about these devices as such.
> > 
> > Signed-off-by: Sakari Ailus 
> > Acked-by: Hans Verkuil 
> > ---
> >  drivers/media/v4l2-core/v4l2-fwnode.c | 35 
> > +++
> >  include/media/v4l2-fwnode.h   | 13 +
> >  2 files changed, 48 insertions(+)
> > 
> > diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
> > b/drivers/media/v4l2-core/v4l2-fwnode.c
> > index 56eee5bbd3b5..b9e60a0e8f86 100644
> > --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> > +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> > @@ -589,6 +589,41 @@ static int v4l2_fwnode_reference_parse_int_props(
> > return ret;
> >  }
> >  
> > +int v4l2_fwnode_reference_parse_sensor_common(
> > +   struct device *dev, struct v4l2_async_notifier *notifier)
> > +{
> > +   static const char *led_props[] = { "led" };
> > +   static const struct {
> > +   const char *name;
> > +   const char **props;
> > +   unsigned int nprops;
> > +   } props[] = {
> > +   { "flash-leds", led_props, ARRAY_SIZE(led_props) },
> > +   { "lens-focus", NULL, 0 },
> > +   };
> > +   unsigned int i;
> > +
> > +   for (i = 0; i < ARRAY_SIZE(props); i++) {
> > +   int ret;
> > +
> > +   if (props[i].props && is_acpi_node(dev_fwnode(dev)))
> > +   ret = v4l2_fwnode_reference_parse_int_props(
> > +   dev, notifier, props[i].name,
> > +   props[i].props, props[i].nprops);
> > +   else
> > +   ret = v4l2_fwnode_reference_parse(
> > +   dev, notifier, props[i].name);
> > +   if (ret) {
> > +   dev_warn(dev, "parsing property \"%s\" failed (%d)\n",
> > +props[i].name, ret);
> > +   return ret;
> > +   }
> > +   }
> > +
> > +   return 0;
> > +}
> > +EXPORT_SYMBOL_GPL(v4l2_fwnode_reference_parse_sensor_common);
> > +
> >  MODULE_LICENSE("GPL");
> >  MODULE_AUTHOR("Sakari Ailus ");
> >  MODULE_AUTHOR("Sylwester Nawrocki ");
> > diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
> > index 3819a73c3c8a..bcec1ce101dc 100644
> > --- a/include/media/v4l2-fwnode.h
> > +++ b/include/media/v4l2-fwnode.h
> > @@ -257,4 +257,17 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
> >   struct v4l2_fwnode_endpoint *vep,
> >   struct v4l2_async_subdev *asd));
> >  
> > +/**
> > + * v4l2_fwnode_reference_parse_sensor_common - parse common references on
> > + *sensors for async sub-devices
> > + * @dev: the device node the properties of which are parsed for references
> > + * @notifier: the async notifier where the async subdevs will be added
> > + *
> 
> I think you should add a note that if this function returns 0 the
> caller should remember to call v4l2_async_notifier_release. That is not
> immediately obvious.

I'll add that, plus a note to v4l2_async_notifier_release() as well.

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi


Re: [PATCH v10 19/24] v4l: fwnode: Add convenience function for parsing common external refs

2017-09-11 Thread Hans Verkuil
On 09/11/2017 10:00 AM, Sakari Ailus wrote:
> Add v4l2_fwnode_parse_reference_sensor_common for parsing common
> sensor properties that refer to adjacent devices such as flash or lens
> driver chips.
> 
> As this is an association only, there's little a regular driver needs to
> know about these devices as such.
> 
> Signed-off-by: Sakari Ailus 
> Acked-by: Hans Verkuil 
> ---
>  drivers/media/v4l2-core/v4l2-fwnode.c | 35 
> +++
>  include/media/v4l2-fwnode.h   | 13 +
>  2 files changed, 48 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
> b/drivers/media/v4l2-core/v4l2-fwnode.c
> index 56eee5bbd3b5..b9e60a0e8f86 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -589,6 +589,41 @@ static int v4l2_fwnode_reference_parse_int_props(
>   return ret;
>  }
>  
> +int v4l2_fwnode_reference_parse_sensor_common(
> + struct device *dev, struct v4l2_async_notifier *notifier)
> +{
> + static const char *led_props[] = { "led" };
> + static const struct {
> + const char *name;
> + const char **props;
> + unsigned int nprops;
> + } props[] = {
> + { "flash-leds", led_props, ARRAY_SIZE(led_props) },
> + { "lens-focus", NULL, 0 },
> + };
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(props); i++) {
> + int ret;
> +
> + if (props[i].props && is_acpi_node(dev_fwnode(dev)))
> + ret = v4l2_fwnode_reference_parse_int_props(
> + dev, notifier, props[i].name,
> + props[i].props, props[i].nprops);
> + else
> + ret = v4l2_fwnode_reference_parse(
> + dev, notifier, props[i].name);
> + if (ret) {
> + dev_warn(dev, "parsing property \"%s\" failed (%d)\n",
> +  props[i].name, ret);
> + return ret;
> + }
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(v4l2_fwnode_reference_parse_sensor_common);
> +
>  MODULE_LICENSE("GPL");
>  MODULE_AUTHOR("Sakari Ailus ");
>  MODULE_AUTHOR("Sylwester Nawrocki ");
> diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
> index 3819a73c3c8a..bcec1ce101dc 100644
> --- a/include/media/v4l2-fwnode.h
> +++ b/include/media/v4l2-fwnode.h
> @@ -257,4 +257,17 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
> struct v4l2_fwnode_endpoint *vep,
> struct v4l2_async_subdev *asd));
>  
> +/**
> + * v4l2_fwnode_reference_parse_sensor_common - parse common references on
> + *  sensors for async sub-devices
> + * @dev: the device node the properties of which are parsed for references
> + * @notifier: the async notifier where the async subdevs will be added
> + *

I think you should add a note that if this function returns 0 the
caller should remember to call v4l2_async_notifier_release. That is not
immediately obvious.

Regards,

Hans

> + * Return: 0 on success
> + *  -ENOMEM if memory allocation failed
> + *  -EINVAL if property parsing failed
> + */
> +int v4l2_fwnode_reference_parse_sensor_common(
> + struct device *dev, struct v4l2_async_notifier *notifier);
> +
>  #endif /* _V4L2_FWNODE_H */
> 



[PATCH v10 19/24] v4l: fwnode: Add convenience function for parsing common external refs

2017-09-11 Thread Sakari Ailus
Add v4l2_fwnode_parse_reference_sensor_common for parsing common
sensor properties that refer to adjacent devices such as flash or lens
driver chips.

As this is an association only, there's little a regular driver needs to
know about these devices as such.

Signed-off-by: Sakari Ailus 
Acked-by: Hans Verkuil 
---
 drivers/media/v4l2-core/v4l2-fwnode.c | 35 +++
 include/media/v4l2-fwnode.h   | 13 +
 2 files changed, 48 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c 
b/drivers/media/v4l2-core/v4l2-fwnode.c
index 56eee5bbd3b5..b9e60a0e8f86 100644
--- a/drivers/media/v4l2-core/v4l2-fwnode.c
+++ b/drivers/media/v4l2-core/v4l2-fwnode.c
@@ -589,6 +589,41 @@ static int v4l2_fwnode_reference_parse_int_props(
return ret;
 }
 
+int v4l2_fwnode_reference_parse_sensor_common(
+   struct device *dev, struct v4l2_async_notifier *notifier)
+{
+   static const char *led_props[] = { "led" };
+   static const struct {
+   const char *name;
+   const char **props;
+   unsigned int nprops;
+   } props[] = {
+   { "flash-leds", led_props, ARRAY_SIZE(led_props) },
+   { "lens-focus", NULL, 0 },
+   };
+   unsigned int i;
+
+   for (i = 0; i < ARRAY_SIZE(props); i++) {
+   int ret;
+
+   if (props[i].props && is_acpi_node(dev_fwnode(dev)))
+   ret = v4l2_fwnode_reference_parse_int_props(
+   dev, notifier, props[i].name,
+   props[i].props, props[i].nprops);
+   else
+   ret = v4l2_fwnode_reference_parse(
+   dev, notifier, props[i].name);
+   if (ret) {
+   dev_warn(dev, "parsing property \"%s\" failed (%d)\n",
+props[i].name, ret);
+   return ret;
+   }
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(v4l2_fwnode_reference_parse_sensor_common);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Sakari Ailus ");
 MODULE_AUTHOR("Sylwester Nawrocki ");
diff --git a/include/media/v4l2-fwnode.h b/include/media/v4l2-fwnode.h
index 3819a73c3c8a..bcec1ce101dc 100644
--- a/include/media/v4l2-fwnode.h
+++ b/include/media/v4l2-fwnode.h
@@ -257,4 +257,17 @@ int v4l2_async_notifier_parse_fwnode_endpoints(
  struct v4l2_fwnode_endpoint *vep,
  struct v4l2_async_subdev *asd));
 
+/**
+ * v4l2_fwnode_reference_parse_sensor_common - parse common references on
+ *sensors for async sub-devices
+ * @dev: the device node the properties of which are parsed for references
+ * @notifier: the async notifier where the async subdevs will be added
+ *
+ * Return: 0 on success
+ *-ENOMEM if memory allocation failed
+ *-EINVAL if property parsing failed
+ */
+int v4l2_fwnode_reference_parse_sensor_common(
+   struct device *dev, struct v4l2_async_notifier *notifier);
+
 #endif /* _V4L2_FWNODE_H */
-- 
2.11.0