LKML Archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime
@ 2015-05-25  9:28 Charles Keepax
  2015-05-25  9:28 ` [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions Charles Keepax
  2015-05-27  9:18 ` [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime Lee Jones
  0 siblings, 2 replies; 5+ messages in thread
From: Charles Keepax @ 2015-05-25  9:28 UTC (permalink / raw
  To: lee.jones; +Cc: sameo, patches, linux-kernel

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 include/dt-bindings/mfd/arizona.h |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
index c7af7c7..5556099 100644
--- a/include/dt-bindings/mfd/arizona.h
+++ b/include/dt-bindings/mfd/arizona.h
@@ -90,4 +90,18 @@
 #define ARIZONA_INMODE_SE   1
 #define ARIZONA_INMODE_DMIC 2
 
+#define ARIZONA_MICD_TIME_CONTINUOUS                 0
+#define ARIZONA_MICD_TIME_250US                      1
+#define ARIZONA_MICD_TIME_500US                      2
+#define ARIZONA_MICD_TIME_1MS                        3
+#define ARIZONA_MICD_TIME_2MS                        4
+#define ARIZONA_MICD_TIME_4MS                        5
+#define ARIZONA_MICD_TIME_8MS                        6
+#define ARIZONA_MICD_TIME_16MS                       7
+#define ARIZONA_MICD_TIME_32MS                       8
+#define ARIZONA_MICD_TIME_64MS                       9
+#define ARIZONA_MICD_TIME_128MS                      10
+#define ARIZONA_MICD_TIME_256MS                      11
+#define ARIZONA_MICD_TIME_512MS                      12
+
 #endif
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions
  2015-05-25  9:28 [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime Charles Keepax
@ 2015-05-25  9:28 ` Charles Keepax
  2015-05-27  9:24   ` Lee Jones
  2015-05-27  9:18 ` [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime Lee Jones
  1 sibling, 1 reply; 5+ messages in thread
From: Charles Keepax @ 2015-05-25  9:28 UTC (permalink / raw
  To: lee.jones; +Cc: sameo, patches, linux-kernel

Add helpers to read u32's and arrays of u32's from device tree or ACPI
using the new device properties API.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/mfd/arizona-core.c       |   39 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/arizona/core.h |    5 ++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index bebf58a..fb55769 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -20,6 +20,7 @@
 #include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/regulator/machine.h>
@@ -746,6 +747,44 @@ int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
 }
 EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);
 
+int arizona_device_read_u32_array(struct arizona *arizona,
+				  const char *prop, bool mandatory,
+				  u32 *data, size_t num)
+{
+	int ret;
+
+	ret = device_property_read_u32_array(arizona->dev, prop, data, num);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		if (!mandatory)
+			break;
+
+		dev_err(arizona->dev, "Mandatory property %s is missing\n",
+			prop);
+		break;
+	default:
+		dev_err(arizona->dev, "Property %s is malformed: %d\n",
+			prop, ret);
+		break;
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(arizona_device_read_u32_array);
+
+unsigned int arizona_device_read_u32(struct arizona *arizona,
+				     const char *prop, bool mandatory)
+{
+	u32 data = 0;
+
+	arizona_device_read_u32_array(arizona, prop, mandatory, &data, 1);
+
+	return data;
+}
+EXPORT_SYMBOL_GPL(arizona_device_read_u32);
+
 static int arizona_of_get_core_pdata(struct arizona *arizona)
 {
 	struct arizona_pdata *pdata = &arizona->pdata;
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
index 847bdaf..1c3d39d 100644
--- a/include/linux/mfd/arizona/core.h
+++ b/include/linux/mfd/arizona/core.h
@@ -160,5 +160,10 @@ int wm8997_patch(struct arizona *arizona);
 
 extern int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
 				     bool mandatory);
+extern int arizona_device_read_u32_array(struct arizona *arizona,
+					 const char *prop, bool mandatory,
+					 u32 *data, size_t num);
+extern unsigned int arizona_device_read_u32(struct arizona *arizona,
+					    const char *prop, bool mandatory);
 
 #endif
-- 
1.7.2.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime
  2015-05-25  9:28 [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime Charles Keepax
  2015-05-25  9:28 ` [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions Charles Keepax
@ 2015-05-27  9:18 ` Lee Jones
  1 sibling, 0 replies; 5+ messages in thread
From: Lee Jones @ 2015-05-27  9:18 UTC (permalink / raw
  To: Charles Keepax; +Cc: sameo, patches, linux-kernel

On Mon, 25 May 2015, Charles Keepax wrote:

> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  include/dt-bindings/mfd/arizona.h |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)

Applied, thanks.

> diff --git a/include/dt-bindings/mfd/arizona.h b/include/dt-bindings/mfd/arizona.h
> index c7af7c7..5556099 100644
> --- a/include/dt-bindings/mfd/arizona.h
> +++ b/include/dt-bindings/mfd/arizona.h
> @@ -90,4 +90,18 @@
>  #define ARIZONA_INMODE_SE   1
>  #define ARIZONA_INMODE_DMIC 2
>  
> +#define ARIZONA_MICD_TIME_CONTINUOUS                 0
> +#define ARIZONA_MICD_TIME_250US                      1
> +#define ARIZONA_MICD_TIME_500US                      2
> +#define ARIZONA_MICD_TIME_1MS                        3
> +#define ARIZONA_MICD_TIME_2MS                        4
> +#define ARIZONA_MICD_TIME_4MS                        5
> +#define ARIZONA_MICD_TIME_8MS                        6
> +#define ARIZONA_MICD_TIME_16MS                       7
> +#define ARIZONA_MICD_TIME_32MS                       8
> +#define ARIZONA_MICD_TIME_64MS                       9
> +#define ARIZONA_MICD_TIME_128MS                      10
> +#define ARIZONA_MICD_TIME_256MS                      11
> +#define ARIZONA_MICD_TIME_512MS                      12
> +
>  #endif

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions
  2015-05-25  9:28 ` [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions Charles Keepax
@ 2015-05-27  9:24   ` Lee Jones
  2015-05-27 10:08     ` Charles Keepax
  0 siblings, 1 reply; 5+ messages in thread
From: Lee Jones @ 2015-05-27  9:24 UTC (permalink / raw
  To: Charles Keepax; +Cc: sameo, patches, linux-kernel

On Mon, 25 May 2015, Charles Keepax wrote:

> Add helpers to read u32's and arrays of u32's from device tree or ACPI
> using the new device properties API.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> ---
>  drivers/mfd/arizona-core.c       |   39 ++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/arizona/core.h |    5 ++++
>  2 files changed, 44 insertions(+), 0 deletions(-)

Me no likey!

There are 100's of 'required' and 'optional' properties in the kernel
and it's normally the decision to early return or not that seals the
fate of a given driver.  I'm not happy for platforms to start adding
their own variants.

If you really do think these kinds of "helpers" add value, then make
them generic, so everyone can make use of them.  Personally, I'm
dubious however.

> diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
> index bebf58a..fb55769 100644
> --- a/drivers/mfd/arizona-core.c
> +++ b/drivers/mfd/arizona-core.c
> @@ -20,6 +20,7 @@
>  #include <linux/of_device.h>
>  #include <linux/of_gpio.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/regulator/machine.h>
> @@ -746,6 +747,44 @@ int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
>  }
>  EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);
>  
> +int arizona_device_read_u32_array(struct arizona *arizona,
> +				  const char *prop, bool mandatory,
> +				  u32 *data, size_t num)
> +{
> +	int ret;
> +
> +	ret = device_property_read_u32_array(arizona->dev, prop, data, num);
> +	switch (ret) {
> +	case 0:
> +		break;
> +	case -EINVAL:
> +		if (!mandatory)
> +			break;
> +
> +		dev_err(arizona->dev, "Mandatory property %s is missing\n",
> +			prop);
> +		break;
> +	default:
> +		dev_err(arizona->dev, "Property %s is malformed: %d\n",
> +			prop, ret);
> +		break;
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(arizona_device_read_u32_array);
> +
> +unsigned int arizona_device_read_u32(struct arizona *arizona,
> +				     const char *prop, bool mandatory)
> +{
> +	u32 data = 0;
> +
> +	arizona_device_read_u32_array(arizona, prop, mandatory, &data, 1);
> +
> +	return data;
> +}
> +EXPORT_SYMBOL_GPL(arizona_device_read_u32);
> +
>  static int arizona_of_get_core_pdata(struct arizona *arizona)
>  {
>  	struct arizona_pdata *pdata = &arizona->pdata;
> diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
> index 847bdaf..1c3d39d 100644
> --- a/include/linux/mfd/arizona/core.h
> +++ b/include/linux/mfd/arizona/core.h
> @@ -160,5 +160,10 @@ int wm8997_patch(struct arizona *arizona);
>  
>  extern int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
>  				     bool mandatory);
> +extern int arizona_device_read_u32_array(struct arizona *arizona,
> +					 const char *prop, bool mandatory,
> +					 u32 *data, size_t num);
> +extern unsigned int arizona_device_read_u32(struct arizona *arizona,
> +					    const char *prop, bool mandatory);
>  
>  #endif

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions
  2015-05-27  9:24   ` Lee Jones
@ 2015-05-27 10:08     ` Charles Keepax
  0 siblings, 0 replies; 5+ messages in thread
From: Charles Keepax @ 2015-05-27 10:08 UTC (permalink / raw
  To: Lee Jones; +Cc: sameo, patches, linux-kernel

On Wed, May 27, 2015 at 10:24:40AM +0100, Lee Jones wrote:
> On Mon, 25 May 2015, Charles Keepax wrote:
> 
> > Add helpers to read u32's and arrays of u32's from device tree or ACPI
> > using the new device properties API.
> > 
> > Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
> > ---
> >  drivers/mfd/arizona-core.c       |   39 ++++++++++++++++++++++++++++++++++++++
> >  include/linux/mfd/arizona/core.h |    5 ++++
> >  2 files changed, 44 insertions(+), 0 deletions(-)
> 
> Me no likey!
> 
> There are 100's of 'required' and 'optional' properties in the kernel
> and it's normally the decision to early return or not that seals the
> fate of a given driver.  I'm not happy for platforms to start adding
> their own variants.
> 
> If you really do think these kinds of "helpers" add value, then make
> them generic, so everyone can make use of them.  Personally, I'm
> dubious however.

Thats cool I don't really have any problem with dropping this
patch and doing the necessary checking where appropriate.

Thanks,
Charles

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-27 10:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-25  9:28 [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime Charles Keepax
2015-05-25  9:28 ` [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions Charles Keepax
2015-05-27  9:24   ` Lee Jones
2015-05-27 10:08     ` Charles Keepax
2015-05-27  9:18 ` [PATCH 1/2] mfd: arizona: Add convience defines for micd_rate/micd_bias_starttime Lee Jones

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 read-only IMAP folder(s) and NNTP newsgroup(s).