* [RFC 0/3] Proposed extensions for NVMEM
@ 2016-02-22 19:52 Andrey Smirnov
2016-02-22 19:52 ` [RFC 1/3] nvmem: Add 'of_nvmem_cell_from_device_node()' Andrey Smirnov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Andrey Smirnov @ 2016-02-22 19:52 UTC (permalink / raw)
To: linux-kernel; +Cc: srinivas.kandagatla, maxime.ripard, s.hauer, Andrey Smirnov
Hello,
This RFC introduces two new drivers to NVMEM subsytem. First driver,
'nvmem-blob', serves the purpose of exposing data, embedded in DTB,
via NVMEM consumer API. Second, 'nvmem-composite', allows the user to
combin a number of NVMEM cells (or parts of them) into a single
continuos "blob" of data presented to the rest of the system as a
regular NVMEM device.
The intent of this RFC is to solicit feedback about the approach,
binding or if these features should be accepted upstream in general.
I originally proposed this extentions as a part of Barebox project (Barebox
borrows a lot of concepts from Linux kernel and adopting NVMEM
subsystem was being discussed), in order to facilitate usage of NVMEM
to initialize source of MAC address for a paticular Ethernet adapter
(Barebox would read that value and fixup DT blob with appropriate
value as a part of booting Linux). However the drivers should be
generic enough to not be tied to that case.
Please bear in mind the the code included is a very rough draft and a
lot of error checking/handling code in is was stubbed out.
Any feedback is welcome.
Thank you,
Andrey Smirnov
Andrey Smirnov (3):
nvmem: Add 'of_nvmem_cell_from_device_node()'
nvmem: Add 'nvmem-blob' driver
nvmem: Add 'nvmem-composite' driver
Documentation/devicetree/bindings/nvmem/blob.txt | 35 ++++
.../devicetree/bindings/nvmem/composite.txt | 44 ++++
drivers/nvmem/Makefile | 2 +
drivers/nvmem/blob.c | 132 ++++++++++++
drivers/nvmem/composite.c | 228 +++++++++++++++++++++
drivers/nvmem/core.c | 44 ++--
include/linux/nvmem-consumer.h | 7 +
7 files changed, 479 insertions(+), 13 deletions(-)
create mode 100644 Documentation/devicetree/bindings/nvmem/blob.txt
create mode 100644 Documentation/devicetree/bindings/nvmem/composite.txt
create mode 100644 drivers/nvmem/blob.c
create mode 100644 drivers/nvmem/composite.c
--
2.5.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC 1/3] nvmem: Add 'of_nvmem_cell_from_device_node()'
2016-02-22 19:52 [RFC 0/3] Proposed extensions for NVMEM Andrey Smirnov
@ 2016-02-22 19:52 ` Andrey Smirnov
2016-02-22 19:52 ` [RFC 2/3] nvmem: Add 'nvmem-blob' driver Andrey Smirnov
2016-02-22 19:52 ` [RFC 3/3] nvmem: Add 'nvmem-composite' driver Andrey Smirnov
2 siblings, 0 replies; 4+ messages in thread
From: Andrey Smirnov @ 2016-02-22 19:52 UTC (permalink / raw)
To: linux-kernel; +Cc: srinivas.kandagatla, maxime.ripard, s.hauer, Andrey Smirnov
Add 'of_nvmem_cell_from_device_node()' -- a function that allows to
obtain 'struct nvmem_cell' from a device tree node representing it. One
use-case for such a function would be to access nvmem cells with known
phandles.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/nvmem/core.c | 44 +++++++++++++++++++++++++++++-------------
include/linux/nvmem-consumer.h | 7 +++++++
2 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 6fd4e5a..08550dd 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -601,29 +601,21 @@ static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id)
#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
/**
- * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
+ * of_nvmem_cell_from_device_node() - Get a nvmem cell from device node representation
*
- * @dev node: Device tree node that uses the nvmem cell
- * @id: nvmem cell name from nvmem-cell-names property.
+ * @np node: Device tree node representing NVMEM cell
*
* 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_device_node(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);
-
- cell_np = of_parse_phandle(np, "nvmem-cells", index);
- if (!cell_np)
- return ERR_PTR(-EINVAL);
+ int rval, len;
nvmem_np = of_get_next_parent(cell_np);
if (!nvmem_np)
@@ -682,6 +674,32 @@ err_mem:
return ERR_PTR(rval);
}
+EXPORT_SYMBOL_GPL(of_nvmem_cell_from_device_node);
+
+/**
+ * of_nvmem_cell_get() - Get a nvmem cell from given device node referencing it 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);
+
+ cell_np = of_parse_phandle(np, "nvmem-cells", index);
+ if (!cell_np)
+ return ERR_PTR(-EINVAL);
+
+ return of_nvmem_cell_from_device_node(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 9bb77d3..835c8a2 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -136,11 +136,18 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,
#endif /* CONFIG_NVMEM */
#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
+struct nvmem_cell *of_nvmem_cell_from_device_node(struct device_node *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 inline struct nvmem_cell *
+of_nvmem_cell_from_device_node(struct device_node *np)
+{
+ return ERR_PTR(-ENOSYS);
+}
static inline struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
const char *name)
{
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFC 2/3] nvmem: Add 'nvmem-blob' driver
2016-02-22 19:52 [RFC 0/3] Proposed extensions for NVMEM Andrey Smirnov
2016-02-22 19:52 ` [RFC 1/3] nvmem: Add 'of_nvmem_cell_from_device_node()' Andrey Smirnov
@ 2016-02-22 19:52 ` Andrey Smirnov
2016-02-22 19:52 ` [RFC 3/3] nvmem: Add 'nvmem-composite' driver Andrey Smirnov
2 siblings, 0 replies; 4+ messages in thread
From: Andrey Smirnov @ 2016-02-22 19:52 UTC (permalink / raw)
To: linux-kernel; +Cc: srinivas.kandagatla, maxime.ripard, s.hauer, Andrey Smirnov
Add 'nvmem-blob' driver, which allows to access device tree embedded
data via NVMEM subsystem API.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
Documentation/devicetree/bindings/nvmem/blob.txt | 35 ++++++
drivers/nvmem/Makefile | 1 +
drivers/nvmem/blob.c | 132 +++++++++++++++++++++++
3 files changed, 168 insertions(+)
create mode 100644 Documentation/devicetree/bindings/nvmem/blob.txt
create mode 100644 drivers/nvmem/blob.c
diff --git a/Documentation/devicetree/bindings/nvmem/blob.txt b/Documentation/devicetree/bindings/nvmem/blob.txt
new file mode 100644
index 0000000..b299576
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/blob.txt
@@ -0,0 +1,35 @@
+= Deviece Tree Embedded Blob As NVMEM Device =
+
+This binding is designed to provide a way for a developer to reference
+data, built-in into device tree blob file, as NVMEM provider and acccess
+certain portions of that data as NVMEM cells using NVMEM consumer API.
+
+Required properties:
+- compatible: should be "nvmem-blob"
+- data: specifies data contained in nvmem device
+
+= Data cells =
+Are child nodes of nvmem-composite, bindings of which as described in
+bindings/nvmem/nvmem.txt
+
+Example:
+
+ a-blob {
+ compatible = "nvmem-blob";
+ data = [aa bb cc dd ee];
+
+ cell1: cell@0 {
+ reg = <0 5>;
+ };
+ };
+
+= Data consumers =
+Are device nodes which consume nvmem data cells.
+
+Example:
+
+ a-node {
+ ...
+ nvmem-cells = <&cell1>;
+ nvmem-cell-names = "some-data";
+ };
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 95dde3f..1a1adba 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -18,3 +18,4 @@ obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o
nvmem_sunxi_sid-y := sunxi_sid.o
obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o
nvmem-vf610-ocotp-y := vf610-ocotp.o
+obj-y += blob.o
diff --git a/drivers/nvmem/blob.c b/drivers/nvmem/blob.c
new file mode 100644
index 0000000..3f2296b
--- /dev/null
+++ b/drivers/nvmem/blob.c
@@ -0,0 +1,132 @@
+#define DEBUG 1
+
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+struct nvmem_blob {
+ const u8 *data;
+ size_t data_size;
+};
+
+static int nvmem_blob_write(void *context, const void *data,
+ size_t count)
+{
+ return -ENOTSUPP;
+}
+
+static int nvmem_blob_read(void *context,
+ const void *reg, size_t reg_size,
+ void *val, size_t val_size)
+{
+ struct nvmem_blob *nblob = context;
+ const unsigned int offset = *(u32 *)reg;
+
+ memcpy(val, nblob->data + offset,
+ min(val_size, nblob->data_size - offset));
+ return 0;
+}
+
+static const struct regmap_bus nvmem_blob_regmap_bus = {
+ .write = nvmem_blob_write,
+ .read = nvmem_blob_read,
+};
+
+
+static int nvmem_blob_validate_dt(struct device_node *np)
+{
+ return 0;
+}
+
+static int nvmem_blob_probe(struct platform_device *pdev)
+{
+ int ret;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct regmap *map;
+ struct nvmem_device *nvmem;
+ struct nvmem_blob *nblob;
+ struct property *pp;
+ struct nvmem_config nv_cnf = {0};
+ struct regmap_config rm_cnf = {0};
+
+ ret = nvmem_blob_validate_dt(np);
+ if (ret < 0) {
+ dev_dbg(dev, "Device tree validation failed\n");
+ return ret;
+ }
+
+ nblob = devm_kzalloc(dev, sizeof(*nblob), GFP_KERNEL);
+ if (!nblob) {
+ dev_dbg(dev, "Not enough memory to allocate a blob\n");
+ return -ENOMEM;
+ }
+
+ pp = of_find_property(np, "data", NULL);
+ BUG_ON(!pp);
+
+ nblob->data = pp->value;
+ nblob->data_size = pp->length;
+
+ rm_cnf.reg_bits = 32;
+ rm_cnf.val_bits = 8;
+ rm_cnf.reg_stride = 1;
+ rm_cnf.name = "nvmem-blob";
+ rm_cnf.max_register = nblob->data_size - 1;
+
+ map = devm_regmap_init(dev,
+ &nvmem_blob_regmap_bus,
+ nblob,
+ &rm_cnf);
+ if (IS_ERR(map)) {
+ dev_dbg(dev, "Failed to initilize regmap\n");
+ return PTR_ERR(map);
+ }
+
+ nv_cnf.name = "nvmem-blob";
+ nv_cnf.read_only = true;
+ nv_cnf.dev = dev;
+ nv_cnf.owner = THIS_MODULE;
+
+ nvmem = nvmem_register(&nv_cnf);
+ if (IS_ERR(nvmem)) {
+ dev_dbg(dev, "Filed to register nvmem device\n");
+ return PTR_ERR(nvmem);
+ }
+
+ platform_set_drvdata(pdev, nblob);
+ return 0;
+}
+
+static int nvmem_blob_remove(struct platform_device *pdev)
+{
+ struct nvmem_device *nvmem = platform_get_drvdata(pdev);
+
+ return nvmem_unregister(nvmem);
+}
+
+static const struct of_device_id nvmem_blob_dt_ids[] = {
+ { .compatible = "nvmem-blob", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, nvmem_blob_dt_ids);
+
+static struct platform_driver nvmem_blob_driver = {
+ .probe = nvmem_blob_probe,
+ .remove = nvmem_blob_remove,
+ .driver = {
+ .name = "nvmem-blob",
+ .of_match_table = nvmem_blob_dt_ids,
+ },
+};
+module_platform_driver(nvmem_blob_driver);
+
+MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>");
+MODULE_DESCRIPTION("FIXME");
+MODULE_LICENSE("GPL v2");
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFC 3/3] nvmem: Add 'nvmem-composite' driver
2016-02-22 19:52 [RFC 0/3] Proposed extensions for NVMEM Andrey Smirnov
2016-02-22 19:52 ` [RFC 1/3] nvmem: Add 'of_nvmem_cell_from_device_node()' Andrey Smirnov
2016-02-22 19:52 ` [RFC 2/3] nvmem: Add 'nvmem-blob' driver Andrey Smirnov
@ 2016-02-22 19:52 ` Andrey Smirnov
2 siblings, 0 replies; 4+ messages in thread
From: Andrey Smirnov @ 2016-02-22 19:52 UTC (permalink / raw)
To: linux-kernel; +Cc: srinivas.kandagatla, maxime.ripard, s.hauer, Andrey Smirnov
Add 'nvmem-composite' driver which allows to combine multiple chunks of
various NVMEM cells into a single continuous NVMEM device.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
.../devicetree/bindings/nvmem/composite.txt | 44 ++++
drivers/nvmem/Makefile | 1 +
drivers/nvmem/composite.c | 228 +++++++++++++++++++++
3 files changed, 273 insertions(+)
create mode 100644 Documentation/devicetree/bindings/nvmem/composite.txt
create mode 100644 drivers/nvmem/composite.c
diff --git a/Documentation/devicetree/bindings/nvmem/composite.txt b/Documentation/devicetree/bindings/nvmem/composite.txt
new file mode 100644
index 0000000..e24cf4b
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/composite.txt
@@ -0,0 +1,44 @@
+= NVMEM cell compositor =
+
+This binding is designed to provide a way for a developer to combine
+portions of other NVMEM cell and acces that data as a signle NVMEM
+cell using NVMEM consumer API.
+
+Required properties:
+- compatible: should be "nvmem-composite"
+- layout: specifies which sources comprise data in nvmem device
+ format is "<nvmem-cell-phandle offset size>"
+
+= Data cells =
+Are child nodes of nvmem-composite, bindings of which as described in
+bindings/nvmem/nvmem.txt
+
+Example:
+
+ composite-nvmem {
+ compatible = "nvmem-composite";
+ layout = <&another_cell_a 0 2
+ &another_cell_b 0 1
+ &another_cell_c 3 2>;
+
+ cell1: cell@0 {
+ reg = <0 5>;
+ };
+ }
+
+the result of reading variable cell1 would be:
+
+[a[0] a[1] b[0] c[3] c[4]],
+
+where a[i], b[i], c[i], represnet i-th bytes of NVMEM cells
+another_cell_a, another_cell_b and another_cell_c respectively
+
+= Data consumers =
+Are device nodes which consume nvmem data cells.
+
+Example:
+
+ a-node {
+ nvmem-cells = <&cell1>;
+ nvmem-cell-names = "some-data";
+ };
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 1a1adba..49c0eca 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -19,3 +19,4 @@ nvmem_sunxi_sid-y := sunxi_sid.o
obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o
nvmem-vf610-ocotp-y := vf610-ocotp.o
obj-y += blob.o
+obj-y += composite.o
diff --git a/drivers/nvmem/composite.c b/drivers/nvmem/composite.c
new file mode 100644
index 0000000..5c29923
--- /dev/null
+++ b/drivers/nvmem/composite.c
@@ -0,0 +1,228 @@
+#define DEBUG 1
+
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/nvmem-consumer.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+struct nvmem_composite {
+ struct device *dev;
+ struct list_head layout;
+ size_t layout_size;
+};
+
+struct nvmem_composite_item {
+ struct nvmem_cell *cell;
+ unsigned int idx, start, end, size;
+ struct list_head node;
+};
+
+static struct nvmem_composite_item *
+nvmem_composite_find_first(struct nvmem_composite *ncomp,
+ unsigned int offset)
+{
+ struct nvmem_composite_item *first;
+ list_for_each_entry(first, &ncomp->layout, node) {
+ /*
+ * Skip all of the irrelevant items that end before our offset
+ */
+ if (first->end > offset)
+ return first;
+ }
+
+ return NULL;
+}
+
+static int nvmem_composite_read(void *context,
+ const void *reg, size_t reg_size,
+ void *val, size_t val_size)
+{
+ int ii;
+ struct nvmem_composite *ncomp = context;
+ const unsigned int offset = *(u32 *)reg;
+ void *dst = val;
+ size_t residue = val_size;
+ struct nvmem_composite_item *item, *first;
+ uint8_t *data;
+ size_t size, chunk;
+
+
+ first = item = nvmem_composite_find_first(ncomp, offset);
+ if (!first) {
+ dev_dbg(ncomp->dev, "Invalid offset\n");
+ return -EINVAL;
+ }
+
+ list_for_each_entry_from(item, &ncomp->layout, node) {
+ /*
+ * If our first read is not located on item boundary
+ * we have to introduce artificial offset
+ */
+ ii = (item == first) ? offset - first->start : 0;
+
+ data = nvmem_cell_read(item->cell, &size);
+ if (IS_ERR(data)) {
+ dev_dbg(ncomp->dev, "Failed to read nvmem cell\n");
+ return PTR_ERR(data);
+ }
+
+ chunk = min(residue, item->size - ii);
+ memcpy(dst, &data[item->idx + ii], chunk);
+ kfree(data);
+
+ dev_dbg(ncomp->dev, "chunk %u\n", chunk);
+
+ dst += chunk;
+ residue -= chunk;
+ }
+
+ return (residue) ? -EINVAL : 0;
+}
+
+static int nvmem_composite_write(void *context, const void *data,
+ size_t count)
+{
+ return -ENOTSUPP;
+}
+
+static const struct regmap_bus nvmem_composite_regmap_bus = {
+ .write = nvmem_composite_write,
+ .read = nvmem_composite_read,
+};
+
+static int nvmem_composite_validate_dt(struct device_node *np)
+{
+ /* FIXME */
+ return 0;
+}
+
+static int nvmem_composite_probe(struct platform_device *pdev)
+{
+ int i, ret;
+ unsigned int start = 0;
+ unsigned int len;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+ struct nvmem_device *nvmem;
+ struct nvmem_composite *ncomp;
+ struct regmap *map;
+ struct nvmem_composite_item *item;
+ struct nvmem_config nv_cnf = {0};
+ struct regmap_config rm_cnf = {0};
+ const __be32 *addr;
+ unsigned int item_count;
+
+ ret = nvmem_composite_validate_dt(np);
+ if (ret < 0) {
+ dev_dbg(dev, "Device validation failed\n");
+ return ret;
+ }
+
+ ncomp = devm_kzalloc(dev, sizeof(*ncomp), GFP_KERNEL);
+ INIT_LIST_HEAD(&ncomp->layout);
+ ncomp->dev = dev;
+
+ addr = of_get_property(np, "layout", &len);
+ item_count = len / (3 * sizeof(__be32));
+
+ for (i = 0; i < item_count; i++) {
+ struct device_node *cell_np;
+ uint32_t phandle;
+
+ item = devm_kzalloc(dev, sizeof(*item), GFP_KERNEL);
+
+ phandle = be32_to_cpup(addr++);
+ cell_np = of_find_node_by_phandle(phandle);
+ if (!cell_np) {
+ dev_dbg(dev,
+ "Couldn't find nvmem cell by its phandle\n");
+ return -ENOENT;
+ }
+
+ item->cell = of_nvmem_cell_from_device_node(cell_np);
+ if (IS_ERR(item->cell)) {
+ dev_dbg(dev,
+ "Failed to instantiate nvmem cell from "
+ "a device tree node\n");
+ ret = PTR_ERR(item->cell);
+ goto unwind;
+ }
+
+ item->start = start;
+ item->idx = be32_to_cpup(addr++);
+ item->size = be32_to_cpup(addr++);
+ item->end = item->size - 1;
+ ncomp->layout_size += item->size;
+ start += item->size;
+
+ list_add_tail(&item->node, &ncomp->layout);
+ }
+
+ rm_cnf.reg_bits = 32;
+ rm_cnf.val_bits = 8;
+ rm_cnf.reg_stride = 1;
+ rm_cnf.name = "nvmem-composite";
+ rm_cnf.max_register = ncomp->layout_size - 1;
+
+ map = devm_regmap_init(dev,
+ &nvmem_composite_regmap_bus,
+ ncomp,
+ &rm_cnf);
+ if (IS_ERR(map)) {
+ dev_dbg(dev, "Failed to initilize regmap\n");
+ return PTR_ERR(map);
+ }
+
+ nv_cnf.name = "nvmem-composite";
+ nv_cnf.read_only = true;
+ nv_cnf.dev = dev;
+
+ nvmem = nvmem_register(&nv_cnf);
+ if (IS_ERR(nvmem)) {
+ dev_dbg(dev, "Failed to register 'nvmem' device\n");
+ return PTR_ERR(nvmem);
+ }
+
+ platform_set_drvdata(pdev, nvmem);
+ return 0;
+unwind:
+ /* FIXME */
+ return ret;
+}
+
+static int nvmem_composite_remove(struct platform_device *pdev)
+{
+ struct nvmem_device *nvmem = platform_get_drvdata(pdev);
+
+ /*
+ FIXME free allocated nvmem cells
+ */
+ return nvmem_unregister(nvmem);
+}
+
+
+static const struct of_device_id nvmem_composite_dt_ids[] = {
+ { .compatible = "nvmem-composite", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, nvmem_composite_dt_ids);
+
+static struct platform_driver nvmem_composite_driver = {
+ .probe = nvmem_composite_probe,
+ .remove = nvmem_composite_remove,
+ .driver = {
+ .name = "nvmem-composite",
+ .of_match_table = nvmem_composite_dt_ids,
+ },
+};
+module_platform_driver(nvmem_composite_driver);
+
+MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>");
+MODULE_DESCRIPTION("FIXME");
+MODULE_LICENSE("GPL v2");
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-22 19:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-22 19:52 [RFC 0/3] Proposed extensions for NVMEM Andrey Smirnov
2016-02-22 19:52 ` [RFC 1/3] nvmem: Add 'of_nvmem_cell_from_device_node()' Andrey Smirnov
2016-02-22 19:52 ` [RFC 2/3] nvmem: Add 'nvmem-blob' driver Andrey Smirnov
2016-02-22 19:52 ` [RFC 3/3] nvmem: Add 'nvmem-composite' driver Andrey Smirnov
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 NNTP newsgroup(s).