Skip to contentSkip to conversation

Verbatim device names and devm_nvmem_(un)register()

PATCH Superseded Andrey Smirnov 2 participants 26 messages Jan 1, 2018 – Jan 2, 2018

Subsystems (7)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Verbatim device names and devm_nvmem_(un)register()

Srinivas, all:

This patchset contains various small changes that I recently made to NVMEM, more specifically:

- Patches 1 and 2 are two changes I am hoping are acceptable upstream

- Patches 3 to 14 are a follow up to patch 2

- Patches 15 to 21 are just trivial fixups and I am more than happy to drop them if they seem to add more pointless churn rather then value.

Feedback is appreciated!

Thanks,
Andrey Smirnov

Changes since [v1]:

- Fixed a build break detected by kbuild test robot

- Added a patch to unconditionally enable COMPILE_TEST for meson-efuse

- Dropped Joachim Eastwood from CC list due to bouncing e-mail

[v1] lkml.kernel.org/r/20171227225956.14442-1-andrew.smirnov at gmail.com

Andrey Smirnov (21):
nvmem: core: Allow specifying device name verbatim
nvmem: Introduce devm_nvmem_(un)register()
nvmem: vf610-ocotp: Convert to use devm_nvmem_register()
nvmem: imx-ocotp: Convert to use devm_nvmem_register()
nvmem: uniphier-efuse: Convert to use devm_nvmem_register()
nvmem: snvs_lgpr: Convert to use devm_nvmem_register()
nvmem: rockchip-efuse: Convert to use devm_nvmem_register()
nvmem: qfprom: Convert to use devm_nvmem_register()
nvmem: mtk-efuse: Convert to use devm_nvmem_register()
nvmem: meson-mx-efuse: Convert to use devm_nvmem_register()
nvmem: meson-efuse: Convert to use devm_nvmem_register()
nvmem: lpc18xx_otp: Convert to use devm_nvmem_register()
nvmem: imx-iim: Convert to use devm_nvmem_register()
nvmem: bcm-ocotp: Convert to use devm_nvmem_register()
nvmem: meson-efuse: Do no gate COMPILE_TEST with MESON_SM
nvmem: snvs_lpgpr: Convert commas to semicolons
nvmem: rockchip-efuse: Make use of of_device_get_match_data()
nvmem: vf610-ocotp: Do not use "&pdev->dev" explicitly
nvmem: rockchip-efuse: Do not use "&pdev->dev" explicitly
nvmem: imx-iim: Do not use "&pdev->dev" explicitly
nvmem: bcm-ocotp: Do not use "&pdev->dev" explicitly

 drivers/nvmem/Kconfig          |  2 +-
 drivers/nvmem/bcm-ocotp.c      | 15 ++----------
 drivers/nvmem/core.c           | 52 +++++++++++++++++++++++++++++++++++++++---
 drivers/nvmem/imx-iim.c        | 14 ++----------
 drivers/nvmem/imx-ocotp.c      | 12 +---------
 drivers/nvmem/lpc18xx_otp.c    | 12 +---------
 drivers/nvmem/meson-efuse.c    | 12 +---------
 drivers/nvmem/meson-mx-efuse.c | 12 +---------
 drivers/nvmem/mtk-efuse.c      | 12 +---------
 drivers/nvmem/qfprom.c         | 12 +---------
 drivers/nvmem/rockchip-efuse.c | 28 ++++++++---------------
 drivers/nvmem/snvs_lpgpr.c     | 26 +++++++--------------
 drivers/nvmem/uniphier-efuse.c | 12 +---------
 drivers/nvmem/vf610-ocotp.c    | 15 ++----------
 include/linux/nvmem-provider.h | 17 ++++++++++++++
 15 files changed, 97 insertions(+), 156 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH v2 1/21 nvmem: core: Allow specifying device name verbatim

Add code to allow avoid having nvmem core append a numeric suffix to the end of the name by passing config->id of -1.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/core.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/nvmem/core.c +8 -3
index 5a5cefd12153..57cbeacfbeb2 100644
@@ -475,9 +475,14 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	nvmem->reg_write = config->reg_write;
 	np = config->dev->of_node;
 	nvmem->dev.of_node = np;
-	dev_set_name(&nvmem->dev, "%s%d",
-		     config->name ? : "nvmem",
-		     config->name ? config->id : nvmem->id);
+
+	if (config->id == -1 && config->name) {
+		dev_set_name(&nvmem->dev, "%s", config->name);
+	} else {
+		dev_set_name(&nvmem->dev, "%s%d",
+			     config->name ? : "nvmem",
+			     config->name ? config->id : nvmem->id);
+	}
 
 	nvmem->read_only = of_property_read_bool(np, "read-only") |
 			   config->read_only;
Signature · 1 line
2.14.3
#4 lore raw

PATCH v2 2/21 nvmem: Introduce devm_nvmem_(un)register()

In reply to Andrey Smirnov

Introduce devm_nvmem_register()/devm_nvmem_unregister() to make .remove() unnecessary in trivial drivers.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/core.c           | 41 +++++++++++++++++++++++++++++++++++++++++
 include/linux/nvmem-provider.h | 17 +++++++++++++++++
 2 files changed, 58 insertions(+)
drivers/nvmem/core.c +41 -0
index 57cbeacfbeb2..84f07ba1f36d 100644
@@ -551,6 +551,47 @@ int nvmem_unregister(struct nvmem_device *nvmem)
 }
 EXPORT_SYMBOL_GPL(nvmem_unregister);
 
