LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH v2 00/29] at24: remove at24_platform_data
@ 2018-08-10  8:04 Bartosz Golaszewski
  2018-08-10  8:04 ` [PATCH v2 01/29] nvmem: add support for cell lookups Bartosz Golaszewski
                   ` (29 more replies)
  0 siblings, 30 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:04 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

This is a follow-up to the previously rejected series[1] which partially
removed the at24_platform_data structure. After further development and
taking reviews into account, this series finally removes that struct
completely but not without touching many different parts of the code
base.

Since I took over maintainership of the at24 driver I've been working
towards removing at24_platform_data in favor for device properties.

DaVinci is the only platform that's still using it - all other users
have already been converted.

One of the obstacles in case of DaVinci is removing the setup() callback
from the pdata struct, the only user of which are some davinci boards.

Most boards use the EEPROM to store the MAC address. This series adds
support for cell lookups to the nvmem framework, registers relevant
cells for all users, adds nvmem support to eth_platform_get_mac_address(),
converts davinci_emac driver to using it and replaces at24_platform_data
with device properties.

There's also one board (da850-evm) which uses MTD for reading the MAC
address. I used the patch from Alban Bedel's previous submission[2] to
add support for nvmem to the MTD framework. Since this user doesn't
need device tree, I dropped Alban's patches modifying the DT bindings.
We can add that later once an agreement is reached. For the time being
MTD devices are registered as nvmem devices and we're registering the
mac-address cell using the cell lookup mechanism.

This series adds a blocking notifier chain to the nvmem framework, so
that we can keep the EEPROM reading code in the mityomapl138 board file
with only slight modifications.

I also included some minor fixes to the modified code.

Tested on da850-evm & dm365-evm.

[1] https://lkml.org/lkml/2018/6/29/153
[2] https://lkml.org/lkml/2018/3/24/312

v1 -> v2:

  PATCH 4/29:
  - change name to nvmem_dev_name()
  - return NULL instead of ERR_PTR(-ENOSYS) from nvmem_dev_name() if nvmem is
    not configured

  PATCH 5/29:
  - s/nvmem_device_name/nvmem_dev_name/

  PATCH 6/29:
  - fix the commit message: remove the part mentioning the OF systems

  PATCH 7/29:
  - fix ordering of includes

  PATCH 8/29:
  - fix ordering of includes

  PATCH 9/29:
  - fix ordering of includes

  PATCH 10/29:
  - fix ordering of includes

  PATCH 11/29:
  - fix ordering of includes

  PATCH 14/29:
  - new patch

  PATCH 22/29:
  - added missing terminator

  PATCH 25/29:
  - removed unneeded coma

  PATCH 27/29:
  - s/nvmem_device_name/nvmem_dev_name/
  - fix ordering of includes

  PATCH 28/29:
  - added missing terminator

Alban Bedel (1):
  mtd: Add support for reading MTD devices via the nvmem API

Bartosz Golaszewski (28):
  nvmem: add support for cell lookups
  Documentation: nvmem: document lookup entries
  nvmem: add a notifier chain
  nvmem: provide nvmem_dev_name()
  nvmem: remove the name field from struct nvmem_device
  ARM: davinci: dm365-evm: use nvmem lookup for mac address
  ARM: davinci: dm644-evm: use nvmem lookup for mac address
  ARM: davinci: dm646x-evm: use nvmem lookup for mac address
  ARM: davinci: da830-evm: use nvmem lookup for mac address
  ARM: davinci: mityomapl138: add nvmem cells lookup entries
  ARM: davinci: da850-evm: use nvmem lookup for mac address
  ARM: davinci: da850-evm: remove unnecessary include
  net: simplify eth_platform_get_mac_address()
  net: split eth_platform_get_mac_address() into subroutines
  net: add support for nvmem to eth_platform_get_mac_address()
  net: davinci_emac: use eth_platform_get_mac_address()
  ARM: davinci: da850-evm: remove dead MTD code
  ARM: davinci: mityomapl138: don't read the MAC address from machine
    code
  ARM: davinci: dm365-evm: use device properties for at24 eeprom
  ARM: davinci: da830-evm: use device properties for at24 eeprom
  ARM: davinci: dm644x-evm: use device properties for at24 eeprom
  ARM: davinci: dm646x-evm: use device properties for at24 eeprom
  ARM: davinci: sffsdr: fix the at24 eeprom device name
  ARM: davinci: sffsdr: use device properties for at24 eeprom
  ARM: davinci: remove dead code related to MAC address reading
  ARM: davinci: mityomapl138: use nvmem notifiers
  ARM: davinci: mityomapl138: use device properties for at24 eeprom
  eeprom: at24: kill at24_platform_data

 Documentation/nvmem/nvmem.txt              |  28 +++++
 MAINTAINERS                                |   1 -
 arch/arm/mach-davinci/board-da830-evm.c    |  25 ++--
 arch/arm/mach-davinci/board-da850-evm.c    |  45 +++-----
 arch/arm/mach-davinci/board-dm365-evm.c    |  25 ++--
 arch/arm/mach-davinci/board-dm644x-evm.c   |  25 ++--
 arch/arm/mach-davinci/board-dm646x-evm.c   |  25 ++--
 arch/arm/mach-davinci/board-mityomapl138.c |  60 +++++++---
 arch/arm/mach-davinci/board-sffsdr.c       |  13 +--
 arch/arm/mach-davinci/common.c             |  15 ---
 drivers/misc/eeprom/at24.c                 | 127 +++++++++------------
 drivers/mtd/Kconfig                        |   1 +
 drivers/mtd/mtdcore.c                      |  50 ++++++++
 drivers/net/ethernet/ti/davinci_emac.c     |  12 +-
 drivers/nvmem/core.c                       | 106 ++++++++++++++++-
 include/linux/davinci_emac.h               |   2 -
 include/linux/mtd/mtd.h                    |   2 +
 include/linux/nvmem-consumer.h             |  31 +++++
 include/linux/nvmem-provider.h             |  10 ++
 include/linux/platform_data/at24.h         |  60 ----------
 net/ethernet/eth.c                         |  84 ++++++++++++--
 21 files changed, 492 insertions(+), 255 deletions(-)
 delete mode 100644 include/linux/platform_data/at24.h

-- 
2.18.0


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

* [PATCH v2 01/29] nvmem: add support for cell lookups
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
@ 2018-08-10  8:04 ` Bartosz Golaszewski
  2018-08-10  8:04 ` [PATCH v2 02/29] Documentation: nvmem: document lookup entries Bartosz Golaszewski
                   ` (28 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:04 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We can currently only register nvmem cells from device tree or by
manually calling nvmem_add_cells(). The latter options however forces
users to make sure that the nvmem provider with which the cells are
associated is registered before the call.

This patch proposes a new solution inspired by other frameworks that
offer resource lookups (GPIO, PWM etc.). It adds functions that allow
machine code to register nvmem lookup which are later lazily used to
add corresponding nvmem cells and remove them if no longer needed.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c           | 77 +++++++++++++++++++++++++++++++++-
 include/linux/nvmem-consumer.h |  6 +++
 include/linux/nvmem-provider.h | 10 +++++
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 514d1dfc5630..329ea5b8f809 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -62,6 +62,9 @@ static DEFINE_IDA(nvmem_ida);
 static LIST_HEAD(nvmem_cells);
 static DEFINE_MUTEX(nvmem_cells_mutex);
 
+static LIST_HEAD(nvmem_cell_lookups);
+static DEFINE_MUTEX(nvmem_lookup_mutex);
+
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 static struct lock_class_key eeprom_lock_key;
 #endif
@@ -247,6 +250,41 @@ static const struct attribute_group *nvmem_ro_root_dev_groups[] = {
 	NULL,
 };
 
+/**
+ * nvmem_add_lookup_table() - register a number of nvmem cell lookup entries
+ *
+ * @lookup: array of nvmem cell lookup entries
+ * @nentries: number of lookup entries in the array
+ */
+void nvmem_add_lookup_table(struct nvmem_cell_lookup *lookup, size_t nentries)
+{
+	int i;
+
+	mutex_lock(&nvmem_lookup_mutex);
+	for (i = 0; i < nentries; i++)
+		list_add_tail(&lookup[i].list, &nvmem_cell_lookups);
+	mutex_unlock(&nvmem_lookup_mutex);
+}
+EXPORT_SYMBOL_GPL(nvmem_add_lookup_table);
+
+/**
+ * nvmem_del_lookup_table() - unregister a set of previously added nvmem cell
+ *                            lookup entries
+ *
+ * @lookup: array of nvmem cell lookup entries
+ * @nentries: number of lookup entries in the array
+ */
+void nvmem_del_lookup_table(struct nvmem_cell_lookup *lookup, size_t nentries)
+{
+	int i;
+
+	mutex_lock(&nvmem_lookup_mutex);
+	for (i = 0; i < nentries; i++)
+		list_del(&lookup[i].list);
+	mutex_unlock(&nvmem_lookup_mutex);
+}
+EXPORT_SYMBOL_GPL(nvmem_del_lookup_table);
+
 static void nvmem_release(struct device *dev)
 {
 	struct nvmem_device *nvmem = to_nvmem_device(dev);
@@ -916,6 +954,39 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
 EXPORT_SYMBOL_GPL(of_nvmem_cell_get);
 #endif
 
+static struct nvmem_cell *nvmem_cell_from_lookup(const char *cell_id)
+{
+	struct nvmem_cell *cell = ERR_PTR(-ENOENT);
+	struct nvmem_cell_lookup *lookup;
+	struct nvmem_device *nvmem;
+	int rc;
+
+	mutex_lock(&nvmem_lookup_mutex);
+
+	list_for_each_entry(lookup, &nvmem_cell_lookups, list) {
+		if (strcmp(cell_id, lookup->info.name) == 0) {
+			nvmem = nvmem_find(lookup->nvmem_name);
+			if (!nvmem) {
+				cell = ERR_PTR(-EPROBE_DEFER);
+				goto out;
+			}
+
+			rc = nvmem_add_cells(nvmem, &lookup->info, 1);
+			if (rc) {
+				cell = ERR_PTR(rc);
+				goto out;
+			}
+
+			cell = nvmem_cell_get_from_list(cell_id);
+			break;
+		}
+	}
+
+out:
+	mutex_unlock(&nvmem_lookup_mutex);
+	return cell;
+}
+
 /**
  * nvmem_cell_get() - Get nvmem cell of device form a given cell name
  *
@@ -940,7 +1011,11 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id)
 	if (!cell_id)
 		return ERR_PTR(-EINVAL);
 
-	return nvmem_cell_get_from_list(cell_id);
+	cell = nvmem_cell_get_from_list(cell_id);
+	if (!IS_ERR(cell) || PTR_ERR(cell) == -EPROBE_DEFER)
+		return cell;
+
+	return nvmem_cell_from_lookup(cell_id);
 }
 EXPORT_SYMBOL_GPL(nvmem_cell_get);
 
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index 4e85447f7860..f4b5d3186e94 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -29,6 +29,12 @@ struct nvmem_cell_info {
 	unsigned int		nbits;
 };
 
+struct nvmem_cell_lookup {
+	struct nvmem_cell_info	info;
+	struct list_head	list;
+	const char		*nvmem_name;
+};
+
 #if IS_ENABLED(CONFIG_NVMEM)
 
 /* Cell based interface */
diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h
index 24def6ad09bb..6a17d722062b 100644
--- a/include/linux/nvmem-provider.h
+++ b/include/linux/nvmem-provider.h
@@ -17,6 +17,7 @@
 
 struct nvmem_device;
 struct nvmem_cell_info;
+struct nvmem_cell_lookup;
 typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset,
 				void *val, size_t bytes);
 typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset,
@@ -72,6 +73,9 @@ struct nvmem_config {
 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
 int nvmem_unregister(struct nvmem_device *nvmem);
 
+void nvmem_add_lookup_table(struct nvmem_cell_lookup *lookup, size_t nentries);
+void nvmem_del_lookup_table(struct nvmem_cell_lookup *lookup, size_t nentries);
+
 struct nvmem_device *devm_nvmem_register(struct device *dev,
 					 const struct nvmem_config *cfg);
 
@@ -92,6 +96,12 @@ static inline int nvmem_unregister(struct nvmem_device *nvmem)
 	return -ENOSYS;
 }
 
+static inline void
+nvmem_add_lookup_table(struct nvmem_cell_lookup *lookup, size_t nentries) {}
+
+static inline void
+nvmem_del_lookup_table(struct nvmem_cell_lookup *lookup, size_t nentries) {}
+
 static inline struct nvmem_device *
 devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
 {
-- 
2.18.0


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

* [PATCH v2 02/29] Documentation: nvmem: document lookup entries
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
  2018-08-10  8:04 ` [PATCH v2 01/29] nvmem: add support for cell lookups Bartosz Golaszewski
@ 2018-08-10  8:04 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 03/29] nvmem: add a notifier chain Bartosz Golaszewski
                   ` (27 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:04 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Describe the usage of nvmem cell lookup tables.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 Documentation/nvmem/nvmem.txt | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/Documentation/nvmem/nvmem.txt b/Documentation/nvmem/nvmem.txt
index 8d8d8f58f96f..9d5e3ca2b4f3 100644
--- a/Documentation/nvmem/nvmem.txt
+++ b/Documentation/nvmem/nvmem.txt
@@ -58,6 +58,34 @@ static int qfprom_probe(struct platform_device *pdev)
 It is mandatory that the NVMEM provider has a regmap associated with its
 struct device. Failure to do would return error code from nvmem_register().
 
+Additionally it is possible to create nvmem cell lookup entries and register
+them with the nvmem framework from machine code as shown in the example below:
+
+static struct nvmem_cell_lookup foobar_lookup = {
+	.info = {
+		.name = "mac-address",
+		.offset = 0xd000,
+		.bytes = ERH_ALEN,
+	},
+	.nvmem_name = "foobar",
+};
+
+static void foobar_register(void)
+{
+	...
+	nvmem_add_lookup_table(&foobar_lookup, 1);
+	...
+}
+
+A lookup entry table can be later removed if needed:
+
+static void foobar_fini(void)
+{
+	...
+	nvmem_del_lookup_table(&foobar_lookup, 1);
+	...
+}
+
 NVMEM Consumers
 +++++++++++++++
 
-- 
2.18.0


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

* [PATCH v2 03/29] nvmem: add a notifier chain
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
  2018-08-10  8:04 ` [PATCH v2 01/29] nvmem: add support for cell lookups Bartosz Golaszewski
  2018-08-10  8:04 ` [PATCH v2 02/29] Documentation: nvmem: document lookup entries Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:33   ` Srinivas Kandagatla
  2018-08-10  8:05 ` [PATCH v2 04/29] nvmem: provide nvmem_dev_name() Bartosz Golaszewski
                   ` (26 subsequent siblings)
  29 siblings, 1 reply; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Add a blocking notifier chain with two events (add and remove) so that
users can get notified about the addition of nvmem devices they're
waiting for.

We'll use this instead of the at24 setup callback in the mityomapl138
board file.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/nvmem/core.c           | 20 ++++++++++++++++++++
 include/linux/nvmem-consumer.h | 18 ++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 329ea5b8f809..128c8e51bff2 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -65,6 +65,8 @@ static DEFINE_MUTEX(nvmem_cells_mutex);
 static LIST_HEAD(nvmem_cell_lookups);
 static DEFINE_MUTEX(nvmem_lookup_mutex);
 
+static BLOCKING_NOTIFIER_HEAD(nvmem_notifier);
+
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
 static struct lock_class_key eeprom_lock_key;
 #endif
@@ -479,6 +481,18 @@ static int nvmem_setup_compat(struct nvmem_device *nvmem,
 	return 0;
 }
 
+int nvmem_register_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&nvmem_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(nvmem_register_notifier);
+
+int nvmem_unregister_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&nvmem_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(nvmem_unregister_notifier);
+
 /**
  * nvmem_register() - Register a nvmem device for given nvmem_config.
  * Also creates an binary entry in /sys/bus/nvmem/devices/dev-name/nvmem
@@ -559,6 +573,10 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	if (config->cells)
 		nvmem_add_cells(nvmem, config->cells, config->ncells);
 
+	rval = blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem);
+	if (rval)
+		goto err_device_del;
+
 	return nvmem;
 
 err_device_del:
@@ -586,6 +604,8 @@ int nvmem_unregister(struct nvmem_device *nvmem)
 	}
 	mutex_unlock(&nvmem_mutex);
 
+	blocking_notifier_call_chain(&nvmem_notifier, NVMEM_REMOVE, nvmem);
+
 	if (nvmem->flags & FLAG_COMPAT)
 		device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
 
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index f4b5d3186e94..ae4d30347602 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -14,6 +14,7 @@
 
 #include <linux/err.h>
 #include <linux/errno.h>
+#include <linux/notifier.h>
 
 struct device;
 struct device_node;
@@ -35,6 +36,11 @@ struct nvmem_cell_lookup {
 	const char		*nvmem_name;
 };
 
+enum {
+	NVMEM_ADD = 1,
+	NVMEM_REMOVE,
+};
+
 #if IS_ENABLED(CONFIG_NVMEM)
 
 /* Cell based interface */
@@ -61,6 +67,8 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
 int nvmem_device_cell_write(struct nvmem_device *nvmem,
 			    struct nvmem_cell_info *info, void *buf);
 
+int nvmem_register_notifier(struct notifier_block *nb);
+int nvmem_unregister_notifier(struct notifier_block *nb);
 #else
 
 static inline struct nvmem_cell *nvmem_cell_get(struct device *dev,
@@ -149,6 +157,16 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,
 {
 	return -ENOSYS;
 }
+
+static inline int nvmem_register_notifier(struct notifier_block *nb)
+{
+	return -ENOSYS;
+}
+
+static inline int int nvmem_unregister_notifier(struct notifier_block *nb)
+{
+	return -ENOSYS;
+}
 #endif /* CONFIG_NVMEM */
 
 #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
-- 
2.18.0


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

* [PATCH v2 04/29] nvmem: provide nvmem_dev_name()
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 03/29] nvmem: add a notifier chain Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:10   ` Srinivas Kandagatla
  2018-08-10  8:05 ` [PATCH v2 05/29] nvmem: remove the name field from struct nvmem_device Bartosz Golaszewski
                   ` (25 subsequent siblings)
  29 siblings, 1 reply; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Kernel users don't have any means of checking the names of nvmem
devices. Add a routine that returns the name of the nvmem provider.

This will be useful for nvmem notifier subscribers - otherwise they
can't check what device is being added/removed.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/nvmem/core.c           | 6 ++++++
 include/linux/nvmem-consumer.h | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 128c8e51bff2..31df2e6d6f72 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1440,6 +1440,12 @@ int nvmem_device_write(struct nvmem_device *nvmem,
 }
 EXPORT_SYMBOL_GPL(nvmem_device_write);
 
+const char *nvmem_dev_name(struct nvmem_device *nvmem)
+{
+	return dev_name(&nvmem->dev);
+}
+EXPORT_SYMBOL_GPL(nvmem_dev_name);
+
 static int __init nvmem_init(void)
 {
 	return bus_register(&nvmem_bus_type);
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index ae4d30347602..14bb86a7a78d 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -69,6 +69,8 @@ int nvmem_device_cell_write(struct nvmem_device *nvmem,
 
 int nvmem_register_notifier(struct notifier_block *nb);
 int nvmem_unregister_notifier(struct notifier_block *nb);
+
+const char *nvmem_dev_name(struct nvmem_device *nvmem);
 #else
 
 static inline struct nvmem_cell *nvmem_cell_get(struct device *dev,
@@ -167,6 +169,11 @@ static inline int int nvmem_unregister_notifier(struct notifier_block *nb)
 {
 	return -ENOSYS;
 }
+
+static inline const char *nvmem_dev_name(struct nvmem_device *nvmem)
+{
+	return NULL;
+}
 #endif /* CONFIG_NVMEM */
 
 #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
-- 
2.18.0


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

* [PATCH v2 05/29] nvmem: remove the name field from struct nvmem_device
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 04/29] nvmem: provide nvmem_dev_name() Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:33   ` Srinivas Kandagatla
  2018-08-10  8:05 ` [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API Bartosz Golaszewski
                   ` (24 subsequent siblings)
  29 siblings, 1 reply; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

