Re: [PATCH 1/3] device: property: add helpers to count items in string arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 08, 2020 at 02:58:11PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> 
> Instead of doing the following:
> 
>     count = device_property_read_string_array(dev, propname, NULL, 0);
> 
> Let's provide inline helpers with hardcoded arguments for counting
> strings in property arrays.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

Thanks!

> Suggested-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> ---
>  include/linux/property.h | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 9f805c442819..1fa5e250a8ea 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -170,6 +170,12 @@ static inline int device_property_count_u64(struct device *dev, const char *prop
>  	return device_property_read_u64_array(dev, propname, NULL, 0);
>  }
>  
> +static inline int device_property_count_strings(struct device *dev,
> +						const char *propname)
> +{
> +	return device_property_read_string_array(dev, propname, NULL, 0);
> +}
> +
>  static inline bool fwnode_property_read_bool(const struct fwnode_handle *fwnode,
>  					     const char *propname)
>  {
> @@ -224,6 +230,13 @@ static inline int fwnode_property_count_u64(const struct fwnode_handle *fwnode,
>  	return fwnode_property_read_u64_array(fwnode, propname, NULL, 0);
>  }
>  
> +static inline int
> +fwnode_property_count_strings(const struct fwnode_handle *fwnode,
> +			      const char *propname)
> +{
> +	return fwnode_property_read_string_array(fwnode, propname, NULL, 0);
> +}
> +
>  struct software_node;
>  
>  /**
> -- 
> 2.26.1
> 

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux