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@xxxxxxxxxxxxxx> --- 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@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox