All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] nvmem: set2 patches for v4.14
@ 2017-09-11  9:00 srinivas.kandagatla
  2017-09-11  9:00   ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: srinivas.kandagatla @ 2017-09-11  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

Hi Greg,

These are few fixes which can go in to 4.14,
could you please pick them up 


Thanks,
Srini

Guy Shapiro (1):
  nvmem: core: return EFBIG on out-of-range write

Masahiro Yamada (3):
  nvmem: add missing of_node_put() in of_nvmem_cell_get()
  nvmem: remove inline in drivers/nvmem/core.c
  nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional

 drivers/nvmem/core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.9.3

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

* [PATCH 1/4] nvmem: core: return EFBIG on out-of-range write
@ 2017-09-11  9:00   ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
  0 siblings, 0 replies; 10+ messages in thread
From: srinivas.kandagatla @ 2017-09-11  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Guy Shapiro, linux-api, Srinivas Kandagatla

From: Guy Shapiro <guy.shapiro@mobi-wize.com>

When writing data that exceeds the nvmem size to a nvmem sysfs file
using the sh redirection operator >, the shell hangs, trying to
write the out-of-range bytes endlessly.

Fix the problem by returning EFBIG described in man 2 write.

Similar change was done for binary sysfs files on commit
0936896056365349afa867c16e9f9100a6707cbf

Signed-off-by: Guy Shapiro <guy.shapiro@mobi-wize.com>
Cc: linux-api@vger.kernel.org
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index de54c7f..3866117 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -135,7 +135,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
 
 	/* Stop the user from writing */
 	if (pos >= nvmem->size)
-		return 0;
+		return -EFBIG;
 
 	if (count < nvmem->word_size)
 		return -EINVAL;
-- 
2.9.3

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

* [PATCH 1/4] nvmem: core: return EFBIG on out-of-range write
@ 2017-09-11  9:00   ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
  0 siblings, 0 replies; 10+ messages in thread
From: srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A @ 2017-09-11  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Guy Shapiro,
	linux-api-u79uwXL29TY76Z2rM5mHXA, Srinivas Kandagatla

From: Guy Shapiro <guy.shapiro-2HKgp+mgmS5l57MIdRCFDg@public.gmane.org>

When writing data that exceeds the nvmem size to a nvmem sysfs file
using the sh redirection operator >, the shell hangs, trying to
write the out-of-range bytes endlessly.

Fix the problem by returning EFBIG described in man 2 write.

Similar change was done for binary sysfs files on commit
0936896056365349afa867c16e9f9100a6707cbf

Signed-off-by: Guy Shapiro <guy.shapiro-2HKgp+mgmS5l57MIdRCFDg@public.gmane.org>
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index de54c7f..3866117 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -135,7 +135,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj,
 
 	/* Stop the user from writing */
 	if (pos >= nvmem->size)
-		return 0;
+		return -EFBIG;
 
 	if (count < nvmem->word_size)
 		return -EINVAL;
-- 
2.9.3

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

* [PATCH 2/4] nvmem: add missing of_node_put() in of_nvmem_cell_get()
  2017-09-11  9:00 [PATCH 0/4] nvmem: set2 patches for v4.14 srinivas.kandagatla
  2017-09-11  9:00   ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
@ 2017-09-11  9:00 ` srinivas.kandagatla
  2017-09-11  9:00 ` [PATCH 3/4] nvmem: remove inline in drivers/nvmem/core.c srinivas.kandagatla
  2017-09-11  9:00 ` [PATCH 4/4] nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional srinivas.kandagatla
  3 siblings, 0 replies; 10+ messages in thread
From: srinivas.kandagatla @ 2017-09-11  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Masahiro Yamada, Srinivas Kandagatla

From: Masahiro Yamada <yamada.masahiro@socionext.com>

of_get_next_parent() increments the refcount of the returned node.
It should be put when done.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 3866117..d12e5de 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -789,6 +789,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np,
 		return ERR_PTR(-EINVAL);
 
 	nvmem = __nvmem_device_get(nvmem_np, NULL, NULL);
+	of_node_put(nvmem_np);
 	if (IS_ERR(nvmem))
 		return ERR_CAST(nvmem);
 
-- 
2.9.3

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

* [PATCH 3/4] nvmem: remove inline in drivers/nvmem/core.c
  2017-09-11  9:00 [PATCH 0/4] nvmem: set2 patches for v4.14 srinivas.kandagatla
  2017-09-11  9:00   ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
  2017-09-11  9:00 ` [PATCH 2/4] nvmem: add missing of_node_put() in of_nvmem_cell_get() srinivas.kandagatla
@ 2017-09-11  9:00 ` srinivas.kandagatla
  2017-09-18 14:09   ` Greg Kroah-Hartman
  2017-09-11  9:00 ` [PATCH 4/4] nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional srinivas.kandagatla
  3 siblings, 1 reply; 10+ messages in thread
From: srinivas.kandagatla @ 2017-09-11  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Masahiro Yamada, Srinivas Kandagatla

From: Masahiro Yamada <yamada.masahiro@socionext.com>

These two functions are defined in .c file, but called just once
(at least for now).  So, the compiler will fold them into their
callers even without the "inline" markers.

However, this kind of optimization should not be done by hand.
It is compiler's judge after all.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index d12e5de..fdb8b7a 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -946,8 +946,7 @@ void nvmem_cell_put(struct nvmem_cell *cell)
 }
 EXPORT_SYMBOL_GPL(nvmem_cell_put);
 
-static inline void nvmem_shift_read_buffer_in_place(struct nvmem_cell *cell,
-						    void *buf)
+static void nvmem_shift_read_buffer_in_place(struct nvmem_cell *cell, void *buf)
 {
 	u8 *p, *b;
 	int i, bit_offset = cell->bit_offset;
@@ -1028,8 +1027,8 @@ void *nvmem_cell_read(struct nvmem_cell *cell, size_t *len)
 }
 EXPORT_SYMBOL_GPL(nvmem_cell_read);
 
-static inline void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
-						    u8 *_buf, int len)
+static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell *cell,
+					     u8 *_buf, int len)
 {
 	struct nvmem_device *nvmem = cell->nvmem;
 	int i, rc, nbits, bit_offset = cell->bit_offset;
-- 
2.9.3

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

* [PATCH 4/4] nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional
  2017-09-11  9:00 [PATCH 0/4] nvmem: set2 patches for v4.14 srinivas.kandagatla
                   ` (2 preceding siblings ...)
  2017-09-11  9:00 ` [PATCH 3/4] nvmem: remove inline in drivers/nvmem/core.c srinivas.kandagatla
@ 2017-09-11  9:00 ` srinivas.kandagatla
  2017-09-18 14:09   ` Greg Kroah-Hartman
  3 siblings, 1 reply; 10+ messages in thread
From: srinivas.kandagatla @ 2017-09-11  9:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Masahiro Yamada, Srinivas Kandagatla

From: Masahiro Yamada <yamada.masahiro@socionext.com>

As you see in drivers/nvmem/Makefile, this C file is compiled only
when CONFIG_NVMEM is y or m.

So, IS_ENABLED(CONFIG_NVMEM) is always evaluated to 1 in this file.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/nvmem/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index fdb8b7a..8649045 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -615,7 +615,7 @@ static struct nvmem_device *nvmem_find(const char *name)
 	return to_nvmem_device(d);
 }
 
-#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
+#if IS_ENABLED(CONFIG_OF)
 /**
  * of_nvmem_device_get() - Get nvmem device from a given id
  *
@@ -753,7 +753,7 @@ static struct nvmem_cell *nvmem_cell_get_from_list(const char *cell_id)
 	return cell;
 }
 
-#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)
+#if IS_ENABLED(CONFIG_OF)
 /**
  * of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
  *
-- 
2.9.3

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

* Re: [PATCH 3/4] nvmem: remove inline in drivers/nvmem/core.c
  2017-09-11  9:00 ` [PATCH 3/4] nvmem: remove inline in drivers/nvmem/core.c srinivas.kandagatla
@ 2017-09-18 14:09   ` Greg Kroah-Hartman
  2017-09-18 15:02     ` Srinivas Kandagatla
  0 siblings, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2017-09-18 14:09 UTC (permalink / raw)
  To: srinivas.kandagatla; +Cc: linux-kernel, Masahiro Yamada

On Mon, Sep 11, 2017 at 11:00:13AM +0200, srinivas.kandagatla@linaro.org wrote:
> From: Masahiro Yamada <yamada.masahiro@socionext.com>
> 
> These two functions are defined in .c file, but called just once
> (at least for now).  So, the compiler will fold them into their
> callers even without the "inline" markers.
> 
> However, this kind of optimization should not be done by hand.
> It is compiler's judge after all.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/nvmem/core.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

This isn't really a bugfix, so should wait for 4.15-rc1.

thanks,

greg k-h

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