This field is never set and is only used in a single error message.
Remove the field and use nvmem_dev_name() instead.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/nvmem/core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 31df2e6d6f72..ab3ced2d9a84 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -26,7 +26,6 @@
 #include <linux/slab.h>
 
 struct nvmem_device {
-	const char		*name;
 	struct module		*owner;
 	struct device		dev;
 	int			stride;
@@ -712,7 +711,7 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np,
 	if (!try_module_get(nvmem->owner)) {
 		dev_err(&nvmem->dev,
 			"could not increase module refcount for cell %s\n",
-			nvmem->name);
+			nvmem_dev_name(nvmem));
 
 		mutex_lock(&nvmem_mutex);
 		nvmem->users--;
-- 
2.18.0


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

* [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 05/29] nvmem: remove the name field from struct nvmem_device Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-17 16:27   ` Boris Brezillon
  2018-08-10  8:05 ` [PATCH v2 07/29] ARM: davinci: dm365-evm: use nvmem lookup for mac address Bartosz Golaszewski
                   ` (23 subsequent siblings)
  29 siblings, 1 reply; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Alban Bedel <albeu@free.fr>

Allow drivers that use the nvmem API to read data stored on MTD devices.
For this the mtd devices are registered as read-only NVMEM providers.

Signed-off-by: Alban Bedel <albeu@free.fr>
[Bartosz:
  - use the managed variant of nvmem_register(),
  - set the nvmem name]
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/mtd/Kconfig     |  1 +
 drivers/mtd/mtdcore.c   | 50 +++++++++++++++++++++++++++++++++++++++++
 include/linux/mtd/mtd.h |  2 ++
 3 files changed, 53 insertions(+)

diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 46ab7feec6b6..f5549482d0df 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -1,5 +1,6 @@
 menuconfig MTD
 	tristate "Memory Technology Device (MTD) support"
+	imply NVMEM
 	help
 	  Memory Technology Devices are flash, RAM and similar chips, often
 	  used for solid state file systems on embedded devices. This option
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 42395df06be9..a57302eaceb5 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -488,6 +488,49 @@ int mtd_pairing_groups(struct mtd_info *mtd)
 }
 EXPORT_SYMBOL_GPL(mtd_pairing_groups);
 
+static int mtd_nvmem_reg_read(void *priv, unsigned int offset,
+			      void *val, size_t bytes)
+{
+	struct mtd_info *mtd = priv;
+	size_t retlen;
+	int err;
+
+	err = mtd_read(mtd, offset, bytes, &retlen, val);
+	if (err && err != -EUCLEAN)
+		return err;
+
+	return retlen == bytes ? 0 : -EIO;
+}
+
+static int mtd_nvmem_add(struct mtd_info *mtd)
+{
+	struct nvmem_config config = { };
+
+	config.dev = &mtd->dev;
+	config.owner = THIS_MODULE;
+	config.name = mtd->name;
+	config.reg_read = mtd_nvmem_reg_read;
+	config.size = mtd->size;
+	config.word_size = 1;
+	config.stride = 1;
+	config.read_only = true;
+	config.root_only = true;
+	config.priv = mtd;
+
+	mtd->nvmem = devm_nvmem_register(&mtd->dev, &config);
+	if (IS_ERR(mtd->nvmem)) {
+		/* Just ignore if there is no NVMEM support in the kernel */
+		if (PTR_ERR(mtd->nvmem) == -ENOSYS) {
+			mtd->nvmem = NULL;
+		} else {
+			dev_err(&mtd->dev, "Failed to register NVMEM device\n");
+			return PTR_ERR(mtd->nvmem);
+		}
+	}
+
+	return 0;
+}
+
 static struct dentry *dfs_dir_mtd;
 
 /**
@@ -570,6 +613,11 @@ int add_mtd_device(struct mtd_info *mtd)
 	if (error)
 		goto fail_added;
 
+	/* Add the nvmem provider */
+	error = mtd_nvmem_add(mtd);
+	if (error)
+		goto fail_nvmem_add;
+
 	if (!IS_ERR_OR_NULL(dfs_dir_mtd)) {
 		mtd->dbg.dfs_dir = debugfs_create_dir(dev_name(&mtd->dev), dfs_dir_mtd);
 		if (IS_ERR_OR_NULL(mtd->dbg.dfs_dir)) {
@@ -595,6 +643,8 @@ int add_mtd_device(struct mtd_info *mtd)
 	__module_get(THIS_MODULE);
 	return 0;
 
+fail_nvmem_add:
+	device_unregister(&mtd->dev);
 fail_added:
 	of_node_put(mtd_get_of_node(mtd));
 	idr_remove(&mtd_idr, i);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index a86c4fa93115..8121c6582285 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -25,6 +25,7 @@
 #include <linux/notifier.h>
 #include <linux/device.h>
 #include <linux/of.h>
+#include <linux/nvmem-provider.h>
 
 #include <mtd/mtd-abi.h>
 
@@ -339,6 +340,7 @@ struct mtd_info {
 	struct device dev;
 	int usecount;
 	struct mtd_debug_info dbg;
+	struct nvmem_device *nvmem;
 };
 
 int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,
-- 
2.18.0


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

* [PATCH v2 07/29] ARM: davinci: dm365-evm: use nvmem lookup for mac address
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 08/29] ARM: davinci: dm644-evm: " Bartosz Golaszewski
                   ` (22 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now support nvmem lookups for machine code. Add a lookup for
mac-address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-dm365-evm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 435f7ec7d9af..cf3f2e611228 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -22,6 +22,7 @@
 #include <linux/leds.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/nvmem-provider.h>
 #include <linux/slab.h>
 #include <linux/mtd/rawnand.h>
 #include <linux/input.h>
@@ -169,6 +170,15 @@ static struct platform_device davinci_nand_device = {
 	},
 };
 
+static struct nvmem_cell_lookup dm365evm_mac_address_cell = {
+	.info = {
+		.name = "mac-address",
+		.offset = 0x7f00,
+		.bytes = ETH_ALEN,
+	},
+	.nvmem_name = "1-00500",
+};
+
 static struct at24_platform_data eeprom_info = {
 	.byte_len       = (256*1024) / 8,
 	.page_size      = 64,
@@ -769,6 +779,8 @@ static __init void dm365_evm_init(void)
 
 	dm365_init_spi0(BIT(0), dm365_evm_spi_info,
 			ARRAY_SIZE(dm365_evm_spi_info));
+
+	nvmem_add_lookup_table(&dm365evm_mac_address_cell, 1);
 }
 
 MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM")
-- 
2.18.0


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

* [PATCH v2 08/29] ARM: davinci: dm644-evm: use nvmem lookup for mac address
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (6 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 07/29] ARM: davinci: dm365-evm: use nvmem lookup for mac address Bartosz Golaszewski
@ 2018-08-10  8:05 ` " Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 09/29] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
                   ` (21 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now support nvmem lookups for machine code. Add a lookup for
mac-address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-dm644x-evm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 48436f74fd71..829fa1c8d0b4 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -22,6 +22,7 @@
 #include <linux/mtd/rawnand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
+#include <linux/nvmem-provider.h>
 #include <linux/phy.h>
 #include <linux/clk.h>
 #include <linux/videodev2.h>
@@ -476,6 +477,15 @@ static struct pcf857x_platform_data pcf_data_u35 = {
  *  - ... newer boards may have more
  */
 
+static struct nvmem_cell_lookup dm6446evm_mac_address_cell = {
+	.info = {
+		.name = "mac-address",
+		.offset = 0x7f00,
+		.bytes = ETH_ALEN,
+	},
+	.nvmem_name = "1-00500",
+};
+
 static struct at24_platform_data eeprom_info = {
 	.byte_len	= (256*1024) / 8,
 	.page_size	= 64,
@@ -828,6 +838,8 @@ static __init void davinci_evm_init(void)
 		phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
 						davinci_phy_fixup);
 	}
+
+	nvmem_add_lookup_table(&dm6446evm_mac_address_cell, 1);
 }
 
 MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")
-- 
2.18.0


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

* [PATCH v2 09/29] ARM: davinci: dm646x-evm: use nvmem lookup for mac address
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (7 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 08/29] ARM: davinci: dm644-evm: " Bartosz Golaszewski
@ 2018-08-10  8:05 ` " Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 10/29] ARM: davinci: da830-evm: " Bartosz Golaszewski
                   ` (20 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now support nvmem lookups for machine code. Add a lookup for
mac-address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-dm646x-evm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 584064fdabf5..943ab0ca6db8 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -31,6 +31,7 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/rawnand.h>
 #include <linux/mtd/partitions.h>
+#include <linux/nvmem-provider.h>
 #include <linux/clk.h>
 #include <linux/export.h>
 #include <linux/platform_data/gpio-davinci.h>
@@ -310,6 +311,15 @@ static struct pcf857x_platform_data pcf_data = {
  *  - ... newer boards may have more
  */
 
+static struct nvmem_cell_lookup dm646x_evm_mac_address_cell = {
+	.info = {
+		.name = "mac-address",
+		.offset = 0x7f00,
+		.bytes = ETH_ALEN,
+	},
+	.nvmem_name = "1-00500",
+};
+
 static struct at24_platform_data eeprom_info = {
 	.byte_len       = (256*1024) / 8,
 	.page_size      = 64,
@@ -802,6 +812,8 @@ static __init void evm_init(void)
 		davinci_init_ide();
 
 	soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID;
+
+	nvmem_add_lookup_table(&dm646x_evm_mac_address_cell, 1);
 }
 
 MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM")
-- 
2.18.0


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

* [PATCH v2 10/29] ARM: davinci: da830-evm: use nvmem lookup for mac address
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (8 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 09/29] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
@ 2018-08-10  8:05 ` " Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 11/29] ARM: davinci: mityomapl138: add nvmem cells lookup entries Bartosz Golaszewski
                   ` (19 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now support nvmem lookups for machine code. Add a lookup for
mac-address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-da830-evm.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index 14a6fc061744..9a055ebba081 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -21,6 +21,7 @@
 #include <linux/platform_data/at24.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/nvmem-provider.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 #include <linux/platform_data/gpio-davinci.h>
@@ -409,6 +410,15 @@ static inline void da830_evm_init_lcdc(int mux_mode)
 static inline void da830_evm_init_lcdc(int mux_mode) { }
 #endif
 
+static struct nvmem_cell_lookup da830_evm_mac_address_cell = {
+	.info = {
+		.name = "mac-address",
+		.offset = 0x7f00,
+		.bytes = ETH_ALEN,
+	},
+	.nvmem_name = "1-00500",
+};
+
 static struct at24_platform_data da830_evm_i2c_eeprom_info = {
 	.byte_len	= SZ_256K / 8,
 	.page_size	= 64,
@@ -618,6 +628,8 @@ static __init void da830_evm_init(void)
 		pr_warn("%s: spi 0 registration failed: %d\n", __func__, ret);
 
 	regulator_has_full_constraints();
+
+	nvmem_add_lookup_table(&da830_evm_mac_address_cell, 1);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
-- 
2.18.0


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

* [PATCH v2 11/29] ARM: davinci: mityomapl138: add nvmem cells lookup entries
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (9 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 10/29] ARM: davinci: da830-evm: " Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 12/29] ARM: davinci: da850-evm: use nvmem lookup for mac address Bartosz Golaszewski
                   ` (18 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now support nvmem lookups for machine code. Add a lookup for
mac-address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-mityomapl138.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index 37b3e48a21d1..48a9bae76e4a 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -15,6 +15,7 @@
 #include <linux/console.h>
 #include <linux/platform_device.h>
 #include <linux/mtd/partitions.h>
+#include <linux/nvmem-provider.h>
 #include <linux/regulator/machine.h>
 #include <linux/i2c.h>
 #include <linux/platform_data/at24.h>
@@ -160,6 +161,25 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context)
 	mityomapl138_cpufreq_init(partnum);
 }
 
+static struct nvmem_cell_lookup mityomapl138_nvmem_cells[] = {
+	{
+		.info = {
+			.name = "factory-config",
+			.offset = 0x0,
+			.bytes = sizeof(struct factory_config),
+		},
+		.nvmem_name = "1-00500",
+	},
+	{
+		.info = {
+			.name = "mac-address",
+			.offset = 0x64,
+			.bytes = ETH_ALEN,
+		},
+		.nvmem_name = "1-00500",
+	}
+};
+
 static struct at24_platform_data mityomapl138_fd_chip = {
 	.byte_len	= 256,
 	.page_size	= 8,
@@ -534,6 +554,8 @@ static void __init mityomapl138_init(void)
 	if (ret)
 		pr_warn("spi 1 registration failed: %d\n", ret);
 
+	nvmem_add_lookup_table(mityomapl138_nvmem_cells,
+			       ARRAY_SIZE(mityomapl138_nvmem_cells));
 	mityomapl138_config_emac();
 
 	ret = da8xx_register_rtc();
-- 
2.18.0


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

* [PATCH v2 12/29] ARM: davinci: da850-evm: use nvmem lookup for mac address
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (10 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 11/29] ARM: davinci: mityomapl138: add nvmem cells lookup entries Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 13/29] ARM: davinci: da850-evm: remove unnecessary include Bartosz Golaszewski
                   ` (17 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now support nvmem lookups for machine code. Add a lookup for
mac-address.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-da850-evm.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 6d5beb11bd96..5a634a04ec69 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -29,6 +29,7 @@
 #include <linux/mtd/rawnand.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/physmap.h>
+#include <linux/nvmem-provider.h>
 #include <linux/platform_device.h>
 #include <linux/platform_data/gpio-davinci.h>
 #include <linux/platform_data/mtd-davinci.h>
@@ -99,6 +100,19 @@ static struct mtd_partition da850evm_spiflash_part[] = {
 	},
 };
 
+static struct nvmem_cell_lookup da850evm_mac_address_cell = {
+	.info = {
+		.name = "mac-address",
+		.offset = 0x0,
+		.bytes = ETH_ALEN,
+	},
+	/*
+	 * The nvmem name differs from the partition name because of the
+	 * internal works of the nvmem framework.
+	 */
+	.nvmem_name = "MAC-Address0",
+};
+
 static struct flash_platform_data da850evm_spiflash_data = {
 	.name		= "m25p80",
 	.parts		= da850evm_spiflash_part,
@@ -1447,6 +1461,8 @@ static __init void da850_evm_init(void)
 		pr_warn("%s: spi info registration failed: %d\n", __func__,
 			ret);
 
+	nvmem_add_lookup_table(&da850evm_mac_address_cell, 1);
+
 	ret = da8xx_register_spi_bus(1, ARRAY_SIZE(da850evm_spi_info));
 	if (ret)
 		pr_warn("%s: SPI 1 registration failed: %d\n", __func__, ret);
-- 
2.18.0


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

* [PATCH v2 13/29] ARM: davinci: da850-evm: remove unnecessary include
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (11 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 12/29] ARM: davinci: da850-evm: use nvmem lookup for mac address Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 14/29] net: simplify eth_platform_get_mac_address() Bartosz Golaszewski
                   ` (16 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

The include file for at24_platform_data is not needed in this file.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-da850-evm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 5a634a04ec69..521a26b5c20d 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -20,7 +20,6 @@
 #include <linux/kernel.h>
 #include <linux/leds.h>
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
 #include <linux/platform_data/pca953x.h>
 #include <linux/input.h>
 #include <linux/input/tps6507x-ts.h>
-- 
2.18.0


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

* [PATCH v2 14/29] net: simplify eth_platform_get_mac_address()
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (12 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 13/29] ARM: davinci: da850-evm: remove unnecessary include Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10 14:39   ` Andy Shevchenko
  2018-08-10  8:05 ` [PATCH v2 15/29] net: split eth_platform_get_mac_address() into subroutines Bartosz Golaszewski
                   ` (15 subsequent siblings)
  29 siblings, 1 reply; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We don't need to use pci_device_to_OF_node() - we can retrieve
dev->of_node directly even for pci devices.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 net/ethernet/eth.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index ee28440f57c5..7f08105402c8 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -530,11 +530,7 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
 	const unsigned char *addr;
 	struct device_node *dp;
 
-	if (dev_is_pci(dev))
-		dp = pci_device_to_OF_node(to_pci_dev(dev));
-	else
-		dp = dev->of_node;
-
+	dp = dev->of_node;
 	addr = NULL;
 	if (dp)
 		addr = of_get_mac_address(dp);
-- 
2.18.0


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

* [PATCH v2 15/29] net: split eth_platform_get_mac_address() into subroutines
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (13 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 14/29] net: simplify eth_platform_get_mac_address() Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 16/29] net: add support for nvmem to eth_platform_get_mac_address() Bartosz Golaszewski
                   ` (14 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We want do add more sources from which to read the MAC address. In
order to avoid bloating this function too much, start by splitting it
into subroutines, each of which takes care of reading the MAC from
one source.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 net/ethernet/eth.c | 44 ++++++++++++++++++++++++++++++++++++--------
 1 file changed, 36 insertions(+), 8 deletions(-)

diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 7f08105402c8..d01dd55de037 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -525,22 +525,50 @@ unsigned char * __weak arch_get_platform_mac_address(void)
 	return NULL;
 }
 
-int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
+static int mac_address_from_of(struct device *dev, u8 *mac_addr)
 {
 	const unsigned char *addr;
-	struct device_node *dp;
+	struct device_node *np;
 
-	dp = dev->of_node;
-	addr = NULL;
-	if (dp)
-		addr = of_get_mac_address(dp);
-	if (!addr)
-		addr = arch_get_platform_mac_address();
+	np = dev->of_node;
+	if (!np)
+		return -ENODEV;
 
+	addr = of_get_mac_address(np);
 	if (!addr)
 		return -ENODEV;
 
+	if (!addr || !is_valid_ether_addr(addr))
+		return -ENODEV;
+
 	ether_addr_copy(mac_addr, addr);
 	return 0;
 }
+
+static int mac_address_from_arch(u8 *mac_addr)
+{
+	const unsigned char *addr;
+
+	addr = arch_get_platform_mac_address();
+	if (!addr || !is_valid_ether_addr(addr))
+		return -ENODEV;
+
+	ether_addr_copy(mac_addr, addr);
+	return 0;
+}
+
+int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
+{
+	int rv;
+
+	rv = mac_address_from_of(dev, mac_addr);
+	if (!rv)
+		return 0;
+
+	rv = mac_address_from_arch(mac_addr);
+	if (!rv)
+		return 0;
+
+	return -ENODEV;
+}
 EXPORT_SYMBOL(eth_platform_get_mac_address);
-- 
2.18.0


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

* [PATCH v2 16/29] net: add support for nvmem to eth_platform_get_mac_address()
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (14 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 15/29] net: split eth_platform_get_mac_address() into subroutines Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 17/29] net: davinci_emac: use eth_platform_get_mac_address() Bartosz Golaszewski
                   ` (13 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Many non-DT platforms read the MAC address from EEPROM. Usually it's
either done with callbacks defined in board files or from SoC-specific
ethernet drivers.

In order to generalize this, try to read the MAC from nvmem in
eth_platform_get_mac_address() using a standard lookup name:
"mac-address".

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 net/ethernet/eth.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index d01dd55de037..f6f6af05fb58 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -54,6 +54,7 @@
 #include <linux/if_ether.h>
 #include <linux/of_net.h>
 #include <linux/pci.h>
+#include <linux/nvmem-consumer.h>
 #include <net/dst.h>
 #include <net/arp.h>
 #include <net/sock.h>
@@ -557,6 +558,39 @@ static int mac_address_from_arch(u8 *mac_addr)
 	return 0;
 }
 
+static int mac_address_from_nvmem(struct device *dev, u8 *mac_addr)
+{
+	const unsigned char *addr;
+	struct nvmem_cell *cell;
+	size_t alen;
+	int rv = 0;
+
+	cell = nvmem_cell_get(dev, "mac-address");
+	if (IS_ERR(cell))
+		return PTR_ERR(cell);
+
+	addr = nvmem_cell_read(cell, &alen);
+	if (IS_ERR(addr)) {
+		rv = PTR_ERR(addr);
+		goto put_nvmem;
+	}
+
+	if (alen != ETH_ALEN || !is_valid_ether_addr(addr)) {
+		rv = -ENODEV;
+		goto free_addr;
+	}
+
+	ether_addr_copy(mac_addr, addr);
+
+free_addr:
+	kfree(addr);
+
+put_nvmem:
+	nvmem_cell_put(cell);
+
+	return rv;
+}
+
 int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
 {
 	int rv;
@@ -569,6 +603,10 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr)
 	if (!rv)
 		return 0;
 
+	rv = mac_address_from_nvmem(dev, mac_addr);
+	if (!rv)
+		return 0;
+
 	return -ENODEV;
 }
 EXPORT_SYMBOL(eth_platform_get_mac_address);
-- 
2.18.0


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

* [PATCH v2 17/29] net: davinci_emac: use eth_platform_get_mac_address()
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (15 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 16/29] net: add support for nvmem to eth_platform_get_mac_address() Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 18/29] ARM: davinci: da850-evm: remove dead MTD code Bartosz Golaszewski
                   ` (12 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We now support nvmem in eth_platform_get_mac_address() and all boards
have the mac-address cells defined. Stop getting the MAC from pdata
and use the dedicated helper.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/net/ethernet/ti/davinci_emac.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index f270beebb428..5d01bad4baa5 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -1700,7 +1700,6 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
 	const struct of_device_id *match;
 	const struct emac_platform_data *auxdata;
 	struct emac_platform_data *pdata = NULL;
-	const u8 *mac_addr;
 
 	if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
 		return dev_get_platdata(&pdev->dev);
@@ -1712,12 +1711,6 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
 	np = pdev->dev.of_node;
 	pdata->version = EMAC_VERSION_2;
 
-	if (!is_valid_ether_addr(pdata->mac_addr)) {
-		mac_addr = of_get_mac_address(np);
-		if (mac_addr)
-			ether_addr_copy(pdata->mac_addr, mac_addr);
-	}
-
 	of_property_read_u32(np, "ti,davinci-ctrl-reg-offset",
 			     &pdata->ctrl_reg_offset);
 
@@ -1819,8 +1812,11 @@ static int davinci_emac_probe(struct platform_device *pdev)
 		goto err_free_netdev;
 	}
 
+	rc = eth_platform_get_mac_address(&pdev->dev, priv->mac_addr);
+	if (rc == -EPROBE_DEFER)
+		return -EPROBE_DEFER; /* We'll get the MAC address later. */
+
 	/* MAC addr and PHY mask , RMII enable info from platform_data */
-	memcpy(priv->mac_addr, pdata->mac_addr, ETH_ALEN);
 	priv->phy_id = pdata->phy_id;
 	priv->rmii_en = pdata->rmii_en;
 	priv->version = pdata->version;
-- 
2.18.0


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

* [PATCH v2 18/29] ARM: davinci: da850-evm: remove dead MTD code
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (16 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 17/29] net: davinci_emac: use eth_platform_get_mac_address() Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 19/29] ARM: davinci: mityomapl138: don't read the MAC address from machine code Bartosz Golaszewski
                   ` (11 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We no longer need to register the MTD notifier to read the MAC address
as it's now being done in the emac driver.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-da850-evm.c | 28 -------------------------
 1 file changed, 28 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 521a26b5c20d..1df796b67b82 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -137,32 +137,6 @@ static struct spi_board_info da850evm_spi_info[] = {
 	},
 };
 
-#ifdef CONFIG_MTD
-static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
-{
-	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
-	size_t retlen;
-
-	if (!strcmp(mtd->name, "MAC-Address")) {
-		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
-		if (retlen == ETH_ALEN)
-			pr_info("Read MAC addr from SPI Flash: %pM\n",
-				mac_addr);
-	}
-}
-
-static struct mtd_notifier da850evm_spi_notifier = {
-	.add	= da850_evm_m25p80_notify_add,
-};
-
-static void da850_evm_setup_mac_addr(void)
-{
-	register_mtd_user(&da850evm_spi_notifier);
-}
-#else
-static void da850_evm_setup_mac_addr(void) { }
-#endif
-
 static struct mtd_partition da850_evm_norflash_partition[] = {
 	{
 		.name           = "bootloaders + env",
@@ -1470,8 +1444,6 @@ static __init void da850_evm_init(void)
 	if (ret)
 		pr_warn("%s: SATA registration failed: %d\n", __func__, ret);
 
-	da850_evm_setup_mac_addr();
-
 	ret = da8xx_register_rproc();
 	if (ret)
 		pr_warn("%s: dsp/rproc registration failed: %d\n",
-- 
2.18.0


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

* [PATCH v2 19/29] ARM: davinci: mityomapl138: don't read the MAC address from machine code
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (17 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 18/29] ARM: davinci: da850-evm: remove dead MTD code Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 20/29] ARM: davinci: dm365-evm: use device properties for at24 eeprom Bartosz Golaszewski
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

This is now done by the emac driver using a registered nvmem cell.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-mityomapl138.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index 48a9bae76e4a..35b2b6068a7a 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -120,7 +120,6 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context)
 {
 	int ret;
 	const char *partnum = NULL;
-	struct davinci_soc_info *soc_info = &davinci_soc_info;
 
 	if (!IS_BUILTIN(CONFIG_NVMEM)) {
 		pr_warn("Factory Config not available without CONFIG_NVMEM\n");
@@ -146,13 +145,6 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context)
 		goto bad_config;
 	}
 
-	pr_info("Found MAC = %pM\n", factory_config.mac);
-	if (is_valid_ether_addr(factory_config.mac))
-		memcpy(soc_info->emac_pdata->mac_addr,
-			factory_config.mac, ETH_ALEN);
-	else
-		pr_warn("Invalid MAC found in factory config block\n");
-
 	partnum = factory_config.partnum;
 	pr_info("Part Number = %s\n", partnum);
 
-- 
2.18.0


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

* [PATCH v2 20/29] ARM: davinci: dm365-evm: use device properties for at24 eeprom
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (18 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 19/29] ARM: davinci: mityomapl138: don't read the MAC address from machine code Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 21/29] ARM: davinci: da830-evm: " Bartosz Golaszewski
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We want to work towards phasing out the at24_platform_data structure.
There are few users and its contents can be represented using generic
device properties. Using device properties only will allow us to
significantly simplify the at24 configuration code.

Remove the at24_platform_data structure and replace it with an array
of property entries. Drop the byte_len/size property, as the model name
already implies the EEPROM's size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 arch/arm/mach-davinci/board-dm365-evm.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index cf3f2e611228..2447e08dd68d 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -18,7 +18,7 @@
 #include <linux/i2c.h>
 #include <linux/io.h>
 #include <linux/clk.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/leds.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
@@ -179,18 +179,15 @@ static struct nvmem_cell_lookup dm365evm_mac_address_cell = {
 	.nvmem_name = "1-00500",
 };
 
-static struct at24_platform_data eeprom_info = {
-	.byte_len       = (256*1024) / 8,
-	.page_size      = 64,
-	.flags          = AT24_FLAG_ADDR16,
-	.setup          = davinci_get_mac_addr,
-	.context	= (void *)0x7f00,
+static const struct property_entry eeprom_properties[] = {
+	PROPERTY_ENTRY_U32("pagesize", 64),
+	{ }
 };
 
 static struct i2c_board_info i2c_info[] = {
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.platform_data	= &eeprom_info,
+		.properties = eeprom_properties,
 	},
 	{
 		I2C_BOARD_INFO("tlv320aic3x", 0x18),
-- 
2.18.0


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

* [PATCH v2 21/29] ARM: davinci: da830-evm: use device properties for at24 eeprom
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (19 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 20/29] ARM: davinci: dm365-evm: use device properties for at24 eeprom Bartosz Golaszewski
@ 2018-08-10  8:05 ` " Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 22/29] ARM: davinci: dm644x-evm: " Bartosz Golaszewski
                   ` (8 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We want to work towards phasing out the at24_platform_data structure.
There are few users and its contents can be represented using generic
device properties. Using device properties only will allow us to
significantly simplify the at24 configuration code.

Remove the at24_platform_data structure and replace it with an array
of property entries. Drop the byte_len/size property, as the model name
already implies the EEPROM's size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 arch/arm/mach-davinci/board-da830-evm.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c
index 9a055ebba081..fcfd1565bfdc 100644
--- a/arch/arm/mach-davinci/board-da830-evm.c
+++ b/arch/arm/mach-davinci/board-da830-evm.c
@@ -18,7 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
 #include <linux/platform_data/pcf857x.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
 #include <linux/nvmem-provider.h>
@@ -419,12 +419,9 @@ static struct nvmem_cell_lookup da830_evm_mac_address_cell = {
 	.nvmem_name = "1-00500",
 };
 
-static struct at24_platform_data da830_evm_i2c_eeprom_info = {
-	.byte_len	= SZ_256K / 8,
-	.page_size	= 64,
-	.flags		= AT24_FLAG_ADDR16,
-	.setup		= davinci_get_mac_addr,
-	.context	= (void *)0x7f00,
+static const struct property_entry da830_evm_i2c_eeprom_properties[] = {
+	PROPERTY_ENTRY_U32("pagesize", 64),
+	{ }
 };
 
 static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
@@ -458,7 +455,7 @@ static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.platform_data	= &da830_evm_i2c_eeprom_info,
+		.properties = da830_evm_i2c_eeprom_properties,
 	},
 	{
 		I2C_BOARD_INFO("tlv320aic3x", 0x18),
-- 
2.18.0


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

* [PATCH v2 22/29] ARM: davinci: dm644x-evm: use device properties for at24 eeprom
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (20 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 21/29] ARM: davinci: da830-evm: " Bartosz Golaszewski
@ 2018-08-10  8:05 ` " Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 23/29] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
                   ` (7 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We want to work towards phasing out the at24_platform_data structure.
There are few users and its contents can be represented using generic
device properties. Using device properties only will allow us to
significantly simplify the at24 configuration code.

Remove the at24_platform_data structure and replace it with an array
of property entries. Drop the byte_len/size property, as the model name
already implies the EEPROM's size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 arch/arm/mach-davinci/board-dm644x-evm.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 829fa1c8d0b4..954296d23297 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -16,8 +16,8 @@
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
 #include <linux/platform_data/pcf857x.h>
-#include <linux/platform_data/at24.h>
 #include <linux/platform_data/gpio-davinci.h>
+#include <linux/property.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/rawnand.h>
 #include <linux/mtd/partitions.h>
@@ -486,12 +486,9 @@ static struct nvmem_cell_lookup dm6446evm_mac_address_cell = {
 	.nvmem_name = "1-00500",
 };
 
-static struct at24_platform_data eeprom_info = {
-	.byte_len	= (256*1024) / 8,
-	.page_size	= 64,
-	.flags		= AT24_FLAG_ADDR16,
-	.setup          = davinci_get_mac_addr,
-	.context	= (void *)0x7f00,
+static const struct property_entry eeprom_properties[] = {
+	PROPERTY_ENTRY_U32("pagesize", 64),
+	{ }
 };
 
 /*
@@ -601,7 +598,7 @@ static struct i2c_board_info __initdata i2c_info[] =  {
 	},
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.platform_data	= &eeprom_info,
+		.properties = eeprom_properties,
 	},
 	{
 		I2C_BOARD_INFO("tlv320aic33", 0x1b),
-- 
2.18.0


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

* [PATCH v2 23/29] ARM: davinci: dm646x-evm: use device properties for at24 eeprom
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (21 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 22/29] ARM: davinci: dm644x-evm: " Bartosz Golaszewski
@ 2018-08-10  8:05 ` " Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 24/29] ARM: davinci: sffsdr: fix the at24 eeprom device name Bartosz Golaszewski
                   ` (6 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We want to work towards phasing out the at24_platform_data structure.
There are few users and its contents can be represented using generic
device properties. Using device properties only will allow us to
significantly simplify the at24 configuration code.

Remove the at24_platform_data structure and replace it with an array
of property entries. Drop the byte_len/size property, as the model name
already implies the EEPROM's size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 arch/arm/mach-davinci/board-dm646x-evm.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 943ab0ca6db8..04d293096962 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -22,7 +22,7 @@
 #include <linux/gpio.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/platform_data/pcf857x.h>
 
 #include <media/i2c/tvp514x.h>
@@ -320,12 +320,9 @@ static struct nvmem_cell_lookup dm646x_evm_mac_address_cell = {
 	.nvmem_name = "1-00500",
 };
 
-static struct at24_platform_data eeprom_info = {
-	.byte_len       = (256*1024) / 8,
-	.page_size      = 64,
-	.flags          = AT24_FLAG_ADDR16,
-	.setup          = davinci_get_mac_addr,
-	.context	= (void *)0x7f00,
+static const struct property_entry eeprom_properties[] = {
+	PROPERTY_ENTRY_U32("pagesize", 64),
+	{ }
 };
 #endif
 
@@ -396,7 +393,7 @@ static void evm_init_cpld(void)
 static struct i2c_board_info __initdata i2c_info[] =  {
 	{
 		I2C_BOARD_INFO("24c256", 0x50),
-		.platform_data  = &eeprom_info,
+		.properties  = eeprom_properties,
 	},
 	{
 		I2C_BOARD_INFO("pcf8574a", 0x38),
-- 
2.18.0


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

* [PATCH v2 24/29] ARM: davinci: sffsdr: fix the at24 eeprom device name
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (22 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 23/29] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 25/29] ARM: davinci: sffsdr: use device properties for at24 eeprom Bartosz Golaszewski
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

The currently used 24lc64 i2c device name doesn't match against any
of the devices supported by the at24 driver. Change it to the closest
compatible chip.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-sffsdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index e7c1728b0833..f6a4d094cbc3 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -100,7 +100,7 @@ static struct at24_platform_data eeprom_info = {
 
 static struct i2c_board_info __initdata i2c_info[] =  {
 	{
-		I2C_BOARD_INFO("24lc64", 0x50),
+		I2C_BOARD_INFO("24c64", 0x50),
 		.platform_data	= &eeprom_info,
 	},
 	/* Other I2C devices:
-- 
2.18.0


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

* [PATCH v2 25/29] ARM: davinci: sffsdr: use device properties for at24 eeprom
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (23 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 24/29] ARM: davinci: sffsdr: fix the at24 eeprom device name Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 26/29] ARM: davinci: remove dead code related to MAC address reading Bartosz Golaszewski
                   ` (4 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We want to work towards phasing out the at24_platform_data structure.
There are few users and its contents can be represented using generic
device properties. Using device properties only will allow us to
significantly simplify the at24 configuration code.

Remove the at24_platform_data structure and replace it with an array
of property entries. Drop the byte_len/size property, as the model name
already implies the EEPROM's size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 arch/arm/mach-davinci/board-sffsdr.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index f6a4d094cbc3..4f3bc78e8154 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -26,7 +26,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/rawnand.h>
 #include <linux/mtd/partitions.h>
@@ -92,16 +92,15 @@ static struct platform_device davinci_sffsdr_nandflash_device = {
 	.resource	= davinci_sffsdr_nandflash_resource,
 };
 
-static struct at24_platform_data eeprom_info = {
-	.byte_len	= (64*1024) / 8,
-	.page_size	= 32,
-	.flags		= AT24_FLAG_ADDR16,
+static const struct property_entry eeprom_properties[] = {
+	PROPERTY_ENTRY_U32("pagesize", 32),
+	{ }
 };
 
 static struct i2c_board_info __initdata i2c_info[] =  {
 	{
 		I2C_BOARD_INFO("24c64", 0x50),
-		.platform_data	= &eeprom_info,
+		.properties = eeprom_properties,
 	},
 	/* Other I2C devices:
 	 * MSP430,  addr 0x23 (not used)
-- 
2.18.0


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

* [PATCH v2 26/29] ARM: davinci: remove dead code related to MAC address reading
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (24 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 25/29] ARM: davinci: sffsdr: use device properties for at24 eeprom Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 27/29] ARM: davinci: mityomapl138: use nvmem notifiers Bartosz Golaszewski
                   ` (3 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

There are no more users of davinci_get_mac_addr(). Remove it. Also
remove the mac_addr field from the emac platform data struct.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/common.c | 15 ---------------
 include/linux/davinci_emac.h   |  2 --
 2 files changed, 17 deletions(-)

diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c
index bcb6a7ba84e9..0c6cc354a4aa 100644
--- a/arch/arm/mach-davinci/common.c
+++ b/arch/arm/mach-davinci/common.c
@@ -28,21 +28,6 @@ EXPORT_SYMBOL(davinci_soc_info);
 void __iomem *davinci_intc_base;
 int davinci_intc_type;
 
-void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context)
-{
-	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
-	off_t offset = (off_t)context;
-
-	if (!IS_BUILTIN(CONFIG_NVMEM)) {
-		pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n");
-		return;
-	}
-
-	/* Read MAC addr from EEPROM */
-	if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
-		pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
-}
-
 static int __init davinci_init_id(struct davinci_soc_info *soc_info)
 {
 	int			i;
diff --git a/include/linux/davinci_emac.h b/include/linux/davinci_emac.h
index 05b97144d342..19888b27706d 100644
--- a/include/linux/davinci_emac.h
+++ b/include/linux/davinci_emac.h
@@ -19,7 +19,6 @@ struct mdio_platform_data {
 };
 
 struct emac_platform_data {
-	char mac_addr[ETH_ALEN];
 	u32 ctrl_reg_offset;
 	u32 ctrl_mod_reg_offset;
 	u32 ctrl_ram_offset;
@@ -46,5 +45,4 @@ enum {
 	EMAC_VERSION_2,	/* DM646x */
 };
 
-void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context);
 #endif
-- 
2.18.0


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

* [PATCH v2 27/29] ARM: davinci: mityomapl138: use nvmem notifiers
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (25 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 26/29] ARM: davinci: remove dead code related to MAC address reading Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 28/29] ARM: davinci: mityomapl138: use device properties for at24 eeprom Bartosz Golaszewski
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Stop using the at24_platform_data setup callback in favor of nvmem
notifiers.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 arch/arm/mach-davinci/board-mityomapl138.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index 35b2b6068a7a..dacc5292f9bd 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -15,6 +15,8 @@
 #include <linux/console.h>
 #include <linux/platform_device.h>
 #include <linux/mtd/partitions.h>
+#include <linux/notifier.h>
+#include <linux/nvmem-consumer.h>
 #include <linux/nvmem-provider.h>
 #include <linux/regulator/machine.h>
 #include <linux/i2c.h>
@@ -116,10 +118,15 @@ static void mityomapl138_cpufreq_init(const char *partnum)
 static void mityomapl138_cpufreq_init(const char *partnum) { }
 #endif
 
-static void read_factory_config(struct nvmem_device *nvmem, void *context)
+static int read_factory_config(struct notifier_block *nb,
+			       unsigned long event, void *data)
 {
 	int ret;
 	const char *partnum = NULL;
+	struct nvmem_device *nvmem = data;
+
+	if (strcmp(nvmem_dev_name(nvmem), "1-00500") != 0)
+		return NOTIFY_DONE;
 
 	if (!IS_BUILTIN(CONFIG_NVMEM)) {
 		pr_warn("Factory Config not available without CONFIG_NVMEM\n");
@@ -151,8 +158,14 @@ static void read_factory_config(struct nvmem_device *nvmem, void *context)
 bad_config:
 	/* default maximum speed is valid for all platforms */
 	mityomapl138_cpufreq_init(partnum);
+
+	return NOTIFY_STOP;
 }
 
+static struct notifier_block mityomapl138_nvmem_notifier = {
+	.notifier_call = read_factory_config,
+};
+
 static struct nvmem_cell_lookup mityomapl138_nvmem_cells[] = {
 	{
 		.info = {
@@ -176,8 +189,6 @@ static struct at24_platform_data mityomapl138_fd_chip = {
 	.byte_len	= 256,
 	.page_size	= 8,
 	.flags		= AT24_FLAG_READONLY | AT24_FLAG_IRUGO,
-	.setup		= read_factory_config,
-	.context	= NULL,
 };
 
 static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
@@ -546,6 +557,7 @@ static void __init mityomapl138_init(void)
 	if (ret)
 		pr_warn("spi 1 registration failed: %d\n", ret);
 
+	nvmem_register_notifier(&mityomapl138_nvmem_notifier);
 	nvmem_add_lookup_table(mityomapl138_nvmem_cells,
 			       ARRAY_SIZE(mityomapl138_nvmem_cells));
 	mityomapl138_config_emac();
-- 
2.18.0


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

* [PATCH v2 28/29] ARM: davinci: mityomapl138: use device properties for at24 eeprom
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (26 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 27/29] ARM: davinci: mityomapl138: use nvmem notifiers Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:05 ` [PATCH v2 29/29] eeprom: at24: kill at24_platform_data Bartosz Golaszewski
  2018-08-10  8:41 ` [PATCH v2 00/29] at24: remove at24_platform_data Srinivas Kandagatla
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We want to work towards phasing out the at24_platform_data structure.
There are few users and its contents can be represented using generic
device properties. Using device properties only will allow us to
significantly simplify the at24 configuration code.

Remove the at24_platform_data structure and replace it with an array
of property entries. Drop the byte_len/size property, as the model name
already implies the EEPROM's size.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 arch/arm/mach-davinci/board-mityomapl138.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c
index dacc5292f9bd..db50fcce5976 100644
--- a/arch/arm/mach-davinci/board-mityomapl138.c
+++ b/arch/arm/mach-davinci/board-mityomapl138.c
@@ -14,13 +14,13 @@
 #include <linux/init.h>
 #include <linux/console.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/mtd/partitions.h>
 #include <linux/notifier.h>
 #include <linux/nvmem-consumer.h>
 #include <linux/nvmem-provider.h>
 #include <linux/regulator/machine.h>
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
 #include <linux/etherdevice.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
@@ -185,10 +185,10 @@ static struct nvmem_cell_lookup mityomapl138_nvmem_cells[] = {
 	}
 };
 
-static struct at24_platform_data mityomapl138_fd_chip = {
-	.byte_len	= 256,
-	.page_size	= 8,
-	.flags		= AT24_FLAG_READONLY | AT24_FLAG_IRUGO,
+static const struct property_entry mityomapl138_fd_chip_properties[] = {
+	PROPERTY_ENTRY_U32("pagesize", 8),
+	PROPERTY_ENTRY_BOOL("read-only"),
+	{ }
 };
 
 static struct davinci_i2c_platform_data mityomap_i2c_0_pdata = {
@@ -317,7 +317,7 @@ static struct i2c_board_info __initdata mityomap_tps65023_info[] = {
 	},
 	{
 		I2C_BOARD_INFO("24c02", 0x50),
-		.platform_data = &mityomapl138_fd_chip,
+		.properties = mityomapl138_fd_chip_properties,
 	},
 };
 
-- 
2.18.0


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

* [PATCH v2 29/29] eeprom: at24: kill at24_platform_data
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (27 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 28/29] ARM: davinci: mityomapl138: use device properties for at24 eeprom Bartosz Golaszewski
@ 2018-08-10  8:05 ` Bartosz Golaszewski
  2018-08-10  8:41 ` [PATCH v2 00/29] at24: remove at24_platform_data Srinivas Kandagatla
  29 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10  8:05 UTC (permalink / raw)
  To: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

There are no more users of at24_platform_data. Remove the relevant
header and modify the driver code to not use it anymore.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 MAINTAINERS                        |   1 -
 drivers/misc/eeprom/at24.c         | 127 +++++++++++++----------------
 include/linux/platform_data/at24.h |  60 --------------
 3 files changed, 57 insertions(+), 131 deletions(-)
 delete mode 100644 include/linux/platform_data/at24.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 7cebd5bba8a8..8eb87a3548f8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2328,7 +2328,6 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git
 S:	Maintained
 F:	Documentation/devicetree/bindings/eeprom/at24.txt
 F:	drivers/misc/eeprom/at24.c
-F:	include/linux/platform_data/at24.h
 
 ATA OVER ETHERNET (AOE) DRIVER
 M:	"Ed L. Cashin" <ed.cashin@acm.org>
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index f5cc517d1131..93642b4b47c5 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -22,10 +22,24 @@
 #include <linux/i2c.h>
 #include <linux/nvmem-provider.h>
 #include <linux/regmap.h>
-#include <linux/platform_data/at24.h>
 #include <linux/pm_runtime.h>
 #include <linux/gpio/consumer.h>
 
+/* Address pointer is 16 bit. */
+#define AT24_FLAG_ADDR16	BIT(7)
+/* sysfs-entry will be read-only. */
+#define AT24_FLAG_READONLY	BIT(6)
+/* sysfs-entry will be world-readable. */
+#define AT24_FLAG_IRUGO		BIT(5)
+/* Take always 8 addresses (24c00). */
+#define AT24_FLAG_TAKE8ADDR	BIT(4)
+/* Factory-programmed serial number. */
+#define AT24_FLAG_SERIAL	BIT(3)
+/* Factory-programmed mac address. */
+#define AT24_FLAG_MAC		BIT(2)
+/* Does not auto-rollover reads to the next slave address. */
+#define AT24_FLAG_NO_RDROL	BIT(1)
+
 /*
  * I2C EEPROMs from most vendors are inexpensive and mostly interchangeable.
  * Differences between different vendor product lines (like Atmel AT24C or
@@ -124,10 +138,6 @@ MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)");
 	     usleep_range(1000, 1500), op_time = jiffies)
 
 struct at24_chip_data {
-	/*
-	 * these fields mirror their equivalents in
-	 * struct at24_platform_data
-	 */
 	u32 byte_len;
 	u8 flags;
 };
@@ -467,46 +477,11 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
 	return 0;
 }
 
-static void at24_properties_to_pdata(struct device *dev,
-				     struct at24_platform_data *chip)
-{
-	int err;
-	u32 val;
-
-	if (device_property_present(dev, "read-only"))
-		chip->flags |= AT24_FLAG_READONLY;
-	if (device_property_present(dev, "no-read-rollover"))
-		chip->flags |= AT24_FLAG_NO_RDROL;
-
-	err = device_property_read_u32(dev, "size", &val);
-	if (!err)
-		chip->byte_len = val;
-
-	err = device_property_read_u32(dev, "pagesize", &val);
-	if (!err) {
-		chip->page_size = val;
-	} else {
-		/*
-		 * This is slow, but we can't know all eeproms, so we better
-		 * play safe. Specifying custom eeprom-types via platform_data
-		 * is recommended anyhow.
-		 */
-		chip->page_size = 1;
-	}
-}
-
-static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata)
+static const struct at24_chip_data *at24_get_chip_data(struct device *dev)
 {
 	struct device_node *of_node = dev->of_node;
 	const struct at24_chip_data *cdata;
 	const struct i2c_device_id *id;
-	struct at24_platform_data *pd;
-
-	pd = dev_get_platdata(dev);
-	if (pd) {
-		memcpy(pdata, pd, sizeof(*pdata));
-		return 0;
-	}
 
 	id = i2c_match_id(at24_ids, to_i2c_client(dev));
 
@@ -523,13 +498,9 @@ static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata)
 		cdata = acpi_device_get_match_data(dev);
 
 	if (!cdata)
-		return -ENODEV;
+		return ERR_PTR(-ENODEV);
 
-	pdata->byte_len = cdata->byte_len;
-	pdata->flags = cdata->flags;
-	at24_properties_to_pdata(dev, pdata);
-
-	return 0;
+	return cdata;
 }
 
 static void at24_remove_dummy_clients(struct at24_data *at24)
@@ -598,8 +569,9 @@ static int at24_probe(struct i2c_client *client)
 {
 	struct regmap_config regmap_config = { };
 	struct nvmem_config nvmem_config = { };
-	struct at24_platform_data pdata = { };
+	const struct at24_chip_data *cdata;
 	struct device *dev = &client->dev;
+	u32 byte_len, page_size, flags;
 	bool i2c_fn_i2c, i2c_fn_block;
 	unsigned int i, num_addresses;
 	struct at24_data *at24;
@@ -613,35 +585,54 @@ static int at24_probe(struct i2c_client *client)
 	i2c_fn_block = i2c_check_functionality(client->adapter,
 					       I2C_FUNC_SMBUS_WRITE_I2C_BLOCK);
 
-	err = at24_get_pdata(dev, &pdata);
+	cdata = at24_get_chip_data(dev);
+	if (IS_ERR(cdata))
+		return PTR_ERR(cdata);
+
+	err = device_property_read_u32(dev, "pagesize", &page_size);
+	if (err)
+		/*
+		 * This is slow, but we can't know all eeproms, so we better
+		 * play safe. Specifying custom eeprom-types via platform_data
+		 * is recommended anyhow.
+		 */
+		page_size = 1;
+
+	flags = cdata->flags;
+	if (device_property_present(dev, "read-only"))
+		flags |= AT24_FLAG_READONLY;
+	if (device_property_present(dev, "no-read-rollover"))
+		flags |= AT24_FLAG_NO_RDROL;
+
+	err = device_property_read_u32(dev, "size", &byte_len);
 	if (err)
-		return err;
+		byte_len = cdata->byte_len;
 
 	if (!i2c_fn_i2c && !i2c_fn_block)
-		pdata.page_size = 1;
+		page_size = 1;
 
-	if (!pdata.page_size) {
+	if (!page_size) {
 		dev_err(dev, "page_size must not be 0!\n");
 		return -EINVAL;
 	}
 
-	if (!is_power_of_2(pdata.page_size))
+	if (!is_power_of_2(page_size))
 		dev_warn(dev, "page_size looks suspicious (no power of 2)!\n");
 
-	if (pdata.flags & AT24_FLAG_TAKE8ADDR)
+	if (flags & AT24_FLAG_TAKE8ADDR)
 		num_addresses = 8;
 	else
-		num_addresses =	DIV_ROUND_UP(pdata.byte_len,
-			(pdata.flags & AT24_FLAG_ADDR16) ? 65536 : 256);
+		num_addresses =	DIV_ROUND_UP(byte_len,
+			(flags & AT24_FLAG_ADDR16) ? 65536 : 256);
 
-	if ((pdata.flags & AT24_FLAG_SERIAL) && (pdata.flags & AT24_FLAG_MAC)) {
+	if ((flags & AT24_FLAG_SERIAL) && (flags & AT24_FLAG_MAC)) {
 		dev_err(dev,
 			"invalid device data - cannot have both AT24_FLAG_SERIAL & AT24_FLAG_MAC.");
 		return -EINVAL;
 	}
 
 	regmap_config.val_bits = 8;
-	regmap_config.reg_bits = (pdata.flags & AT24_FLAG_ADDR16) ? 16 : 8;
+	regmap_config.reg_bits = (flags & AT24_FLAG_ADDR16) ? 16 : 8;
 	regmap_config.disable_locking = true;
 
 	regmap = devm_regmap_init_i2c(client, &regmap_config);
@@ -654,11 +645,11 @@ static int at24_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	mutex_init(&at24->lock);
-	at24->byte_len = pdata.byte_len;
-	at24->page_size = pdata.page_size;
-	at24->flags = pdata.flags;
+	at24->byte_len = byte_len;
+	at24->page_size = page_size;
+	at24->flags = flags;
 	at24->num_addresses = num_addresses;
-	at24->offset_adj = at24_get_offset_adj(pdata.flags, pdata.byte_len);
+	at24->offset_adj = at24_get_offset_adj(flags, byte_len);
 	at24->client[0].client = client;
 	at24->client[0].regmap = regmap;
 
@@ -666,10 +657,10 @@ static int at24_probe(struct i2c_client *client)
 	if (IS_ERR(at24->wp_gpio))
 		return PTR_ERR(at24->wp_gpio);
 
-	writable = !(pdata.flags & AT24_FLAG_READONLY);
+	writable = !(flags & AT24_FLAG_READONLY);
 	if (writable) {
 		at24->write_max = min_t(unsigned int,
-					pdata.page_size, at24_io_limit);
+					page_size, at24_io_limit);
 		if (!i2c_fn_i2c && at24->write_max > I2C_SMBUS_BLOCK_MAX)
 			at24->write_max = I2C_SMBUS_BLOCK_MAX;
 	}
@@ -712,7 +703,7 @@ static int at24_probe(struct i2c_client *client)
 	nvmem_config.priv = at24;
 	nvmem_config.stride = 1;
 	nvmem_config.word_size = 1;
-	nvmem_config.size = pdata.byte_len;
+	nvmem_config.size = byte_len;
 
 	at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
 	if (IS_ERR(at24->nvmem)) {
@@ -721,13 +712,9 @@ static int at24_probe(struct i2c_client *client)
 	}
 
 	dev_info(dev, "%u byte %s EEPROM, %s, %u bytes/write\n",
-		 pdata.byte_len, client->name,
+		 byte_len, client->name,
 		 writable ? "writable" : "read-only", at24->write_max);
 
-	/* export data to kernel code */
-	if (pdata.setup)
-		pdata.setup(at24->nvmem, pdata.context);
-
 	return 0;
 
 err_clients:
diff --git a/include/linux/platform_data/at24.h b/include/linux/platform_data/at24.h
deleted file mode 100644
index 63507ff464ee..000000000000
--- a/include/linux/platform_data/at24.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * at24.h - platform_data for the at24 (generic eeprom) driver
- * (C) Copyright 2008 by Pengutronix
- * (C) Copyright 2012 by Wolfram Sang
- * same license as the driver
- */
-
-#ifndef _LINUX_AT24_H
-#define _LINUX_AT24_H
-
-#include <linux/types.h>
-#include <linux/nvmem-consumer.h>
-#include <linux/bitops.h>
-
-/**
- * struct at24_platform_data - data to set up at24 (generic eeprom) driver
- * @byte_len: size of eeprom in byte
- * @page_size: number of byte which can be written in one go
- * @flags: tunable options, check AT24_FLAG_* defines
- * @setup: an optional callback invoked after eeprom is probed; enables kernel
-	code to access eeprom via nvmem, see example
- * @context: optional parameter passed to setup()
- *
- * If you set up a custom eeprom type, please double-check the parameters.
- * Especially page_size needs extra care, as you risk data loss if your value
- * is bigger than what the chip actually supports!
- *
- * An example in pseudo code for a setup() callback:
- *
- * void get_mac_addr(struct nvmem_device *nvmem, void *context)
- * {
- *	u8 *mac_addr = ethernet_pdata->mac_addr;
- *	off_t offset = context;
- *
- *	// Read MAC addr from EEPROM
- *	if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
- *		pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
- * }
- *
- * This function pointer and context can now be set up in at24_platform_data.
- */
-
-struct at24_platform_data {
-	u32		byte_len;		/* size (sum of all addr) */
-	u16		page_size;		/* for writes */
-	u8		flags;
-#define AT24_FLAG_ADDR16	BIT(7)	/* address pointer is 16 bit */
-#define AT24_FLAG_READONLY	BIT(6)	/* sysfs-entry will be read-only */
-#define AT24_FLAG_IRUGO		BIT(5)	/* sysfs-entry will be world-readable */
-#define AT24_FLAG_TAKE8ADDR	BIT(4)	/* take always 8 addresses (24c00) */
-#define AT24_FLAG_SERIAL	BIT(3)	/* factory-programmed serial number */
-#define AT24_FLAG_MAC		BIT(2)	/* factory-programmed mac address */
-#define AT24_FLAG_NO_RDROL	BIT(1)	/* does not auto-rollover reads to */
-					/* the next slave address */
-
-	void		(*setup)(struct nvmem_device *nvmem, void *context);
-	void		*context;
-};
-
-#endif /* _LINUX_AT24_H */
-- 
2.18.0


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

* Re: [PATCH v2 04/29] nvmem: provide nvmem_dev_name()
  2018-08-10  8:05 ` [PATCH v2 04/29] nvmem: provide nvmem_dev_name() Bartosz Golaszewski
@ 2018-08-10  8:10   ` Srinivas Kandagatla
  0 siblings, 0 replies; 40+ messages in thread
From: Srinivas Kandagatla @ 2018-08-10  8:10 UTC (permalink / raw)
  To: Bartosz Golaszewski, Jonathan Corbet, Sekhar Nori, Kevin Hilman,
	Russell King, Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse,
	Brian Norris, Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski



On 10/08/18 09:05, Bartosz Golaszewski wrote:
>   
> +const char *nvmem_dev_name(struct nvmem_device *nvmem)
> +{
> +	return dev_name(&nvmem->dev);
> +}
> +EXPORT_SYMBOL_GPL(nvmem_dev_name);
> +
Kernel doc for this is missing!
Other than that it looks good to me!

--srini

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

* Re: [PATCH v2 03/29] nvmem: add a notifier chain
  2018-08-10  8:05 ` [PATCH v2 03/29] nvmem: add a notifier chain Bartosz Golaszewski
@ 2018-08-10  8:33   ` Srinivas Kandagatla
  0 siblings, 0 replies; 40+ messages in thread
From: Srinivas Kandagatla @ 2018-08-10  8:33 UTC (permalink / raw)
  To: Bartosz Golaszewski, Jonathan Corbet, Sekhar Nori, Kevin Hilman,
	Russell King, Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse,
	Brian Norris, Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski



On 10/08/18 09:05, Bartosz Golaszewski wrote:
> +int nvmem_register_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_register(&nvmem_notifier, nb);
> +}
> +EXPORT_SYMBOL_GPL(nvmem_register_notifier);
> +
> +int nvmem_unregister_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_unregister(&nvmem_notifier, nb);
> +}
> +EXPORT_SYMBOL_GPL(nvmem_unregister_notifier);
> +
Kerneldoc is missing for these both exported symbols too!

--srini

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

* Re: [PATCH v2 05/29] nvmem: remove the name field from struct nvmem_device
  2018-08-10  8:05 ` [PATCH v2 05/29] nvmem: remove the name field from struct nvmem_device Bartosz Golaszewski
@ 2018-08-10  8:33   ` Srinivas Kandagatla
  0 siblings, 0 replies; 40+ messages in thread
From: Srinivas Kandagatla @ 2018-08-10  8:33 UTC (permalink / raw)
  To: Bartosz Golaszewski, Jonathan Corbet, Sekhar Nori, Kevin Hilman,
	Russell King, Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse,
	Brian Norris, Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski



On 10/08/18 09:05, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> This field is never set and is only used in a single error message.
> Remove the field and use nvmem_dev_name() instead.
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
Looks good to me!

>   drivers/nvmem/core.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 31df2e6d6f72..ab3ced2d9a84 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -26,7 +26,6 @@
>   #include <linux/slab.h>
>   
>   struct nvmem_device {
> -	const char		*name;
>   	struct module		*owner;
>   	struct device		dev;
>   	int			stride;
> @@ -712,7 +711,7 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np,
>   	if (!try_module_get(nvmem->owner)) {
>   		dev_err(&nvmem->dev,
>   			"could not increase module refcount for cell %s\n",
> -			nvmem->name);
> +			nvmem_dev_name(nvmem));
>   
>   		mutex_lock(&nvmem_mutex);
>   		nvmem->users--;
> 

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

* Re: [PATCH v2 00/29] at24: remove at24_platform_data
  2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
                   ` (28 preceding siblings ...)
  2018-08-10  8:05 ` [PATCH v2 29/29] eeprom: at24: kill at24_platform_data Bartosz Golaszewski
@ 2018-08-10  8:41 ` Srinivas Kandagatla
  29 siblings, 0 replies; 40+ messages in thread
From: Srinivas Kandagatla @ 2018-08-10  8:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Jonathan Corbet, Sekhar Nori, Kevin Hilman,
	Russell King, Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse,
	Brian Norris, Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn
  Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-i2c, linux-mtd,
	linux-omap, netdev, Bartosz Golaszewski



On 10/08/18 09:04, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> This is a follow-up to the previously rejected series[1] which partially
> removed the at24_platform_data structure. After further development and
> taking reviews into account, this series finally removes that struct
> completely but not without touching many different parts of the code
> base.
> 
> Since I took over maintainership of the at24 driver I've been working
> towards removing at24_platform_data in favor for device properties.
> 
> DaVinci is the only platform that's still using it - all other users
> have already been converted.
> 
> One of the obstacles in case of DaVinci is removing the setup() callback
> from the pdata struct, the only user of which are some davinci boards.
> 
> Most boards use the EEPROM to store the MAC address. This series adds
> support for cell lookups to the nvmem framework, registers relevant
> cells for all users, adds nvmem support to eth_platform_get_mac_address(),
> converts davinci_emac driver to using it and replaces at24_platform_data
> with device properties.
> 
> There's also one board (da850-evm) which uses MTD for reading the MAC
> address. I used the patch from Alban Bedel's previous submission[2] to
> add support for nvmem to the MTD framework. Since this user doesn't
> need device tree, I dropped Alban's patches modifying the DT bindings.
> We can add that later once an agreement is reached. For the time being
> MTD devices are registered as nvmem devices and we're registering the
> mac-address cell using the cell lookup mechanism.
> 
> This series adds a blocking notifier chain to the nvmem framework, so
> that we can keep the EEPROM reading code in the mityomapl138 board file
> with only slight modifications.
> 
> I also included some minor fixes to the modified code.
> 
> Tested on da850-evm & dm365-evm.
> 
> [1] https://lkml.org/lkml/2018/6/29/153
> [2] https://lkml.org/lkml/2018/3/24/312
> 
...

> Bartosz Golaszewski (28):
>    nvmem: add support for cell lookups
>    Documentation: nvmem: document lookup entries
>    nvmem: add a notifier chain
>    nvmem: provide nvmem_dev_name()
>    nvmem: remove the name field from struct nvmem_device
> 
>   Documentation/nvmem/nvmem.txt              |  28 +++++
..
>   drivers/nvmem/core.c                       | 106 ++++++++++++++++-

nvmem parts looks good to me other then few trivial kernel doc comments!
I can either Ack those patches or Send them after rc3-4 to Greg KH as 
4.20 material.

Thanks
srini

> 

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

* Re: [PATCH v2 14/29] net: simplify eth_platform_get_mac_address()
  2018-08-10  8:05 ` [PATCH v2 14/29] net: simplify eth_platform_get_mac_address() Bartosz Golaszewski
@ 2018-08-10 14:39   ` Andy Shevchenko
  2018-08-10 16:17     ` Bartosz Golaszewski
  0 siblings, 1 reply; 40+ messages in thread
From: Andy Shevchenko @ 2018-08-10 14:39 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn, Linux Documentation List,
	Linux Kernel Mailing List, linux-arm Mailing List, linux-i2c,
	open list:MEMORY TECHNOLOGY...,
	Linux OMAP Mailing List, netdev, Bartosz Golaszewski

On Fri, Aug 10, 2018 at 11:05 AM, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> We don't need to use pci_device_to_OF_node() - we can retrieve
> dev->of_node directly even for pci devices.
>

>         struct device_node *dp;
>
> -       if (dev_is_pci(dev))
> -               dp = pci_device_to_OF_node(to_pci_dev(dev));
> -       else
> -               dp = dev->of_node;
> -
> +       dp = dev->of_node;
>         addr = NULL;
>         if (dp)
>                 addr = of_get_mac_address(dp);

Looking more at this I could even propose to change all above by

addr = device_get_mac_address(dev, mac_addr, ETH_ALEN);

Thoughts?

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH v2 14/29] net: simplify eth_platform_get_mac_address()
  2018-08-10 14:39   ` Andy Shevchenko
@ 2018-08-10 16:17     ` Bartosz Golaszewski
  0 siblings, 0 replies; 40+ messages in thread
From: Bartosz Golaszewski @ 2018-08-10 16:17 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Boris Brezillon, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn, Linux Documentation List,
	Linux Kernel Mailing List, linux-arm Mailing List, linux-i2c,
	open list:MEMORY TECHNOLOGY...,
	Linux OMAP Mailing List, netdev, Bartosz Golaszewski

2018-08-10 16:39 GMT+02:00 Andy Shevchenko <andy.shevchenko@gmail.com>:
> On Fri, Aug 10, 2018 at 11:05 AM, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>
>> We don't need to use pci_device_to_OF_node() - we can retrieve
>> dev->of_node directly even for pci devices.
>>
>
>>         struct device_node *dp;
>>
>> -       if (dev_is_pci(dev))
>> -               dp = pci_device_to_OF_node(to_pci_dev(dev));
>> -       else
>> -               dp = dev->of_node;
>> -
>> +       dp = dev->of_node;
>>         addr = NULL;
>>         if (dp)
>>                 addr = of_get_mac_address(dp);
>
> Looking more at this I could even propose to change all above by
>
> addr = device_get_mac_address(dev, mac_addr, ETH_ALEN);
>
> Thoughts?
>
> --
> With Best Regards,
> Andy Shevchenko

Indeed seems like it's even more generalized. Thanks for spotting that.

Bart

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

* Re: [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API
  2018-08-10  8:05 ` [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API Bartosz Golaszewski
@ 2018-08-17 16:27   ` Boris Brezillon
  2018-08-19 11:31     ` Alban
  0 siblings, 1 reply; 40+ messages in thread
From: Boris Brezillon @ 2018-08-17 16:27 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Jonathan Corbet, Sekhar Nori, Kevin Hilman, Russell King,
	Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse, Brian Norris,
	Marek Vasut, Richard Weinberger, Grygorii Strashko,
	David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Alban Bedel, Rob Herring,
	David Lechner, Andrew Lunn, linux-doc, linux-kernel,
	linux-arm-kernel, linux-i2c, linux-mtd, linux-omap, netdev,
	Bartosz Golaszewski

Hi Bartosz,

On Fri, 10 Aug 2018 10:05:03 +0200
Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Alban Bedel <albeu@free.fr>
> 
> Allow drivers that use the nvmem API to read data stored on MTD devices.
> For this the mtd devices are registered as read-only NVMEM providers.
> 
> Signed-off-by: Alban Bedel <albeu@free.fr>
> [Bartosz:
>   - use the managed variant of nvmem_register(),
>   - set the nvmem name]
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

What happened to the 2 other patches of Alban's series? I'd really like
the DT case to be handled/agreed on in the same patchset, but IIRC,
Alban and Srinivas disagreed on how this should be represented. I
hope this time we'll come to an agreement, because the MTD <-> NVMEM
glue has been floating around for quite some time...

Regards,

Boris

> ---
>  drivers/mtd/Kconfig     |  1 +
>  drivers/mtd/mtdcore.c   | 50 +++++++++++++++++++++++++++++++++++++++++
>  include/linux/mtd/mtd.h |  2 ++
>  3 files changed, 53 insertions(+)
> 
> diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
> index 46ab7feec6b6..f5549482d0df 100644
> --- a/drivers/mtd/Kconfig
> +++ b/drivers/mtd/Kconfig
> @@ -1,5 +1,6 @@
>  menuconfig MTD
>  	tristate "Memory Technology Device (MTD) support"
> +	imply NVMEM
>  	help
>  	  Memory Technology Devices are flash, RAM and similar chips, often
>  	  used for solid state file systems on embedded devices. This option
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 42395df06be9..a57302eaceb5 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -488,6 +488,49 @@ int mtd_pairing_groups(struct mtd_info *mtd)
>  }
>  EXPORT_SYMBOL_GPL(mtd_pairing_groups);
>  
> +static int mtd_nvmem_reg_read(void *priv, unsigned int offset,
> +			      void *val, size_t bytes)
> +{
> +	struct mtd_info *mtd = priv;
> +	size_t retlen;
> +	int err;
> +
> +	err = mtd_read(mtd, offset, bytes, &retlen, val);
> +	if (err && err != -EUCLEAN)
> +		return err;
> +
> +	return retlen == bytes ? 0 : -EIO;
> +}
> +
> +static int mtd_nvmem_add(struct mtd_info *mtd)
> +{
> +	struct nvmem_config config = { };
> +
> +	config.dev = &mtd->dev;
> +	config.owner = THIS_MODULE;
> +	config.name = mtd->name;
> +	config.reg_read = mtd_nvmem_reg_read;
> +	config.size = mtd->size;
> +	config.word_size = 1;
> +	config.stride = 1;
> +	config.read_only = true;
> +	config.root_only = true;
> +	config.priv = mtd;
> +
> +	mtd->nvmem = devm_nvmem_register(&mtd->dev, &config);
> +	if (IS_ERR(mtd->nvmem)) {
> +		/* Just ignore if there is no NVMEM support in the kernel */
> +		if (PTR_ERR(mtd->nvmem) == -ENOSYS) {
> +			mtd->nvmem = NULL;
> +		} else {
> +			dev_err(&mtd->dev, "Failed to register NVMEM device\n");
> +			return PTR_ERR(mtd->nvmem);
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static struct dentry *dfs_dir_mtd;
>  
>  /**
> @@ -570,6 +613,11 @@ int add_mtd_device(struct mtd_info *mtd)
>  	if (error)
>  		goto fail_added;
>  
> +	/* Add the nvmem provider */
> +	error = mtd_nvmem_add(mtd);
> +	if (error)
> +		goto fail_nvmem_add;
> +
>  	if (!IS_ERR_OR_NULL(dfs_dir_mtd)) {
>  		mtd->dbg.dfs_dir = debugfs_create_dir(dev_name(&mtd->dev), dfs_dir_mtd);
>  		if (IS_ERR_OR_NULL(mtd->dbg.dfs_dir)) {
> @@ -595,6 +643,8 @@ int add_mtd_device(struct mtd_info *mtd)
>  	__module_get(THIS_MODULE);
>  	return 0;
>  
> +fail_nvmem_add:
> +	device_unregister(&mtd->dev);
>  fail_added:
>  	of_node_put(mtd_get_of_node(mtd));
>  	idr_remove(&mtd_idr, i);
> diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
> index a86c4fa93115..8121c6582285 100644
> --- a/include/linux/mtd/mtd.h
> +++ b/include/linux/mtd/mtd.h
> @@ -25,6 +25,7 @@
>  #include <linux/notifier.h>
>  #include <linux/device.h>
>  #include <linux/of.h>
> +#include <linux/nvmem-provider.h>
>  
>  #include <mtd/mtd-abi.h>
>  
> @@ -339,6 +340,7 @@ struct mtd_info {
>  	struct device dev;
>  	int usecount;
>  	struct mtd_debug_info dbg;
> +	struct nvmem_device *nvmem;
>  };
>  
>  int mtd_ooblayout_ecc(struct mtd_info *mtd, int section,


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

* Re: [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API
  2018-08-17 16:27   ` Boris Brezillon
@ 2018-08-19 11:31     ` Alban
  2018-08-19 16:46       ` Boris Brezillon
  0 siblings, 1 reply; 40+ messages in thread
From: Alban @ 2018-08-19 11:31 UTC (permalink / raw)
  To: Boris Brezillon
  Cc: Aban Bedel, Bartosz Golaszewski, Jonathan Corbet, Sekhar Nori,
	Kevin Hilman, Russell King, Arnd Bergmann, Greg Kroah-Hartman,
	David Woodhouse, Brian Norris, Marek Vasut, Richard Weinberger,
	Grygorii Strashko, David S . Miller, Srinivas Kandagatla, Naren,
	Mauro Carvalho Chehab, Andrew Morton, Lukas Wunner,
	Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Rob Herring, David Lechner,
	Andrew Lunn, linux-doc, linux-kernel, linux-arm-kernel,
	linux-i2c, linux-mtd, linux-omap, netdev, Bartosz Golaszewski

[-- Attachment #1: Type: text/plain, Size: 1475 bytes --]

On Fri, 17 Aug 2018 18:27:20 +0200
Boris Brezillon <boris.brezillon@bootlin.com> wrote:

> Hi Bartosz,
> 
> On Fri, 10 Aug 2018 10:05:03 +0200
> Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> 
> > From: Alban Bedel <albeu@free.fr>
> > 
> > Allow drivers that use the nvmem API to read data stored on MTD devices.
> > For this the mtd devices are registered as read-only NVMEM providers.
> > 
> > Signed-off-by: Alban Bedel <albeu@free.fr>
> > [Bartosz:
> >   - use the managed variant of nvmem_register(),
> >   - set the nvmem name]
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>  
> 
> What happened to the 2 other patches of Alban's series? I'd really
> like the DT case to be handled/agreed on in the same patchset, but
> IIRC, Alban and Srinivas disagreed on how this should be represented.
> I hope this time we'll come to an agreement, because the MTD <-> NVMEM
> glue has been floating around for quite some time...

These other patches were to fix what I consider a fundamental flaw in
the generic NVMEM bindings, however we couldn't agree on this point.
Bartosz later contacted me to take over this series and I suggested to
just change the MTD NVMEM binding to use a compatible string on the
NVMEM cells as an alternative solution to fix the clash with the old
style MTD partition.

However all this has no impact on the code needed to add NVMEM support
to MTD, so the above patch didn't change at all.

Alban

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API
  2018-08-19 11:31     ` Alban
@ 2018-08-19 16:46       ` Boris Brezillon
  2018-08-20 10:43         ` Srinivas Kandagatla
  0 siblings, 1 reply; 40+ messages in thread
From: Boris Brezillon @ 2018-08-19 16:46 UTC (permalink / raw)
  To: Alban, Srinivas Kandagatla
  Cc: Bartosz Golaszewski, Jonathan Corbet, Sekhar Nori, Kevin Hilman,
	Russell King, Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse,
	Brian Norris, Marek Vasut, Richard Weinberger, Grygorii Strashko,
	David S . Miller, Naren, Mauro Carvalho Chehab, Andrew Morton,
	Lukas Wunner, Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Rob Herring, David Lechner,
	Andrew Lunn, linux-doc, linux-kernel, linux-arm-kernel,
	linux-i2c, linux-mtd, linux-omap, netdev, Bartosz Golaszewski

On Sun, 19 Aug 2018 13:31:06 +0200
Alban <albeu@free.fr> wrote:

> On Fri, 17 Aug 2018 18:27:20 +0200
> Boris Brezillon <boris.brezillon@bootlin.com> wrote:
> 
> > Hi Bartosz,
> > 
> > On Fri, 10 Aug 2018 10:05:03 +0200
> > Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >   
> > > From: Alban Bedel <albeu@free.fr>
> > > 
> > > Allow drivers that use the nvmem API to read data stored on MTD devices.
> > > For this the mtd devices are registered as read-only NVMEM providers.
> > > 
> > > Signed-off-by: Alban Bedel <albeu@free.fr>
> > > [Bartosz:
> > >   - use the managed variant of nvmem_register(),
> > >   - set the nvmem name]
> > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>    
> > 
> > What happened to the 2 other patches of Alban's series? I'd really
> > like the DT case to be handled/agreed on in the same patchset, but
> > IIRC, Alban and Srinivas disagreed on how this should be represented.
> > I hope this time we'll come to an agreement, because the MTD <-> NVMEM
> > glue has been floating around for quite some time...  
> 
> These other patches were to fix what I consider a fundamental flaw in
> the generic NVMEM bindings, however we couldn't agree on this point.
> Bartosz later contacted me to take over this series and I suggested to
> just change the MTD NVMEM binding to use a compatible string on the
> NVMEM cells as an alternative solution to fix the clash with the old
> style MTD partition.
> 
> However all this has no impact on the code needed to add NVMEM support
> to MTD, so the above patch didn't change at all.

It does have an impact on the supported binding though.
nvmem->dev.of_node is automatically assigned to mtd->dev.of_node, which
means people will be able to define their NVMEM cells directly under
the MTD device and reference them from other nodes (even if it's not
documented), and as you said, it conflict with the old MTD partition
bindings. So we'd better agree on this binding before merging this
patch.

I see several options:

1/ provide a way to tell the NVMEM framework not to use parent->of_node
   even if it's != NULL. This way we really don't support defining
   NVMEM cells in the DT, and also don't support referencing the nvmem
   device using a phandle.

2/ define a new binding where all nvmem-cells are placed in an
   "nvmem" subnode (just like we have this "partitions" subnode for
   partitions), and then add a config->of_node field so that the
   nvmem provider can explicitly specify the DT node representing the
   nvmem device. We'll also need to set this field to ERR_PTR(-ENOENT)
   in case this node does not exist so that the nvmem framework knows
   that it should not assign nvmem->dev.of_node to parent->of_node

3/ only declare partitions as nvmem providers. This would solve the
   problem we have with partitions defined in the DT since
   defining sub-partitions in the DT is not (yet?) supported and
   partition nodes are supposed to be leaf nodes. Still, I'm not a big
   fan of this solution because it will prevent us from supporting
   sub-partitions if we ever want/need to.

4/ Add a ->of_xlate() hook that would be called if present by the
   framework instead of using the default parsing we have right now.

5/ Tell the nvmem framework the name of the subnode containing nvmem
   cell definitions (if NULL that means cells are directly defined
   under the nvmem provider node). We would set it to "nvmem-cells" (or
   whatever you like) for the MTD case.

There are probably other options (some were proposed by Alban and
Srinivas already), but I'd like to get this sorted out before we merge
this patch.

Alban, Srinivas, any opinion?

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

* Re: [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API
  2018-08-19 16:46       ` Boris Brezillon
@ 2018-08-20 10:43         ` Srinivas Kandagatla
  0 siblings, 0 replies; 40+ messages in thread
From: Srinivas Kandagatla @ 2018-08-20 10:43 UTC (permalink / raw)
  To: Boris Brezillon, Alban
  Cc: Bartosz Golaszewski, Jonathan Corbet, Sekhar Nori, Kevin Hilman,
	Russell King, Arnd Bergmann, Greg Kroah-Hartman, David Woodhouse,
	Brian Norris, Marek Vasut, Richard Weinberger, Grygorii Strashko,
	David S . Miller, Naren, Mauro Carvalho Chehab, Andrew Morton,
	Lukas Wunner, Dan Carpenter, Florian Fainelli, Ivan Khoronzhuk,
	Sven Van Asbroeck, Paolo Abeni, Rob Herring, David Lechner,
	Andrew Lunn, linux-doc, linux-kernel, linux-arm-kernel,
	linux-i2c, linux-mtd, linux-omap, netdev, Bartosz Golaszewski

Thanks Boris, for looking into this in more detail.

On 19/08/18 17:46, Boris Brezillon wrote:
> On Sun, 19 Aug 2018 13:31:06 +0200
> Alban <albeu@free.fr> wrote:
> 
>> On Fri, 17 Aug 2018 18:27:20 +0200
>> Boris Brezillon <boris.brezillon@bootlin.com> wrote:
>>
>>> Hi Bartosz,
>>>
>>> On Fri, 10 Aug 2018 10:05:03 +0200
>>> Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>>>    
>>>> From: Alban Bedel <albeu@free.fr>
>>>>
>>>> Allow drivers that use the nvmem API to read data stored on MTD devices.
>>>> For this the mtd devices are registered as read-only NVMEM providers.
>>>>
>>>> Signed-off-by: Alban Bedel <albeu@free.fr>
>>>> [Bartosz:
>>>>    - use the managed variant of nvmem_register(),
>>>>    - set the nvmem name]
>>>> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>>>
>>> What happened to the 2 other patches of Alban's series? I'd really
>>> like the DT case to be handled/agreed on in the same patchset, but
>>> IIRC, Alban and Srinivas disagreed on how this should be represented.
>>> I hope this time we'll come to an agreement, because the MTD <-> NVMEM
>>> glue has been floating around for quite some time...
>>
>> These other patches were to fix what I consider a fundamental flaw in
>> the generic NVMEM bindings, however we couldn't agree on this point.
>> Bartosz later contacted me to take over this series and I suggested to
>> just change the MTD NVMEM binding to use a compatible string on the
>> NVMEM cells as an alternative solution to fix the clash with the old
>> style MTD partition.
>>
>> However all this has no impact on the code needed to add NVMEM support
>> to MTD, so the above patch didn't change at all.
> 
> It does have an impact on the supported binding though.
> nvmem->dev.of_node is automatically assigned to mtd->dev.of_node, which
> means people will be able to define their NVMEM cells directly under
> the MTD device and reference them from other nodes (even if it's not
> documented), and as you said, it conflict with the old MTD partition
> bindings. So we'd better agree on this binding before merging this
> patch.
> 

Yes, I agree with you!

> I see several options:
> 
> 1/ provide a way to tell the NVMEM framework not to use parent->of_node
>     even if it's != NULL. This way we really don't support defining
>     NVMEM cells in the DT, and also don't support referencing the nvmem
>     device using a phandle.
> 
Other options look much better than this one!

> 2/ define a new binding where all nvmem-cells are placed in an
>     "nvmem" subnode (just like we have this "partitions" subnode for
>     partitions), and then add a config->of_node field so that the
>     nvmem provider can explicitly specify the DT node representing the
>     nvmem device. We'll also need to set this field to ERR_PTR(-ENOENT)
>     in case this node does not exist so that the nvmem framework knows
>     that it should not assign nvmem->dev.of_node to parent->of_node
> 
This one looks promising, One Question though..

Do we expect that there would be nvmem cells in any of the partitions?
or
nvmem cell are only valid for unpartioned area?

Am sure that the nvmem cells would be in multiple partitions, Is it okay 
to have some parts of partition to be in a separate subnode?

I would like this case to be considered too.

> 3/ only declare partitions as nvmem providers. This would solve the
>     problem we have with partitions defined in the DT since
>     defining sub-partitions in the DT is not (yet?) supported and
>     partition nodes are supposed to be leaf nodes. Still, I'm not a big
>     fan of this solution because it will prevent us from supporting
>     sub-partitions if we ever want/need to.
> 
This one is going to come back so, its better we

> 4/ Add a ->of_xlate() hook that would be called if present by the
>     framework instead of using the default parsing we have right now.
This looks much cleaner! We could hook that up under 
__nvmem_device_get() to do that translation.

> 
> 5/ Tell the nvmem framework the name of the subnode containing nvmem
>     cell definitions (if NULL that means cells are directly defined
>     under the nvmem provider node). We would set it to "nvmem-cells" (or
>     whatever you like) for the MTD case.
Option 2 looks better than this.

> 
> There are probably other options (some were proposed by Alban and
> Srinivas already), but I'd like to get this sorted out before we merge
> this patch.
> 
> Alban, Srinivas, any opinion?

Overall am still not able to clear visualize on how MTD bindings with 
nvmem cells would look in both partition and un-partition usecases?
An example DT would be nice here!!

Option 4 looks like much generic solution to me, may be we should try 
this once bindings on MTD side w.r.t nvmem cells are decided.

Thanks,
Srini

> 

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

end of thread, back to index

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10  8:04 [PATCH v2 00/29] at24: remove at24_platform_data Bartosz Golaszewski
2018-08-10  8:04 ` [PATCH v2 01/29] nvmem: add support for cell lookups Bartosz Golaszewski
2018-08-10  8:04 ` [PATCH v2 02/29] Documentation: nvmem: document lookup entries Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 03/29] nvmem: add a notifier chain Bartosz Golaszewski
2018-08-10  8:33   ` Srinivas Kandagatla
2018-08-10  8:05 ` [PATCH v2 04/29] nvmem: provide nvmem_dev_name() Bartosz Golaszewski
2018-08-10  8:10   ` Srinivas Kandagatla
2018-08-10  8:05 ` [PATCH v2 05/29] nvmem: remove the name field from struct nvmem_device Bartosz Golaszewski
2018-08-10  8:33   ` Srinivas Kandagatla
2018-08-10  8:05 ` [PATCH v2 06/29] mtd: Add support for reading MTD devices via the nvmem API Bartosz Golaszewski
2018-08-17 16:27   ` Boris Brezillon
2018-08-19 11:31     ` Alban
2018-08-19 16:46       ` Boris Brezillon
2018-08-20 10:43         ` Srinivas Kandagatla
2018-08-10  8:05 ` [PATCH v2 07/29] ARM: davinci: dm365-evm: use nvmem lookup for mac address Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 08/29] ARM: davinci: dm644-evm: " Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 09/29] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 10/29] ARM: davinci: da830-evm: " Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 11/29] ARM: davinci: mityomapl138: add nvmem cells lookup entries Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 12/29] ARM: davinci: da850-evm: use nvmem lookup for mac address Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 13/29] ARM: davinci: da850-evm: remove unnecessary include Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 14/29] net: simplify eth_platform_get_mac_address() Bartosz Golaszewski
2018-08-10 14:39   ` Andy Shevchenko
2018-08-10 16:17     ` Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 15/29] net: split eth_platform_get_mac_address() into subroutines Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 16/29] net: add support for nvmem to eth_platform_get_mac_address() Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 17/29] net: davinci_emac: use eth_platform_get_mac_address() Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 18/29] ARM: davinci: da850-evm: remove dead MTD code Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 19/29] ARM: davinci: mityomapl138: don't read the MAC address from machine code Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 20/29] ARM: davinci: dm365-evm: use device properties for at24 eeprom Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 21/29] ARM: davinci: da830-evm: " Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 22/29] ARM: davinci: dm644x-evm: " Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 23/29] ARM: davinci: dm646x-evm: " Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 24/29] ARM: davinci: sffsdr: fix the at24 eeprom device name Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 25/29] ARM: davinci: sffsdr: use device properties for at24 eeprom Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 26/29] ARM: davinci: remove dead code related to MAC address reading Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 27/29] ARM: davinci: mityomapl138: use nvmem notifiers Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 28/29] ARM: davinci: mityomapl138: use device properties for at24 eeprom Bartosz Golaszewski
2018-08-10  8:05 ` [PATCH v2 29/29] eeprom: at24: kill at24_platform_data Bartosz Golaszewski
2018-08-10  8:41 ` [PATCH v2 00/29] at24: remove at24_platform_data Srinivas Kandagatla

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox