linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] nvmem: patches (set 1) for 5.10
@ 2020-09-17 13:44 Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 1/4] nvmem: mtk-efuse: Remove EFUSE register write support Srinivas Kandagatla
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2020-09-17 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla

Hi Greg,

Here is small set of nvmem patches for 5.10 which includes
- 2 enhancements to core using simple IDA and kobj_to_dev
- 1 fix in core w.r.t device tree node refcounting.
- removed write support for mtk-fuse.

Can you please queue them up for 5.10.

thanks for you help,
srini

Bartosz Golaszewski (1):
  nvmem: switch to simpler IDA interface

Chih-En Hsu (1):
  nvmem: mtk-efuse: Remove EFUSE register write support

Tian Tao (1):
  nvmem: core: Use kobj_to_dev() instead of container_of()

Vadym Kochan (1):
  nvmem: core: fix missing of_node_put() in of_nvmem_device_get()

 drivers/nvmem/core.c      | 17 ++++++++++-------
 drivers/nvmem/mtk-efuse.c | 14 --------------
 2 files changed, 10 insertions(+), 21 deletions(-)

-- 
2.21.0


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

* [PATCH 1/4] nvmem: mtk-efuse: Remove EFUSE register write support
  2020-09-17 13:44 [PATCH 0/4] nvmem: patches (set 1) for 5.10 Srinivas Kandagatla
@ 2020-09-17 13:44 ` Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 2/4] nvmem: core: Use kobj_to_dev() instead of container_of() Srinivas Kandagatla
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2020-09-17 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Chih-En Hsu, Andrew-CT Chen, Srinivas Kandagatla

From: Chih-En Hsu <chih-en.hsu@mediatek.com>

This patch is to remove function "mtk_reg_write" since
Mediatek EFUSE hardware only supports read functionality
for NVMEM consumers.

Fixes: ba360fd040e3 ("nvmem: mtk-efuse: remove nvmem regmap dependency")
Signed-off-by: Chih-En Hsu <chih-en.hsu@mediatek.com>
Acked-by: Andrew-CT Chen <andrew-ct.chen@mediatek.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/mtk-efuse.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index 856d9c3fc38e..6a537d959f14 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -28,19 +28,6 @@ static int mtk_reg_read(void *context,
 	return 0;
 }
 
-static int mtk_reg_write(void *context,
-			 unsigned int reg, void *_val, size_t bytes)
-{
-	struct mtk_efuse_priv *priv = context;
-	u32 *val = _val;
-	int i = 0, words = bytes / 4;
-
-	while (words--)
-		writel(*val++, priv->base + reg + (i++ * 4));
-
-	return 0;
-}
-
 static int mtk_efuse_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -61,7 +48,6 @@ static int mtk_efuse_probe(struct platform_device *pdev)
 	econfig.stride = 4;
 	econfig.word_size = 4;
 	econfig.reg_read = mtk_reg_read;
-	econfig.reg_write = mtk_reg_write;
 	econfig.size = resource_size(res);
 	econfig.priv = priv;
 	econfig.dev = dev;
-- 
2.21.0


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

* [PATCH 2/4] nvmem: core: Use kobj_to_dev() instead of container_of()
  2020-09-17 13:44 [PATCH 0/4] nvmem: patches (set 1) for 5.10 Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 1/4] nvmem: mtk-efuse: Remove EFUSE register write support Srinivas Kandagatla
@ 2020-09-17 13:44 ` Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 3/4] nvmem: switch to simpler IDA interface Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 4/4] nvmem: core: fix missing of_node_put() in of_nvmem_device_get() Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2020-09-17 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Tian Tao, Srinivas Kandagatla

From: Tian Tao <tiantao6@hisilicon.com>

Use kobj_to_dev() instead of container_of()

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 6cd3edb2eaf6..7641e56a17bc 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -128,7 +128,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj,
 	if (attr->private)
 		dev = attr->private;
 	else
-		dev = container_of(kobj, struct device, kobj);
+		dev = kobj_to_dev(kobj);
 	nvmem = to_nvmem_device(dev);
 
 	/* Stop the user from reading */
@@ -168,7 +168,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
 	if (attr->private)
 		dev = attr->private;
 	else
-		dev = container_of(kobj, struct device, kobj);
+		dev = kobj_to_dev(kobj);
 	nvmem = to_nvmem_device(dev);
 
 	/* Stop the user from writing */
@@ -219,7 +219,7 @@ static umode_t nvmem_bin_attr_get_umode(struct nvmem_device *nvmem)
 static umode_t nvmem_bin_attr_is_visible(struct kobject *kobj,
 					 struct bin_attribute *attr, int i)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct nvmem_device *nvmem = to_nvmem_device(dev);
 
 	return nvmem_bin_attr_get_umode(nvmem);
-- 
2.21.0


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

