From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Subject: [PATCH 16/18] [RFC] nvmem: Add of_nvmem_cell_from_cell_np
Date: Tue, 16 Feb 2016 17:29:17 -0800 [thread overview]
Message-ID: <1455672559-25061-17-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1455672559-25061-1-git-send-email-andrew.smirnov@gmail.com>
Add of_nvmem_cell_from_cell_np to allow creating 'struct nvmem_cell'
form a phandle of 'nvmem' cell.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/nvmem/core.c | 57 ++++++++++++++++++++++++++----------------
include/linux/nvmem-consumer.h | 10 ++++++++
2 files changed, 45 insertions(+), 22 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 0214253..5f9b2ce 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -342,32 +342,16 @@ static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id)
}
#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OFTREE)
-/**
- * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
- *
- * @dev node: Device tree node that uses the nvmem cell
- * @id: nvmem cell name from nvmem-cell-names property.
- *
- * Return: Will be an ERR_PTR() on error or a valid pointer
- * to a struct nvmem_cell. The nvmem_cell will be freed by the
- * nvmem_cell_put().
- */
-struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
- const char *name)
+
+
+struct nvmem_cell *
+of_nvmem_cell_from_cell_np(struct device_node *cell_np)
{
- struct device_node *cell_np, *nvmem_np;
+ struct device_node *nvmem_np;
struct nvmem_cell *cell;
struct nvmem_device *nvmem;
const __be32 *addr;
- int rval, len, index;
-
- index = of_property_match_string(np, "nvmem-cell-names", name);
- if (index < 0)
- return ERR_PTR(index);
-
- cell_np = of_parse_phandle(np, "nvmem-cells", index);
- if (!cell_np)
- return ERR_PTR(-EINVAL);
+ int rval, len;
nvmem_np = of_get_parent(cell_np);
if (!nvmem_np)
@@ -429,6 +413,35 @@ err_mem:
return ERR_PTR(rval);
}
+EXPORT_SYMBOL_GPL(of_nvmem_cell_from_cell_np);
+
+/**
+ * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
+ *
+ * @dev node: Device tree node that uses the nvmem cell
+ * @id: nvmem cell name from nvmem-cell-names property.
+ *
+ * Return: Will be an ERR_PTR() on error or a valid pointer
+ * to a struct nvmem_cell. The nvmem_cell will be freed by the
+ * nvmem_cell_put().
+ */
+struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
+ const char *name)
+{
+ struct device_node *cell_np;
+ int index;
+
+ index = of_property_match_string(np, "nvmem-cell-names", name);
+ if (index < 0)
+ return ERR_PTR(index);
+
+ cell_np = of_parse_phandle(np, "nvmem-cells", index);
+ if (!cell_np)
+ return ERR_PTR(-EINVAL);
+
+
+ return of_nvmem_cell_from_cell_np(cell_np);
+}
EXPORT_SYMBOL_GPL(of_nvmem_cell_get);
#endif
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index cae6ec7..76d6138 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -136,11 +136,21 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,
#endif /* CONFIG_NVMEM */
#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OFTREE)
+struct nvmem_cell *
+of_nvmem_cell_from_cell_np(struct device_node *cell_np);
+
struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
const char *name);
struct nvmem_device *of_nvmem_device_get(struct device_node *np,
const char *name);
+
#else
+struct nvmem_cell *
+of_nvmem_cell_from_cell_np(struct device_node *cell_np)
+{
+ return ERR_PTR(-ENOSYS);
+}
+
static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
const char *name)
{
--
2.5.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-02-17 1:30 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-17 1:29 [PATCH 00/17] RFC for additional 'nvmem' plumbing Andrey Smirnov
2016-02-17 1:29 ` [PATCH 01/18] common: Add EPROBE_DEFER to strerror Andrey Smirnov
2016-02-17 1:29 ` [PATCH 02/18] base: driver.c: Coalesce error checking code Andrey Smirnov
2016-02-17 1:29 ` [PATCH 03/18] [RFC] at91: Make IS_ERR work for I/O pointers Andrey Smirnov
2016-02-17 8:34 ` Sascha Hauer
2016-02-17 20:39 ` Andrey Smirnov
2016-02-18 10:26 ` Sascha Hauer
2016-02-17 1:29 ` [PATCH 04/18] [RFC] base/driver.c: Remove dev_request_mem_region_err_null Andrey Smirnov
2016-02-17 1:29 ` [PATCH 05/18] i2c-at91: Use IS_ERR instead of checking for NULL Andrey Smirnov
2016-02-17 1:29 ` [PATCH 06/18] clk-imx6: Call clk_enable on mmdc_ch0_axi_podf Andrey Smirnov
2016-02-17 1:29 ` [PATCH 07/18] fec_imx: Deallocate clocks when probe fails Andrey Smirnov
2016-02-17 1:29 ` [PATCH 08/18] [RFC] base: Introduce dev_request_mem_resource Andrey Smirnov
2016-02-17 1:29 ` [PATCH 09/18] fec_imx: Deallocate I/O resources if probe fails Andrey Smirnov
2016-02-17 1:29 ` [PATCH 10/18] fec_imx: Free phy_reset GPIO if when " Andrey Smirnov
2016-02-17 1:29 ` [PATCH 11/18] fec_imx: Use FEC_ECNTRL_RESET instead of a magic number Andrey Smirnov
2016-02-17 1:29 ` [PATCH 12/18] fec_imx: Impelemnt reset timeout Andrey Smirnov
2016-02-17 8:43 ` Sascha Hauer
2016-02-17 1:29 ` [PATCH 13/18] fec_imx: Deallocate DMA buffers when probe fails Andrey Smirnov
2016-02-17 1:29 ` [PATCH 14/18] fec_imx: Unregister MDIO " Andrey Smirnov
2016-02-17 1:29 ` [PATCH 15/18] [RFC] net: eth: Always use DEVICE_ID_DYNAMIC Andrey Smirnov
2016-02-17 2:40 ` Trent Piepho
2016-02-17 4:16 ` Andrey Smirnov
2016-02-18 19:30 ` Trent Piepho
2016-02-19 17:17 ` Andrey Smirnov
2016-02-17 1:29 ` Andrey Smirnov [this message]
2016-02-17 1:29 ` [PATCH 17/18] [RFC] nvmem: Add nvmem-ro-of-blob driver Andrey Smirnov
2016-02-17 8:52 ` Sascha Hauer
2016-02-17 20:40 ` Andrey Smirnov
2016-02-17 1:29 ` [PATCH 18/18] [RFC] nvmem: Add nvmem-sg driver Andrey Smirnov
2016-02-17 3:09 ` [PATCH 00/17] RFC for additional 'nvmem' plumbing Trent Piepho
2016-02-17 4:20 ` Andrey Smirnov
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=1455672559-25061-17-git-send-email-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
/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