Thread (15 messages) 15 messages, 2 authors, 2021-06-21
STALE1863d

[PATCH 02/13] nvmem: treat devices without nvmem_bus::write as read only

From: Ahmad Fatoum <a.fatoum@pengutronix.de>
Date: 2021-06-19 03:47:16
Subsystem: nvmem framework, the rest · Maintainers: Srinivas Kandagatla, Linus Torvalds

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help