Skip to contentSkip to conversation

nvmem: Replace spaces with tab in documentation

PATCH Applied Marek Vasut 2 participants 5 messages Jun 27, 2024 – Jun 28, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 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
V4: - No change

---
 Documentation/ABI/stable/sysfs-bus-nvmem | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/stable/sysfs-bus-nvmem +1 -1
index c399323f37de3..854bd11d72ac4 100644
@@ -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
#1 lore raw

PATCH v4 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
V4: - No change

---
 Documentation/ABI/stable/sysfs-bus-nvmem | 11 +++++++++++
 1 file changed, 11 insertions(+)
Documentation/ABI/stable/sysfs-bus-nvmem +11 -0
index 854bd11d72ac4..3f0a95250aa84 100644
@@ -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
#2 lore raw

PATCH v4 3/4 nvmem: Use sysfs_emit() for type attribute

In reply to Marek Vasut

Use 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
V4: - No change

---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/core.c +1 -1
index a31ea4275d5ae..5b3606114628b 100644
@@ -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
#3 lore raw

PATCH v4 4/4 nvmem: core: Implement force_ro sysfs attribute

In reply to Marek Vasut

Implement "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.
V4: - Drop default_read_only , that is superseded by nvmem_attr_is_visible
which outright hides the force_ro attribute for read-only devices, so they cannot be switched to read-write.

---
 Documentation/ABI/stable/sysfs-bus-nvmem | 17 ++++++++++
 drivers/nvmem/core.c                     | 43 ++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
Documentation/ABI/stable/sysfs-bus-nvmem +17 -0
index 3f0a95250aa84..aa89adf18bc55 100644
@@ -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 +43 -0

62 lines not on this page · raw message

Signature · 1 line
2.43.0
#4 lore raw
In reply to Marek Vasut
Quoted 4 lines · Marek Vasut

Replace two spaces with tab in the sysfs attribute documentation. No functional change.

Applied, thanks!

[1/4] nvmem: Replace spaces with tab in documentation

      commit: c86a30c762e78fcabba878a72de5a1d6dc8fb813
[2/4] nvmem: Document type attribute
      commit: 850499fede5bba639616e5b113e46c08a6400a0a
[3/4] nvmem: Use sysfs_emit() for type attribute
      commit: 95542b7572d7b124ff2fad6c0ad682916cd4f814
[4/4] nvmem: core: Implement force_ro sysfs attribute
      commit: cd638012bae81c222e5e128b9ff1f7db64176f27

Best regards,

Signature · 1 line
Srinivas Kandagatla <[email protected]>