* [PATCH 3/4] nvmem: switch to simpler IDA interface
  2020-09-17 13:44 [PATCH 0/4] nvmem: patches (set 1) for 5.10 Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 1/4] nvmem: mtk-efuse: Remove EFUSE register write support Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 2/4] nvmem: core: Use kobj_to_dev() instead of container_of() Srinivas Kandagatla
@ 2020-09-17 13:44 ` Srinivas Kandagatla
  2020-09-17 13:44 ` [PATCH 4/4] nvmem: core: fix missing of_node_put() in of_nvmem_device_get() Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2020-09-17 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Bartosz Golaszewski, Srinivas Kandagatla

From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

We don't need to specify any ranges when allocating IDs so we can switch
to ida_alloc() and ida_free() instead of the ida_simple_ counterparts.

ida_simple_get(ida, 0, 0, gfp) is equivalent to
ida_alloc_range(ida, 0, UINT_MAX, gfp) which is equivalent to
ida_alloc(ida, gfp). Note: IDR will never actually allocate an ID
larger than INT_MAX.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 7641e56a17bc..96ac8a632a7a 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -321,7 +321,7 @@ static void nvmem_release(struct device *dev)
 {
 	struct nvmem_device *nvmem = to_nvmem_device(dev);
 
-	ida_simple_remove(&nvmem_ida, nvmem->id);
+	ida_free(&nvmem_ida, nvmem->id);
 	gpiod_put(nvmem->wp_gpio);
 	kfree(nvmem);
 }
@@ -596,7 +596,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	if (!nvmem)
 		return ERR_PTR(-ENOMEM);
 
-	rval  = ida_simple_get(&nvmem_ida, 0, 0, GFP_KERNEL);
+	rval  = ida_alloc(&nvmem_ida, GFP_KERNEL);
 	if (rval < 0) {
 		kfree(nvmem);
 		return ERR_PTR(rval);
@@ -608,7 +608,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 		nvmem->wp_gpio = gpiod_get_optional(config->dev, "wp",
 						    GPIOD_OUT_HIGH);
 	if (IS_ERR(nvmem->wp_gpio)) {
-		ida_simple_remove(&nvmem_ida, nvmem->id);
+		ida_free(&nvmem_ida, nvmem->id);
 		rval = PTR_ERR(nvmem->wp_gpio);
 		kfree(nvmem);
 		return ERR_PTR(rval);
-- 
2.21.0


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

* [PATCH 4/4] nvmem: core: fix missing of_node_put() in of_nvmem_device_get()
  2020-09-17 13:44 [PATCH 0/4] nvmem: patches (set 1) for 5.10 Srinivas Kandagatla
                   ` (2 preceding siblings ...)
  2020-09-17 13:44 ` [PATCH 3/4] nvmem: switch to simpler IDA interface Srinivas Kandagatla
@ 2020-09-17 13:44 ` Srinivas Kandagatla
  3 siblings, 0 replies; 5+ messages in thread
From: Srinivas Kandagatla @ 2020-09-17 13:44 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Vadym Kochan, Srinivas Kandagatla

From: Vadym Kochan <vadym.kochan@plvision.eu>

of_parse_phandle() returns device_node with incremented ref count
which needs to be decremented by of_node_put() when device_node
is not used.

Fixes: e2a5402ec7c6 ("nvmem: Add nvmem_device based consumer apis.")
Signed-off-by: Vadym Kochan <vadym.kochan@plvision.eu>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 96ac8a632a7a..ab57289fe593 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -835,6 +835,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
 {
 
 	struct device_node *nvmem_np;
+	struct nvmem_device *nvmem;
 	int index = 0;
 
 	if (id)
@@ -844,7 +845,9 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id)
 	if (!nvmem_np)
 		return ERR_PTR(-ENOENT);
 
-	return __nvmem_device_get(nvmem_np, device_match_of_node);
+	nvmem = __nvmem_device_get(nvmem_np, device_match_of_node);
+	of_node_put(nvmem_np);
+	return nvmem;
 }
 EXPORT_SYMBOL_GPL(of_nvmem_device_get);
 #endif
-- 
2.21.0


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

end of thread, other threads:[~2020-09-17 14:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 13:44 [PATCH 0/4] nvmem: patches (set 1) for 5.10 Srinivas Kandagatla
2020-09-17 13:44 ` [PATCH 1/4] nvmem: mtk-efuse: Remove EFUSE register write support Srinivas Kandagatla
2020-09-17 13:44 ` [PATCH 2/4] nvmem: core: Use kobj_to_dev() instead of container_of() Srinivas Kandagatla
2020-09-17 13:44 ` [PATCH 3/4] nvmem: switch to simpler IDA interface Srinivas Kandagatla
2020-09-17 13:44 ` [PATCH 4/4] nvmem: core: fix missing of_node_put() in of_nvmem_device_get() Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).