mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 02/13] nvmem: treat devices without nvmem_bus::write as read only
Date: Sat, 19 Jun 2021 05:45:05 +0200	[thread overview]
Message-ID: <20210619034516.6737-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20210619034516.6737-1-a.fatoum@pengutronix.de>

nvmem_bus::write is dereferenced unconditionally when doing write
operations. Align behavior with Linux, which allows drivers to omit
the reg_write callback when the device is known to be read-only.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 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 cfeecf70cd5d..3c14e390de39 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -209,8 +209,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 	nvmem->dev.device_node = np;
 	nvmem->priv = config->priv;
 
-	nvmem->read_only = of_property_read_bool(np, "read-only") |
-			   config->read_only;
+	if (config->read_only || !config->bus->write || of_property_read_bool(np, "read-only"))
+		nvmem->read_only = true;
 
 	dev_set_name(&nvmem->dev, config->name);
 	nvmem->dev.id = DEVICE_ID_DYNAMIC;
-- 
2.29.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-06-19  3:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19  3:45 [PATCH 00/13] nvmem: misc enhancements Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 01/13] nvmem: bsec: remove unused, left-over, struct member Ahmad Fatoum
2021-06-19  3:45 ` Ahmad Fatoum [this message]
2021-06-19  3:45 ` [PATCH 03/13] nvmem: add support for new read-only memory (rmem) binding Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 04/13] nvmem: add support for nvmem-cells binding Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 05/13] sandbox: use nvmem on top of stickypage for reset reason Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 06/13] power: reset: port Linux generic NVMEM reboot mode driver Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 07/13] sandbox: use nvmem-reboot-mode instead of syscon-reboot-mode Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 08/13] sandbox: dts: fix unit-address for state partition Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 09/13] nvmem: add command to list nvmem devices Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 10/13] sandbox: hostfile: move initcall to earlier postcore level Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 11/13] of: of_net: sync of_get_mac_address with Linux for NVMEM support Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 12/13] net: consult device tree for ethernet address in NVMEM as fall-back Ahmad Fatoum
2021-06-19  3:45 ` [PATCH 13/13] sandbox: ship sample environment Ahmad Fatoum
2021-06-21  6:05 ` [PATCH 00/13] nvmem: misc enhancements Sascha Hauer

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=20210619034516.6737-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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