* Re: [PATCH 4/4] nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional
  2017-09-11  9:00 ` [PATCH 4/4] nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional srinivas.kandagatla
@ 2017-09-18 14:09   ` Greg Kroah-Hartman
  2017-09-18 15:02     ` Srinivas Kandagatla
  0 siblings, 1 reply; 10+ messages in thread
From: Greg Kroah-Hartman @ 2017-09-18 14:09 UTC (permalink / raw)
  To: srinivas.kandagatla; +Cc: linux-kernel, Masahiro Yamada

On Mon, Sep 11, 2017 at 11:00:14AM +0200, srinivas.kandagatla@linaro.org wrote:
> From: Masahiro Yamada <yamada.masahiro@socionext.com>
> 
> As you see in drivers/nvmem/Makefile, this C file is compiled only
> when CONFIG_NVMEM is y or m.
> 
> So, IS_ENABLED(CONFIG_NVMEM) is always evaluated to 1 in this file.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/nvmem/core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Again, not a bugfix, should go into 4.15-rc1.

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

* Re: [PATCH 3/4] nvmem: remove inline in drivers/nvmem/core.c
  2017-09-18 14:09   ` Greg Kroah-Hartman
@ 2017-09-18 15:02     ` Srinivas Kandagatla
  0 siblings, 0 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2017-09-18 15:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Masahiro Yamada



On 18/09/17 15:09, Greg Kroah-Hartman wrote:
> On Mon, Sep 11, 2017 at 11:00:13AM +0200, srinivas.kandagatla@linaro.org wrote:
>> From: Masahiro Yamada <yamada.masahiro@socionext.com>
>>
>> These two functions are defined in .c file, but called just once
>> (at least for now).  So, the compiler will fold them into their
>> callers even without the "inline" markers.
>>
>> However, this kind of optimization should not be done by hand.
>> It is compiler's judge after all.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>   drivers/nvmem/core.c | 7 +++----
>>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> This isn't really a bugfix, so should wait for 4.15-rc1.

No rush for this patch, we can take it in 4.15-rc1..

thanks,
srini
> 
> thanks,
> 
> greg k-h
> 

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

* Re: [PATCH 4/4] nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional
  2017-09-18 14:09   ` Greg Kroah-Hartman
@ 2017-09-18 15:02     ` Srinivas Kandagatla
  0 siblings, 0 replies; 10+ messages in thread
From: Srinivas Kandagatla @ 2017-09-18 15:02 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-kernel, Masahiro Yamada



On 18/09/17 15:09, Greg Kroah-Hartman wrote:
> On Mon, Sep 11, 2017 at 11:00:14AM +0200,srinivas.kandagatla@linaro.org  wrote:
>> From: Masahiro Yamada<yamada.masahiro@socionext.com>
>>
>> As you see in drivers/nvmem/Makefile, this C file is compiled only
>> when CONFIG_NVMEM is y or m.
>>
>> So, IS_ENABLED(CONFIG_NVMEM) is always evaluated to 1 in this file.
>>
>> Signed-off-by: Masahiro Yamada<yamada.masahiro@socionext.com>
>> Signed-off-by: Srinivas Kandagatla<srinivas.kandagatla@linaro.org>
>> ---
>>   drivers/nvmem/core.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
> Again, not a bugfix, should go into 4.15-rc1.
Okay, No Problem!

thanks,
srini

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

end of thread, other threads:[~2017-09-18 15:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-11  9:00 [PATCH 0/4] nvmem: set2 patches for v4.14 srinivas.kandagatla
2017-09-11  9:00 ` [PATCH 1/4] nvmem: core: return EFBIG on out-of-range write srinivas.kandagatla
2017-09-11  9:00   ` srinivas.kandagatla-QSEj5FYQhm4dnm+yROfE0A
2017-09-11  9:00 ` [PATCH 2/4] nvmem: add missing of_node_put() in of_nvmem_cell_get() srinivas.kandagatla
2017-09-11  9:00 ` [PATCH 3/4] nvmem: remove inline in drivers/nvmem/core.c srinivas.kandagatla
2017-09-18 14:09   ` Greg Kroah-Hartman
2017-09-18 15:02     ` Srinivas Kandagatla
2017-09-11  9:00 ` [PATCH 4/4] nvmem: remove unneeded IS_ENABLED(CONFIG_NVMEM) conditional srinivas.kandagatla
2017-09-18 14:09   ` Greg Kroah-Hartman
2017-09-18 15:02     ` Srinivas Kandagatla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.