+static void devm_nvmem_release(struct device *dev, void *res)
+{
+	WARN_ON(nvmem_unregister(*(struct nvmem_device **)res));
+}
+
+struct nvmem_device *devm_nvmem_register(struct device *dev,
+					 const struct nvmem_config *config)
+{
+	struct nvmem_device **ptr, *nvmem;
+
+	ptr = devres_alloc(devm_nvmem_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return ERR_PTR(-ENOMEM);
+
+	nvmem = nvmem_register(config);
+
+	if (!IS_ERR(nvmem)) {
+		*ptr = nvmem;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return nvmem;
+}
+EXPORT_SYMBOL_GPL(devm_nvmem_register);
+
+static int devm_nvmem_match(struct device *dev, void *res, void *data)
+{
+	struct nvmem_device **r = res;
+
+	return *r == data;
+}
+
+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
+{
+	return devres_release(dev, devm_nvmem_release, devm_nvmem_match, nvmem);
+}
+EXPORT_SYMBOL(devm_nvmem_unregister);
+
+
 static struct nvmem_device *__nvmem_device_get(struct device_node *np,
 					       struct nvmem_cell **cellp,
 					       const char *cell_id)
include/linux/nvmem-provider.h +17 -0
index 497706f5adca..493f2f529f00 100644
@@ -47,6 +47,11 @@ struct nvmem_config {
 struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
 int nvmem_unregister(struct nvmem_device *nvmem);
 
+struct nvmem_device *devm_nvmem_register(struct device *dev,
+					 const struct nvmem_config *cfg);
+
+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
+
 #else
 
 static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
@@ -59,5 +64,17 @@ static inline int nvmem_unregister(struct nvmem_device *nvmem)
 	return -ENOSYS;
 }
 
+static inline struct nvmem_device *
+devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
+{
+	return nvmem_register(c);
+}
+
+static inline int
+devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
+{
+	return nvmem_unregister(nvmem);
+}
+
 #endif /* CONFIG_NVMEM */
 #endif  /* ifndef _LINUX_NVMEM_PROVIDER_H */
Signature · 1 line
2.14.3
#7 lore raw

PATCH v2 3/21 nvmem: vf610-ocotp: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/vf610-ocotp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/vf610-ocotp.c +1 -11
index 5ae9e002f195..752a0983e7fb 100644
@@ -217,13 +217,6 @@ static const struct of_device_id ocotp_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ocotp_of_match);
 
-static int vf610_ocotp_remove(struct platform_device *pdev)
-{
-	struct vf610_ocotp *ocotp_dev = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(ocotp_dev->nvmem);
-}
-
 static int vf610_ocotp_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -251,13 +244,11 @@ static int vf610_ocotp_probe(struct platform_device *pdev)
 	ocotp_config.priv = ocotp_dev;
 	ocotp_config.dev = dev;
 
-	ocotp_dev->nvmem = nvmem_register(&ocotp_config);
+	ocotp_dev->nvmem = devm_nvmem_register(dev, &ocotp_config);
 	if (IS_ERR(ocotp_dev->nvmem))
 		return PTR_ERR(ocotp_dev->nvmem);
 
 	ocotp_dev->dev = dev;
-	platform_set_drvdata(pdev, ocotp_dev);
-
 	ocotp_dev->timing = vf610_ocotp_calculate_timing(ocotp_dev);
 
 	return 0;
@@ -265,7 +256,6 @@ static int vf610_ocotp_probe(struct platform_device *pdev)
 
 static struct platform_driver vf610_ocotp_driver = {
 	.probe = vf610_ocotp_probe,
-	.remove = vf610_ocotp_remove,
 	.driver = {
 		.name = "vf610-ocotp",
 		.of_match_table = ocotp_of_match,
Signature · 1 line
2.14.3
#8 lore raw

PATCH v2 4/21 nvmem: imx-ocotp: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/imx-ocotp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/imx-ocotp.c +1 -11
index d7ba351a70c9..68deffe636f3 100644
@@ -466,26 +466,16 @@ static int imx_ocotp_probe(struct platform_device *pdev)
 	imx_ocotp_nvmem_config.dev = dev;
 	imx_ocotp_nvmem_config.priv = priv;
 	priv->config = &imx_ocotp_nvmem_config;
-	nvmem = nvmem_register(&imx_ocotp_nvmem_config);
+	nvmem = devm_nvmem_register(dev, &imx_ocotp_nvmem_config);
 
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int imx_ocotp_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver imx_ocotp_driver = {
 	.probe	= imx_ocotp_probe,
-	.remove	= imx_ocotp_remove,
 	.driver = {
 		.name	= "imx_ocotp",
 		.of_match_table = imx_ocotp_dt_ids,
Signature · 1 line
2.14.3
#9 lore raw

PATCH v2 5/21 nvmem: uniphier-efuse: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/uniphier-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/uniphier-efuse.c +1 -11
index 9d278b4e1dc7..7ddc6fc012c9 100644
@@ -60,22 +60,13 @@ static int uniphier_efuse_probe(struct platform_device *pdev)
 	econfig.size = resource_size(res);
 	econfig.priv = priv;
 	econfig.dev = dev;
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int uniphier_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id uniphier_efuse_of_match[] = {
 	{ .compatible = "socionext,uniphier-efuse",},
 	{/* sentinel */},
@@ -84,7 +75,6 @@ MODULE_DEVICE_TABLE(of, uniphier_efuse_of_match);
 
 static struct platform_driver uniphier_efuse_driver = {
 	.probe = uniphier_efuse_probe,
-	.remove = uniphier_efuse_remove,
 	.driver = {
 		.name = "uniphier-efuse",
 		.of_match_table = uniphier_efuse_of_match,
Signature · 1 line
2.14.3
#10 lore raw

PATCH v2 6/21 nvmem: snvs_lgpr: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/snvs_lpgpr.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/snvs_lpgpr.c +1 -11
index e5c2a4a17f03..6a2fdd09e74a 100644
@@ -117,22 +117,13 @@ static int snvs_lpgpr_probe(struct platform_device *pdev)
 	cfg->reg_read  = snvs_lpgpr_read,
 	cfg->reg_write = snvs_lpgpr_write,
 
-	nvmem = nvmem_register(cfg);
+	nvmem = devm_nvmem_register(dev, cfg);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int snvs_lpgpr_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id snvs_lpgpr_dt_ids[] = {
 	{ .compatible = "fsl,imx6q-snvs-lpgpr", .data = &snvs_lpgpr_cfg_imx6q },
 	{ .compatible = "fsl,imx6ul-snvs-lpgpr",
@@ -143,7 +134,6 @@ MODULE_DEVICE_TABLE(of, snvs_lpgpr_dt_ids);
 
 static struct platform_driver snvs_lpgpr_driver = {
 	.probe	= snvs_lpgpr_probe,
-	.remove	= snvs_lpgpr_remove,
 	.driver = {
 		.name	= "snvs_lpgpr",
 		.of_match_table = snvs_lpgpr_dt_ids,
Signature · 1 line
2.14.3
#11 lore raw

PATCH v2 7/21 nvmem: rockchip-efuse: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/rockchip-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/rockchip-efuse.c +1 -11
index 123de77ca5d6..d6dc1330f895 100644
@@ -221,25 +221,15 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 	econfig.reg_read = match->data;
 	econfig.priv = efuse;
 	econfig.dev = efuse->dev;
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int rockchip_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver rockchip_efuse_driver = {
 	.probe = rockchip_efuse_probe,
-	.remove = rockchip_efuse_remove,
 	.driver = {
 		.name = "rockchip-efuse",
 		.of_match_table = rockchip_efuse_match,
Signature · 1 line
2.14.3
#12 lore raw

PATCH v2 8/21 nvmem: qfprom: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/qfprom.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/qfprom.c +1 -11
index cb3b48b47d64..13bf43c84bd4 100644
@@ -47,13 +47,6 @@ static int qfprom_reg_write(void *context,
 	return 0;
 }
 
-static int qfprom_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct nvmem_config econfig = {
 	.name = "qfprom",
 	.stride = 1,
@@ -82,12 +75,10 @@ static int qfprom_probe(struct platform_device *pdev)
 	econfig.dev = dev;
 	econfig.priv = priv;
 
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
@@ -99,7 +90,6 @@ MODULE_DEVICE_TABLE(of, qfprom_of_match);
 
 static struct platform_driver qfprom_driver = {
 	.probe = qfprom_probe,
-	.remove = qfprom_remove,
 	.driver = {
 		.name = "qcom,qfprom",
 		.of_match_table = qfprom_of_match,
Signature · 1 line
2.14.3
#13 lore raw

PATCH v2 9/21 nvmem: mtk-efuse: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/mtk-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/mtk-efuse.c +1 -11
index 9ee3479cfc7b..97ab7e6a4789 100644
@@ -72,22 +72,13 @@ static int mtk_efuse_probe(struct platform_device *pdev)
 	econfig.size = resource_size(res);
 	econfig.priv = priv;
 	econfig.dev = dev;
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int mtk_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id mtk_efuse_of_match[] = {
 	{ .compatible = "mediatek,mt8173-efuse",},
 	{ .compatible = "mediatek,efuse",},
@@ -97,7 +88,6 @@ MODULE_DEVICE_TABLE(of, mtk_efuse_of_match);
 
 static struct platform_driver mtk_efuse_driver = {
 	.probe = mtk_efuse_probe,
-	.remove = mtk_efuse_remove,
 	.driver = {
 		.name = "mediatek,efuse",
 		.of_match_table = mtk_efuse_of_match,
Signature · 1 line
2.14.3
#14 lore raw

PATCH v2 10/21 nvmem: meson-mx-efuse: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/meson-mx-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/meson-mx-efuse.c +1 -11
index a346b4923550..f8e0b92e40ba 100644
@@ -233,25 +233,15 @@ static int meson_mx_efuse_probe(struct platform_device *pdev)
 		return PTR_ERR(efuse->core_clk);
 	}
 
-	efuse->nvmem = nvmem_register(&efuse->config);
+	efuse->nvmem = devm_nvmem_register(&pdev->dev, &efuse->config);
 	if (IS_ERR(efuse->nvmem))
 		return PTR_ERR(efuse->nvmem);
 
-	platform_set_drvdata(pdev, efuse);
-
 	return 0;
 }
 
-static int meson_mx_efuse_remove(struct platform_device *pdev)
-{
-	struct meson_mx_efuse *efuse = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(efuse->nvmem);
-}
-
 static struct platform_driver meson_mx_efuse_driver = {
 	.probe = meson_mx_efuse_probe,
-	.remove = meson_mx_efuse_remove,
 	.driver = {
 		.name = "meson-mx-efuse",
 		.of_match_table = meson_mx_efuse_match,
Signature · 1 line
2.14.3
#15 lore raw

PATCH v2 11/21 nvmem: meson-efuse: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/meson-efuse.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/meson-efuse.c +1 -11
index a43c68f90937..66029fc85ba9 100644
@@ -60,25 +60,15 @@ static int meson_efuse_probe(struct platform_device *pdev)
 	econfig.reg_read = meson_efuse_read;
 	econfig.size = size;
 
-	nvmem = nvmem_register(&econfig);
+	nvmem = devm_nvmem_register(&pdev->dev, &econfig);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int meson_efuse_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver meson_efuse_driver = {
 	.probe = meson_efuse_probe,
-	.remove = meson_efuse_remove,
 	.driver = {
 		.name = "meson-efuse",
 		.of_match_table = meson_efuse_match,
Signature · 1 line
2.14.3
#16 lore raw

PATCH v2 12/21 nvmem: lpc18xx_otp: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/lpc18xx_otp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/lpc18xx_otp.c +1 -11
index 95268db155e9..74777bfe2dcd 100644
@@ -86,22 +86,13 @@ static int lpc18xx_otp_probe(struct platform_device *pdev)
 	lpc18xx_otp_nvmem_config.dev = &pdev->dev;
 	lpc18xx_otp_nvmem_config.priv = otp;
 
-	nvmem = nvmem_register(&lpc18xx_otp_nvmem_config);
+	nvmem = devm_nvmem_register(&pdev->dev, &lpc18xx_otp_nvmem_config);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int lpc18xx_otp_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static const struct of_device_id lpc18xx_otp_dt_ids[] = {
 	{ .compatible = "nxp,lpc1850-otp" },
 	{ },
@@ -110,7 +101,6 @@ MODULE_DEVICE_TABLE(of, lpc18xx_otp_dt_ids);
 
 static struct platform_driver lpc18xx_otp_driver = {
 	.probe	= lpc18xx_otp_probe,
-	.remove	= lpc18xx_otp_remove,
 	.driver = {
 		.name	= "lpc18xx_otp",
 		.of_match_table = lpc18xx_otp_dt_ids,
Signature · 1 line
2.14.3
#17 lore raw

PATCH v2 13/21 nvmem: imx-iim: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/imx-iim.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/imx-iim.c +1 -11
index 52cfe91d9762..635561a441bd 100644
@@ -138,25 +138,15 @@ static int imx_iim_probe(struct platform_device *pdev)
 	cfg.size = drvdata->nregs;
 	cfg.priv = iim;
 
-	nvmem = nvmem_register(&cfg);
+	nvmem = devm_nvmem_register(dev, &cfg);
 	if (IS_ERR(nvmem))
 		return PTR_ERR(nvmem);
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int imx_iim_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver imx_iim_driver = {
 	.probe	= imx_iim_probe,
-	.remove	= imx_iim_remove,
 	.driver = {
 		.name	= "imx-iim",
 		.of_match_table = imx_iim_dt_ids,
Signature · 1 line
2.14.3
#18 lore raw

PATCH v2 14/21 nvmem: bcm-ocotp: Convert to use devm_nvmem_register()

In reply to Andrey Smirnov

Drop all of the code related to .remove hook and make use of devm_nvmem_register() instead.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/bcm-ocotp.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/nvmem/bcm-ocotp.c +1 -11
index 5e9e324427f9..24c30fa475cc 100644
@@ -302,27 +302,17 @@ static int bcm_otpc_probe(struct platform_device *pdev)
 
 	priv->config = &bcm_otpc_nvmem_config;
 
-	nvmem = nvmem_register(&bcm_otpc_nvmem_config);
+	nvmem = devm_nvmem_register(dev, &bcm_otpc_nvmem_config);
 	if (IS_ERR(nvmem)) {
 		dev_err(dev, "error registering nvmem config\n");
 		return PTR_ERR(nvmem);
 	}
 
-	platform_set_drvdata(pdev, nvmem);
-
 	return 0;
 }
 
-static int bcm_otpc_remove(struct platform_device *pdev)
-{
-	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
-
-	return nvmem_unregister(nvmem);
-}
-
 static struct platform_driver bcm_otpc_driver = {
 	.probe	= bcm_otpc_probe,
-	.remove	= bcm_otpc_remove,
 	.driver = {
 		.name	= "brcm-otpc",
 		.of_match_table = bcm_otpc_dt_ids,
Signature · 1 line
2.14.3
#19 lore raw

PATCH v2 15/21 nvmem: meson-efuse: Do no gate COMPILE_TEST with MESON_SM

In reply to Andrey Smirnov

Being able to build this driver when COMPILE_TEST is selected is still useful even when MESON_SM is not selected, since selecting this driver as a module and doing "make modules" will result in successful build and would detect trivial coding errors. For an example of type of errors that could be prevented see [1] and [2]

[1] lkml.kernel.org/r/20171227225956.14442-12-andrew.smirnov at gmail.com
[2] https://marc.info/?l=linux-arm-kernel&m=151461599104358&w=2

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/Kconfig +1 -1
index ff505af064ba..42e84e1b2a26 100644
@@ -147,7 +147,7 @@ config NVMEM_VF610_OCOTP
 
 config MESON_EFUSE
 	tristate "Amlogic Meson GX eFuse Support"
-	depends on (ARCH_MESON || COMPILE_TEST) && MESON_SM
+	depends on (ARCH_MESON && MESON_SM) || COMPILE_TEST
 	help
 	  This is a driver to retrieve specific values from the eFuse found on
 	  the Amlogic Meson GX SoCs.
Signature · 1 line
2.14.3
#20 lore raw

PATCH v2 16/21 nvmem: snvs_lpgpr: Convert commas to semicolons

In reply to Andrey Smirnov

Looks like commas were accidentally used where semicolons were supposed to be. Fix that.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/snvs_lpgpr.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/nvmem/snvs_lpgpr.c +6 -6
index 6a2fdd09e74a..90aaf818563b 100644
@@ -110,12 +110,12 @@ static int snvs_lpgpr_probe(struct platform_device *pdev)
 	cfg->priv = priv;
 	cfg->name = dev_name(dev);
 	cfg->dev = dev;
-	cfg->stride = 4,
-	cfg->word_size = 4,
-	cfg->size = 4,
-	cfg->owner = THIS_MODULE,
-	cfg->reg_read  = snvs_lpgpr_read,
-	cfg->reg_write = snvs_lpgpr_write,
+	cfg->stride = 4;
+	cfg->word_size = 4;
+	cfg->size = 4;
+	cfg->owner = THIS_MODULE;
+	cfg->reg_read  = snvs_lpgpr_read;
+	cfg->reg_write = snvs_lpgpr_write;
 
 	nvmem = devm_nvmem_register(dev, cfg);
 	if (IS_ERR(nvmem))
Signature · 1 line
2.14.3
#21 lore raw

PATCH v2 17/21 nvmem: rockchip-efuse: Make use of of_device_get_match_data()

In reply to Andrey Smirnov

Simplify code a bit by using of_device_get_match_data() instead of of_match_device().

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/rockchip-efuse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/nvmem/rockchip-efuse.c +4 -4
index d6dc1330f895..979ba0a376a0 100644
@@ -193,11 +193,11 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct nvmem_device *nvmem;
 	struct rockchip_efuse_chip *efuse;
-	const struct of_device_id *match;
+	const void *data;
 	struct device *dev = &pdev->dev;
 
-	match = of_match_device(dev->driver->of_match_table, dev);
-	if (!match || !match->data) {
+	data = of_device_get_match_data(dev);
+	if (!data) {
 		dev_err(dev, "failed to get match data\n");
 		return -EINVAL;
 	}
@@ -218,7 +218,7 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 
 	efuse->dev = &pdev->dev;
 	econfig.size = resource_size(res);
-	econfig.reg_read = match->data;
+	econfig.reg_read = data;
 	econfig.priv = efuse;
 	econfig.dev = efuse->dev;
 	nvmem = devm_nvmem_register(dev, &econfig);
Signature · 1 line
2.14.3
#22 lore raw

PATCH v2 18/21 nvmem: vf610-ocotp: Do not use "&pdev->dev" explicitly

In reply to Andrey Smirnov

There already a "dev" variable for that. Use it.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/vf610-ocotp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/nvmem/vf610-ocotp.c +1 -2
index 752a0983e7fb..6e6bf7987d9d 100644
@@ -223,8 +223,7 @@ static int vf610_ocotp_probe(struct platform_device *pdev)
 	struct resource *res;
 	struct vf610_ocotp *ocotp_dev;
 
-	ocotp_dev = devm_kzalloc(&pdev->dev,
-			sizeof(struct vf610_ocotp), GFP_KERNEL);
+	ocotp_dev = devm_kzalloc(dev, sizeof(struct vf610_ocotp), GFP_KERNEL);
 	if (!ocotp_dev)
 		return -ENOMEM;
 
Signature · 1 line
2.14.3
#23 lore raw

PATCH v2 19/21 nvmem: rockchip-efuse: Do not use "&pdev->dev" explicitly

In reply to Andrey Smirnov

There's "dev" variable for this already. Use it.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/rockchip-efuse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/nvmem/rockchip-efuse.c +4 -4
index 979ba0a376a0..3120329aea94 100644
@@ -202,21 +202,21 @@ static int rockchip_efuse_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	efuse = devm_kzalloc(&pdev->dev, sizeof(struct rockchip_efuse_chip),
+	efuse = devm_kzalloc(dev, sizeof(struct rockchip_efuse_chip),
 			     GFP_KERNEL);
 	if (!efuse)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	efuse->base = devm_ioremap_resource(&pdev->dev, res);
+	efuse->base = devm_ioremap_resource(dev, res);
 	if (IS_ERR(efuse->base))
 		return PTR_ERR(efuse->base);
 
-	efuse->clk = devm_clk_get(&pdev->dev, "pclk_efuse");
+	efuse->clk = devm_clk_get(dev, "pclk_efuse");
 	if (IS_ERR(efuse->clk))
 		return PTR_ERR(efuse->clk);
 
-	efuse->dev = &pdev->dev;
+	efuse->dev = dev;
 	econfig.size = resource_size(res);
 	econfig.reg_read = data;
 	econfig.priv = efuse;
Signature · 1 line
2.14.3
#24 lore raw

PATCH v2 20/21 nvmem: imx-iim: Do not use "&pdev->dev" explicitly

In reply to Andrey Smirnov

There's already "dev" variable for that. Use it.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/imx-iim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/imx-iim.c +1 -1
index 635561a441bd..3022bd96bd7e 100644
@@ -125,7 +125,7 @@ static int imx_iim_probe(struct platform_device *pdev)
 
 	drvdata = of_id->data;
 
-	iim->clk = devm_clk_get(&pdev->dev, NULL);
+	iim->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(iim->clk))
 		return PTR_ERR(iim->clk);
 
Signature · 1 line
2.14.3
#25 lore raw

PATCH v2 21/21 nvmem: bcm-ocotp: Do not use "&pdev->dev" explicitly

In reply to Andrey Smirnov

There's "dev" variable for this already. Use it.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
---
 drivers/nvmem/bcm-ocotp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/nvmem/bcm-ocotp.c +1 -2
index 24c30fa475cc..4159b3f41d79 100644
@@ -262,8 +262,7 @@ static int bcm_otpc_probe(struct platform_device *pdev)
 	else if (of_device_is_compatible(dev->of_node, "brcm,ocotp-v2"))
 		priv->map = &otp_map_v2;
 	else {
-		dev_err(&pdev->dev,
-			"%s otpc config map not defined\n", __func__);
+		dev_err(dev, "%s otpc config map not defined\n", __func__);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.14.3
#2 lore raw

Re: [PATCH v2 01/21] nvmem: core: Allow specifying device name verbatim

In reply to Andrey Smirnov

Thanks for the Patch,

Quoted 16 lines · Andrey Smirnov

Add code to allow avoid having nvmem core append a numeric suffix to the end of the name by passing config->id of -1.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
Quoted 4 lines
---
  drivers/nvmem/core.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)

This looks fine for me, Can you also add a line in kernel doc about this behavior.

thanks,
srini

Quoted 23 lines
drivers/nvmem/core.c +8 -3
index 5a5cefd12153..57cbeacfbeb2 100644
@@ -475,9 +475,14 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
  	nvmem->reg_write = config->reg_write;
  	np = config->dev->of_node;
  	nvmem->dev.of_node = np;
-	dev_set_name(&nvmem->dev, "%s%d",
-		     config->name ? : "nvmem",
-		     config->name ? config->id : nvmem->id);
+
+	if (config->id == -1 && config->name) {
+		dev_set_name(&nvmem->dev, "%s", config->name);
+	} else {
+		dev_set_name(&nvmem->dev, "%s%d",
+			     config->name ? : "nvmem",
+			     config->name ? config->id : nvmem->id);
+	}
 
  	nvmem->read_only = of_property_read_bool(np, "read-only") |
  			   config->read_only;
#5 lore raw

Re: [PATCH v2 02/21] nvmem: Introduce devm_nvmem_(un)register()

In reply to Andrey Smirnov

Thanks for the patch,

Quoted 16 lines · Andrey Smirnov

Introduce devm_nvmem_register()/devm_nvmem_unregister() to make .remove() unnecessary in trivial drivers.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
Quoted 5 lines
---
  drivers/nvmem/core.c           | 41 +++++++++++++++++++++++++++++++++++++++++
  include/linux/nvmem-provider.h | 17 +++++++++++++++++
  2 files changed, 58 insertions(+)

Patch looks good, kernel doc for these exported symbols are missing, you should add them in next version!

Thanks,
Srini

Quoted 87 lines
drivers/nvmem/core.c +41 -0
index 57cbeacfbeb2..84f07ba1f36d 100644
@@ -551,6 +551,47 @@ int nvmem_unregister(struct nvmem_device *nvmem)
  }
  EXPORT_SYMBOL_GPL(nvmem_unregister);
 
+static void devm_nvmem_release(struct device *dev, void *res)
+{
+	WARN_ON(nvmem_unregister(*(struct nvmem_device **)res));
+}
+
+struct nvmem_device *devm_nvmem_register(struct device *dev,
+					 const struct nvmem_config *config)
+{
+	struct nvmem_device **ptr, *nvmem;
+
+	ptr = devres_alloc(devm_nvmem_release, sizeof(*ptr), GFP_KERNEL);
+	if (!ptr)
+		return ERR_PTR(-ENOMEM);
+
+	nvmem = nvmem_register(config);
+
+	if (!IS_ERR(nvmem)) {
+		*ptr = nvmem;
+		devres_add(dev, ptr);
+	} else {
+		devres_free(ptr);
+	}
+
+	return nvmem;
+}
+EXPORT_SYMBOL_GPL(devm_nvmem_register);
+
+static int devm_nvmem_match(struct device *dev, void *res, void *data)
+{./drivers/base/devres.c
+	struct nvmem_device **r = res;
+
+	return *r == data;
+}
+
+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
+{
+	return devres_release(dev, devm_nvmem_release, devm_nvmem_match, nvmem);
+}
+EXPORT_SYMBOL(devm_nvmem_unregister);
+
+
  static struct nvmem_device *__nvmem_device_get(struct device_node *np,
  					       struct nvmem_cell **cellp,
  					       const char *cell_id)
include/linux/nvmem-provider.h +17 -0
index 497706f5adca..493f2f529f00 100644
@@ -47,6 +47,11 @@ struct nvmem_config {
  struct nvmem_device *nvmem_register(const struct nvmem_config *cfg);
  int nvmem_unregister(struct nvmem_device *nvmem);
 
+struct nvmem_device *devm_nvmem_register(struct device *dev,
+					 const struct nvmem_config *cfg);
+
+int devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem);
+
  #else
 
  static inline struct nvmem_device *nvmem_register(const struct nvmem_config *c)
@@ -59,5 +64,17 @@ static inline int nvmem_unregister(struct nvmem_device *nvmem)
  	return -ENOSYS;
  }
 
+static inline struct nvmem_device *
+devm_nvmem_register(struct device *dev, const struct nvmem_config *c)
+{
+	return nvmem_register(c);
+}
+
+static inline int
+devm_nvmem_unregister(struct device *dev, struct nvmem_device *nvmem)
+{
+	return nvmem_unregister(nvmem);
+}
+
  #endif /* CONFIG_NVMEM */
  #endif  /* ifndef _LINUX_NVMEM_PROVIDER_H */
#3 lore raw

Re: [PATCH v2 01/21] nvmem: core: Allow specifying device name verbatim

In reply to Srinivas Kandagatla
Quoted 24 lines · Srinivas Kandagatla

Thanks for the Patch,

Quoted 17 lines · Andrey Smirnov

Add code to allow avoid having nvmem core append a numeric suffix to the end of the name by passing config->id of -1.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
Quoted 4 lines
---
  drivers/nvmem/core.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)
Quoted 3 lines

This looks fine for me, Can you also add a line in kernel doc about this behavior.

Sure, will do in v3.

Thanks,
Andrey Smirnov

#6 lore raw

Re: [PATCH v2 02/21] nvmem: Introduce devm_nvmem_(un)register()

In reply to Srinivas Kandagatla
Quoted 26 lines · Srinivas Kandagatla

Thanks for the patch,

Quoted 17 lines · Andrey Smirnov

Introduce devm_nvmem_register()/devm_nvmem_unregister() to make .remove() unnecessary in trivial drivers.

Cc Srinivas Kandagatla <[email protected]>
Cc Heiko Stuebner <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Carlo Caione <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc Matthias Brugger <[email protected]>
Cc cphealy at gmail.com
Cc linux-kernel at vger.kernel.org
Cc linux-mediatek at lists.infradead.org
Cc linux-rockchip at lists.infradead.org
Cc linux-amlogic at lists.infradead.org
Cc linux-arm-kernel at lists.infradead.org
Quoted 6 lines
---
  drivers/nvmem/core.c           | 41
+++++++++++++++++++++++++++++++++++++++++
  include/linux/nvmem-provider.h | 17 +++++++++++++++++
  2 files changed, 58 insertions(+)
Quoted 3 lines

Patch looks good, kernel doc for these exported symbols are missing, you should add them in next version!

Good point! Will do in v3.

Thanks,
Andrey Smirnov