nvmem: Replace spaces with tab in documentation
Subsystems (2)
PATCH v3 1/4 nvmem: Replace spaces with tab in documentation
Replace two spaces with tab in the sysfs attribute documentation. No functional change.
---
Cc: Alexandre Belloni <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]
---
V2: - New patch
V3: - No change
--- Documentation/ABI/stable/sysfs-bus-nvmem | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/stable/sysfs-bus-nvmem +1 -1
@@ -1,6 +1,6 @@ What: /sys/bus/nvmem/devices/.../nvmem Date: July 2015 -KernelVersion: 4.2 +KernelVersion: 4.2 Contact: Srinivas Kandagatla <[email protected]> Description: This file allows user to read/write the raw NVMEM contents.
Signature · 1 line
2.43.0
PATCH v3 2/4 nvmem: Document type attribute
Document a type attribute used by userspace to discern different types of NVMEM devices. The implementation is already present, the ABI document is missing, add it.
---
Cc: Alexandre Belloni <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]
---
V2: - New patch
V3: - Add RB from Alexandre
- Add trailing full stop to the paragraph
--- Documentation/ABI/stable/sysfs-bus-nvmem | 11 +++++++++++ 1 file changed, 11 insertions(+)
Documentation/ABI/stable/sysfs-bus-nvmem +11 -0
@@ -20,3 +20,14 @@ Description: ... * 0001000 + +What: /sys/bus/nvmem/devices/.../type +Date: November 2018 +KernelVersion: 5.0 +Contact: Alexandre Belloni <[email protected]> +Description: + This read-only attribute allows user to read the NVMEM + device type. Supported types are "Unknown", "EEPROM", + "OTP", "Battery backed", "FRAM". + Note: This file is only present if CONFIG_NVMEM_SYSFS + is enabled.
Signature · 1 line
2.43.0
PATCH v3 3/4 nvmem: Use sysfs_emit() for type attribute
In reply to Marek VasutUse sysfs_emit() instead of sprintf() to follow best practice per Documentation/filesystems/sysfs.rst
"show() should only use sysfs_emit()...
"
---
Cc: Alexandre Belloni <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]
---
V2: - New patch
V3: - No change
--- drivers/nvmem/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/core.c +1 -1
@@ -179,7 +179,7 @@ static ssize_t type_show(struct device *dev, {struct nvmem_device *nvmem =to_nvmem_device (dev); -return sprintf (buf,"%s\n" , nvmem_type_str[nvmem->type]); +return sysfs_emit (buf,"%s\n" , nvmem_type_str[nvmem->type]); }static DEVICE_ATTR_RO (type);
Signature · 1 line
2.43.0
PATCH v3 4/4 nvmem: core: Implement force_ro sysfs attribute
In reply to Marek VasutImplement "force_ro" sysfs attribute to allow users to set read-write devices as read-only and back to read-write from userspace. The choice of the name is based on MMC core 'force_ro' attribute.
This solves a situation where an AT24 I2C EEPROM with GPIO based nWP signal may have to be occasionally updated. Such I2C EEPROM device is usually set as read-only during most of the regular system operation, but in case it has to be updated in a controlled manner, it could be unlocked using this new "force_ro" sysfs attribute and then re-locked again.
The "read-only" DT property and config->read_only configuration is respected and is used to set default state of the device, read-only or read-write, for devices which do implement .reg_write function. For devices which do not implement .reg_write function, the device is unconditionally read-only and the "force_ro" attribute is not visible.
---
Cc: Alexandre Belloni <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Bartosz Golaszewski <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Srinivas Kandagatla <[email protected]>
Cc: [email protected]
---
V2: - Document the force_ro attribute
- Use sysfs_emit()
V3: - Expand ABI documentation with what the force_ro attribute
returns and what it can parse.
--- Documentation/ABI/stable/sysfs-bus-nvmem | 17 +++++++++ drivers/nvmem/core.c | 44 ++++++++++++++++++++++++ drivers/nvmem/internals.h | 1 + 3 files changed, 62 insertions(+)
Documentation/ABI/stable/sysfs-bus-nvmem +17 -0
@@ -1,3 +1,20 @@ +What: /sys/bus/nvmem/devices/.../force_ro +Date: June 2024 +KernelVersion: 6.11 +Contact: Marek Vasut <[email protected]> +Description: + This read/write attribute allows users to set read-write + devices as read-only and back to read-write from userspace. + This can be used to unlock and relock write-protection of + devices which are generally locked, except during sporadic + programming operation. + Read returns '0' or '1' for read-write or read-only modes + respectively. + Write parses one of 'YyTt1NnFf0', or [oO][NnFf] for "on" + and "off", i.e. what kstrbool() supports. + Note: This file is only present if CONFIG_NVMEM_SYSFS + is enabled. + What: /sys/bus/nvmem/devices/.../nvmem Date: July 2015 KernelVersion: 4.2
drivers/nvmem/core.c +44 -0
69 lines not on this page · raw message
drivers/nvmem/internals.h +1 -0
@@ -16,6 +16,7 @@ struct nvmem_device {int id;struct kref refcnt;size_t size; +bool default_read_only;bool read_only;bool root_only;int flags;
Signature · 1 line
2.43.0
Re: [PATCH v3 4/4] nvmem: core: Implement force_ro sysfs attribute
Quoted 15 lines · Marek Vasut
static const struct attribute_group *nvmem_dev_groups[] = {drivers/nvmem/core.c +1
-0@@ -945,6 +988,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->read_only =device_property_present (config->dev,"read-only" ) || config->read_only || !nvmem->reg_write; + nvmem->default_read_only = nvmem->read_only;#ifdef CONFIG_NVMEM_SYSFS nvmem->dev.groups = nvmem_dev_groups;drivers/nvmem/internals.h +0
-0
drivers/nvmem/internals.h struct nvmem_device { · line 19
Quoted 4 lines
drivers/nvmem/internals.h +1
-0@@ -16,6 +16,7 @@ struct nvmem_device {int id;struct kref refcnt;size_t size; +bool default_read_only;
Its not very clear what is the need for this?
--srini
Quoted 3 lines
drivers/nvmem/internals.h +0
-0bool read_only;bool root_only;int flags;
Re: [PATCH v3 4/4] nvmem: core: Implement force_ro sysfs attribute
Quoted 15 lines · Srinivas Kandagatla
Quoted 12 lines · Marek Vasut
static const struct
attribute_group*nvmem_dev_groups[] = {(quoted diff) +0
-0@@ -945,6 +988,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
nvmem->read_only=device_property_present(config->dev, "read-only")||config->read_only|| !nvmem->reg_write;
+nvmem->default_read_only=nvmem->read_only;
#ifdefCONFIG_NVMEM_SYSFS
nvmem->dev.groups=nvmem_dev_groups;drivers/nvmem/internals.h +0
-0
Quoted 8 lines
drivers/nvmem/internals.h struct nvmem_device { · line 19
Quoted 5 lines
drivers/nvmem/internals.h +1
-0@@ -16,6 +16,7 @@ struct nvmem_device { int id; struct kref refcnt; size_t size; + bool default_read_only;Its not very clear what is the need for this?
This field is used to discern devices which are by default read-write from ones which are by default read-only. Only the former can be switched between read-write and read-only mode ; the later cannot be switched to read-write mode .
Re: [PATCH v3 4/4] nvmem: core: Implement force_ro sysfs attribute
Quoted 25 lines · Marek Vasut
Quoted 15 lines · Srinivas Kandagatla
Quoted 12 lines · Marek Vasut
static const struct
attribute_group*nvmem_dev_groups[] = {(quoted diff) +0
-0@@ -945,6 +988,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
nvmem->read_only=device_property_present(config->dev, "read-only")||config->read_only|| !nvmem->reg_write;
+nvmem->default_read_only=nvmem->read_only;
#ifdefCONFIG_NVMEM_SYSFS
nvmem->dev.groups=nvmem_dev_groups;drivers/nvmem/internals.h +0
-0Quoted 8 lines
drivers/nvmem/internals.h struct nvmem_device { · line 19
Quoted 5 lines
drivers/nvmem/internals.h +1
-0@@ -16,6 +16,7 @@ struct nvmem_device { int id; struct kref refcnt; size_t size; + bool default_read_only;Its not very clear what is the need for this?
Quoted 1 line
This field is used to discern devices which are by default read-write
provider drivers or any drivers should not be accessing this struct directly.
Quoted 1 line
from ones which are by default read-only. Only the former can be
Why should the drivers care about this?
If the read_only flag is set in the core, nvmem core should prohibit any writes for this provider.
--srini
Quoted 1 line
switched between read-write and read-only mode ; the later cannot be switched to read-write mode .
Re: [PATCH v3 4/4] nvmem: core: Implement force_ro sysfs attribute
Quoted 28 lines · Srinivas Kandagatla
Quoted 25 lines · Marek Vasut
Quoted 23 lines · Srinivas Kandagatla
Quoted 13 lines · Marek Vasut
static const struct
attribute_group*nvmem_dev_groups[] = {(quoted diff) +0
-0@@ -945,6 +988,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
nvmem->read_only=device_property_present(config->dev, "read-only")||config->read_only|| !nvmem->reg_write;
+nvmem->default_read_only=nvmem->read_only;
#ifdefCONFIG_NVMEM_SYSFS
nvmem->dev.groups=nvmem_dev_groups;drivers/nvmem/internals.h +0
-0drivers/nvmem/internals.h struct nvmem_device { · line 19
Quoted 4 lines
drivers/nvmem/internals.h +1
-0@@ -16,6 +16,7 @@ struct nvmem_device { int id; struct kref refcnt; size_t size; + bool default_read_only;Its not very clear what is the need for this?
Quoted 6 lines
Quoted 1 line
This field is used to discern devices which are by default read-write
provider drivers or any drivers should not be accessing this struct directly.
Quoted 1 line
from ones which are by default read-only. Only the former can be
Why should the drivers care about this?
If theread_onlyflag is set in the core, nvmem core should prohibit any writes for this provider.
I think this is a nvmem core patch , isn't it ?
Re: [PATCH v3 4/4] nvmem: core: Implement force_ro sysfs attribute
Quoted 29 lines · Marek Vasut
Quoted 28 lines · Srinivas Kandagatla
Quoted 25 lines · Marek Vasut
Quoted 23 lines · Srinivas Kandagatla
Quoted 13 lines · Marek Vasut
static const struct
attribute_group*nvmem_dev_groups[] = {(quoted diff) +0
-0@@ -945,6 +988,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
nvmem->read_only=device_property_present(config->dev, "read-only")||config->read_only|| !nvmem->reg_write;
+nvmem->default_read_only=nvmem->read_only;
#ifdefCONFIG_NVMEM_SYSFS
nvmem->dev.groups=nvmem_dev_groups;drivers/nvmem/internals.h +0
-0drivers/nvmem/internals.h struct nvmem_device { · line 19
Quoted 4 lines
drivers/nvmem/internals.h +1
-0@@ -16,6 +16,7 @@ struct nvmem_device { int id; struct kref refcnt; size_t size; + bool default_read_only;Its not very clear what is the need for this?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
This field is used to discern devices which are by default read-write
provider drivers or any drivers should not be accessing this struct directly.
Quoted 1 line
from ones which are by default read-only. Only the former can be
Why should the drivers care about this?
If theread_onlyflag is set in the core, nvmem core should prohibit any writes for this provider.I think this is a nvmem core patch , isn't it ?
All that I see in this patch is setting default_read_only and no user for it. unless am looking at wrong patch.
--srin
Re: [PATCH v3 4/4] nvmem: core: Implement force_ro sysfs attribute
Quoted 33 lines · Srinivas Kandagatla
Quoted 30 lines · Marek Vasut
Quoted 29 lines · Srinivas Kandagatla
Quoted 26 lines · Marek Vasut
Quoted 15 lines · Srinivas Kandagatla
Quoted 12 lines · Marek Vasut
static const struct
attribute_group*nvmem_dev_groups[] = {(quoted diff) +0
-0@@ -945,6 +988,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
nvmem->read_only=device_property_present(config->dev, "read-only")||config->read_only|| !nvmem->reg_write;
+nvmem->default_read_only=nvmem->read_only;
#ifdefCONFIG_NVMEM_SYSFS
nvmem->dev.groups=nvmem_dev_groups;drivers/nvmem/internals.h +0
-0Quoted 8 lines
drivers/nvmem/internals.h struct nvmem_device { · line 19
Quoted 5 lines
drivers/nvmem/internals.h +1
-0@@ -16,6 +16,7 @@ struct nvmem_device { int id; struct kref refcnt; size_t size; + bool default_read_only;Its not very clear what is the need for this?
This field is used to discern devices which are by default read-write
Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
provider drivers or any drivers should not be accessing this struct directly.
Quoted 1 line
from ones which are by default read-only. Only the former can be
Why should the drivers care about this?
If theread_onlyflag is set in the core, nvmem core should prohibit any writes for this provider.I think this is a nvmem core patch , isn't it ?
All that I see in this patch is setting
default_read_onlyand no user for it. unless am looking at wrong patch.
Oh, now I understand, doh ... this is a remnant which should be removed. The force_ro attribute is now hidden for read-only devices outright in nvmem_attr_is_visible, so they cannot be switched to read-write mode.
Fixed in V4, thanks.