nvmem: core: Set the provider read-only when no write callback is given
authorAlban Bedel <albeu@free.fr>
Mon, 28 Jan 2019 15:55:00 +0000 (15:55 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 15:24:14 +0000 (16:24 +0100)
If no write callback is given the device should be marked as read-only.
While at it also move from a bit or to a logical or as that is a logical
expression.

Signed-off-by: Alban Bedel <albeu@free.fr>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/core.c

index f7301bb4ef3bc667480b96b77d68eac3fc6d4fab..cf2e1091fe89fe86704de5bab2441003c379358f 100644 (file)
@@ -646,8 +646,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
                             config->name ? config->id : nvmem->id);
        }
 
-       nvmem->read_only = device_property_present(config->dev, "read-only") |
-                          config->read_only;
+       nvmem->read_only = device_property_present(config->dev, "read-only") ||
+                          config->read_only || !nvmem->reg_write;
 
        if (config->root_only)
                nvmem->dev.groups = nvmem->read_only ?