From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Markus Schneider-Pargmann <msp@baylibre.com>,
Nishanth Menon <nm@ti.com>, Vignesh Raghavendra <vigneshr@ti.com>,
Tero Kristo <kristo@kernel.org>, Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Santosh Shilimkar <ssantosh@kernel.org>
Cc: Andrew Davis <afd@ti.com>,
linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] nvmem: core: Read into buffers larger than data
Date: Tue, 6 Feb 2024 22:07:59 +0000 [thread overview]
Message-ID: <bffe2a23-d3fc-499d-825a-e2fd3c7a9d7f@linaro.org> (raw)
In-Reply-To: <20240206143711.2410135-2-msp@baylibre.com>
On 06/02/2024 14:37, Markus Schneider-Pargmann wrote:
> The actual size that nvmem is using internally on a specific platform
> with a specific devicetree may not be known in the consumer code. The
> maximum size may be available at the same time.
>
> Allow the use of larger buffers in nvmem_cell_read_common() by setting
> buffers that are too large to zero before copying into them.
>
Can you explain why can we not use nvmem_cell_read() ?
there is an other thread to add get_size
https://www.spinics.net/lists/kernel/msg5075254.html
> Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
> ---
> drivers/nvmem/core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 980123fb4dde..6fa061ede605 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1806,12 +1806,14 @@ static int nvmem_cell_read_common(struct device *dev, const char *cell_id,
> nvmem_cell_put(cell);
> return PTR_ERR(buf);
> }
> - if (len != count) {
> + if (len > count) {
> kfree(buf);
> nvmem_cell_put(cell);
> return -EINVAL;
> + } else if (len < count) {
> + memset(val + len, 0, count - len);
no please.. this really does not belong here.
--srini
> }
> - memcpy(val, buf, count);
> + memcpy(val, buf, len);
> kfree(buf);
> nvmem_cell_put(cell);
>
next prev parent reply other threads:[~2024-02-06 22:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 14:37 [PATCH 0/4] soc: ti: k3-socinfo: Add support for nvmem cells Markus Schneider-Pargmann
2024-02-06 14:37 ` [PATCH 1/4] nvmem: core: Read into buffers larger than data Markus Schneider-Pargmann
2024-02-06 22:07 ` Srinivas Kandagatla [this message]
2024-02-06 14:37 ` [PATCH 2/4] dt-bindings: hwinfo: ti,k3-socinfo: Add nvmem-cells Markus Schneider-Pargmann
2024-02-06 18:23 ` Rob Herring
2024-02-06 18:43 ` Rob Herring
2024-02-14 9:31 ` Markus Schneider-Pargmann
2024-02-17 14:25 ` Krzysztof Kozlowski
2024-03-04 10:36 ` Markus Schneider-Pargmann
2024-03-05 7:43 ` Krzysztof Kozlowski
2024-03-05 11:17 ` Markus Schneider-Pargmann
2024-03-05 14:11 ` Krzysztof Kozlowski
2024-03-05 14:42 ` Andrew Davis
2024-03-05 17:01 ` Krzysztof Kozlowski
2024-03-05 17:41 ` Andrew Davis
2024-03-18 16:10 ` Markus Schneider-Pargmann
2024-02-07 7:58 ` Krzysztof Kozlowski
2024-02-06 14:37 ` [PATCH 3/4] soc: ti: k3-socinfo: Add support for nvmem cells Markus Schneider-Pargmann
2024-02-06 14:37 ` [PATCH 4/4] arm64: dts: ti: k3-am62-wakeup: Add chip efuse nodes Markus Schneider-Pargmann
2024-02-06 17:48 ` Andrew Davis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bffe2a23-d3fc-499d-825a-e2fd3c7a9d7f@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=afd@ti.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kristo@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=msp@baylibre.com \
--cc=nm@ti.com \
--cc=robh+dt@kernel.org \
--cc=ssantosh@kernel.org \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome