public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: lee.jones@linaro.org
Cc: sameo@linux.intel.com, patches@opensource.wolfsonmicro.com,
	linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions
Date: Mon, 25 May 2015 10:28:35 +0100	[thread overview]
Message-ID: <1432546115-5685-2-git-send-email-ckeepax@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1432546115-5685-1-git-send-email-ckeepax@opensource.wolfsonmicro.com>

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


  reply	other threads:[~2015-05-25  9:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2015-05-27  9:24   ` [PATCH 2/2] mfd: arizona: Add DT/ACPI u32 helper functions 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

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=1432546115-5685-2-git-send-email-ckeepax@opensource.wolfsonmicro.com \
    --to=ckeepax@opensource.wolfsonmicro.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=sameo@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