Add support for STMicroelectronics M24LR EEPROM/NFC chips
Subsystems (2)
v3 cover Add support for STMicroelectronics M24LR EEPROM/NFC chips
This patch series adds support for the STMicroelectronics M24LR series RFID/NFC EEPROM devices. These chips expose two I2C addresses: the primary one provides access to system control and configuration registers, while the secondary address is used for EEPROM access.
The driver implements both functionalities:
- A sysfs-based interface for the control and system parameter registers.
- EEPROM access via the nvmem subsystem using a secondary I2C dummy client.
Brief summary of changes in v3:
- Full support for ST M24LR chips, including integrated EEPROM access within the same driver-no need for the at24 driver.
- Dropped usage of the I2C mux API.
- Switched to using the NVMEM subsystem for EEPROM access.
- Removed reference to the i2c-mux binding.
- Added reference to the nvmem binding to reflect EEPROM integration.
- Updated the reg property to support devices exposing two I2C addresses, one for control and one for EEPROM.
Tested on: M24LR04E-R using Yocto on Raspberry Pi 4
Abd-Alrhman Masalkhi (3):
dt-bindings: eeprom: Add ST M24LR support
misc: add driver for ST M24LR series RFID/NFC EEPROM chips
ABI: sysfs: add documentation for ST M24LR EEPROM and control
interface
.../ABI/testing/sysfs-bus-i2c-devices-m24lr | 96 +++ .../devicetree/bindings/misc/st,m24lr.yaml | 54 ++ drivers/misc/Kconfig | 17 + drivers/misc/Makefile | 1 + drivers/misc/m24lr.c | 705 ++++++++++++++++++ 5 files changed, 873 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr create mode 100644 Documentation/devicetree/bindings/misc/st,m24lr.yaml create mode 100644 drivers/misc/m24lr.c
Signature · 1 line
2.43.0
PATCH v3 1/3 dt-bindings: eeprom: Add ST M24LR support
Add support for STMicroelectronics M24LR RFID/NFC EEPROM chips. These devices use two I2C addresses: the primary address provides access to control and system parameter registers, while the secondary address is used for EEPROM access.
---
Changes in v3:
- Dropped reference to the i2c-mux binding.
- Added reference to the nvmem binding to reflect EEPROM usage.
- Updated 'reg' property to represent the device using two I2C addresses.
- Fixed DT schema errors and yamllint warnings.
- Removed the unused 'pagesize' property.
--- .../devicetree/bindings/misc/st,m24lr.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/st,m24lr.yaml
Documentation/devicetree/bindings/misc/st,m24lr.yaml new file +54 -0
@@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/st,m24lr.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics M24LR NFC/RFID EEPROM + +maintainers: + - Abd-Alrhman Masalkhi <[email protected]> + +description: + STMicroelectronics M24LR series are dual-interface (RF + I2C) + EEPROM chips. These devices support I2C-based access to both + memory and a system area that controls authentication and configuration. + They expose two I2C addresses, one for the system parameter sector and + one for the EEPROM. + +allOf: + - $ref: /schemas/nvmem/nvmem.yaml# + +properties: + compatible: + enum: + - st,m24lr04e-r + - st,m24lr16e-r + - st,m24lr64e-r + + reg: + description: + Two I2C address, the primary for control registers, the secondary + for EEPROM access. + minItems: 2 + maxItems: 2 + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + eeprom@57 { + compatible = "st,m24lr04e-r"; + reg = <0x57>, /* primary-device */ + <0x53>; /* secondary-device */ + }; + }; +...
Signature · 1 line
2.43.0
Re: [PATCH v3 1/3] dt-bindings: eeprom: Add ST M24LR support
Quoted 13 lines · Abd-Alrhman Masalkhi
Add support for STMicroelectronics M24LR RFID/NFC EEPROM chips. These devices use two I2C addresses: the primary address provides access to control and system parameter registers, while the secondary address is used for EEPROM access.
Signed-off-by Abd-Alrhman Masalkhi <[email protected]>---
Changes in v3:
- Dropped reference to the i2c-mux binding.
- Added reference to the nvmem binding to reflect EEPROM usage.
- Updated 'reg' property to represent the device using two I2C addresses.
- Fixed DT schema errors and yamllint warnings.
- Removed the unused 'pagesize' property.
Quoted 2 lines
--- .../devicetree/bindings/misc/st,m24lr.yaml | 54 +++++++++++++++++++
How did you implement this feedback:
"That's not a misc device, but eeprom. Place it in appropriate directory." ?
There is no such device as a misc device.
Quoted 33 lines
1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/st,m24lr.yamlDocumentation/devicetree/bindings/misc/st,m24lr.yaml new file +24
-0@@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/st,m24lr.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics M24LR NFC/RFID EEPROM + +maintainers: + - Abd-Alrhman Masalkhi <[email protected]> + +description: + STMicroelectronics M24LR series are dual-interface (RF + I2C) + EEPROM chips. These devices support I2C-based access to both + memory and a system area that controls authentication and configuration. + They expose two I2C addresses, one for the system parameter sector and + one for the EEPROM. + +allOf: + - $ref: /schemas/nvmem/nvmem.yaml# + +properties: + compatible: + enum:
Documentation/devicetree/bindings/misc/st,m24lr.yaml line 34
Quoted 10 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml new file +10
-0+ - st,m24lr04e-r + - st,m24lr16e-r + - st,m24lr64e-r + + reg: + description: + Two I2C address, the primary for control registers, the secondary + for EEPROM access. + minItems: 2 + maxItems: 2
Replace this all with items and description:
items:
- description: foo
- description: bar
Quoted 7 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml new file +7
-0+ +required: + - compatible + - reg + +unevaluatedProperties: false +
Documentation/devicetree/bindings/misc/st,m24lr.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml new file +10
-0+examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + eeprom@57 { + compatible = "st,m24lr04e-r"; + reg = <0x57>, /* primary-device */ + <0x53>; /* secondary-device */
Where is the rest of at24 properties? Not relevant? Not correct? I had impression this is fully at24 compatible.
Best regards,
Krzysztof
Re: [PATCH v3 1/3] dt-bindings: eeprom: Add ST M24LR support
Hi Krzysztof,
thank you for the feedback.
Quoted 6 lines
How did you implement this feedback:
"That's not a misc device, but eeprom. Place it in appropriate directory." ?
There is no such device as a misc device.
I will move it to the eeprom dirctory
Quoted 11 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml line 34
Quoted 6 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml new file +6
-0+ reg: + description: + Two I2C address, the primary for control registers, the secondary + for EEPROM access. + minItems: 2 + maxItems: 2Replace this all with items and description:
items:
- description: foo
- description: bar
I will do that.
Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml new file +12
-0+ +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>;
Quoted 8 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml line 51
Quoted 5 lines
Documentation/devicetree/bindings/misc/st,m24lr.yaml new file +5
-0+ + eeprom@57 { + compatible = "st,m24lr04e-r"; + reg = <0x57>, /* primary-device */ + <0x53>; /* secondary-device */Where is the rest of at24 properties? Not relevant? Not correct? I had impression this is fully at24 compatible.
The driver does not currently accept at24-style configuration properties (e.g., pagesize, address-width) because the EEPROM access is handled internally using fixed parameters per device variant. Let me know if adding support for these via DT is preferred, I'm happy to extend it for flexibility.
Best regards,
Abd-Alrhman Masalkhi
PATCH v3 2/3 misc: add driver for ST M24LR series RFID/NFC EEPROM chips
In reply to Abd-Alrhman Masalkhiadds support for STMicroelectronics M24LRxx devices, which expose two separate I2C addresses: one for system control and one for EEPROM access. The driver implements both a sysfs-based interface for control registers (e.g. UID, password authentication) and an nvmem provider for EEPROM access.
---
Changes in v3:
- Fully support the M24LR chips, including EEPROM access, no need for the standard at24 driver to handle EEPROM separately.
- Rename the driver file from m24lr_ctl.c to m24lr.c.
- Rename all identifiers from the m24lr_ctl prefix to m24lr.
- Retain the m24lr_ctl prefix for control-related routines to distinguish them from EEPROM-related logic.
- Drop usage of the I2C mux API.
- Use the NVMEM subsystem to handle EEPROM access.
- Add REGMAP support for EEPROM register access.
- Update Kconfig entry to reflect that the driver now supports both control and EEPROM functionality.
Changes in v2:
- Fix compiling Errors and Warnings
- Replace scnprintf with sysfs_emit
- Drop success log message from probe.
Comment:
- Running checkpatch emit a warning for non-const regmap_config. The variable must remain auto and mutable due to runtime manipulation.
--- drivers/misc/Kconfig | 17 + drivers/misc/Makefile | 1 + drivers/misc/m24lr.c | 705 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 723 insertions(+) create mode 100644 drivers/misc/m24lr.c
drivers/misc/Kconfig +17 -0
@@ -644,6 +644,23 @@ config MCHP_LAN966X_PCI - lan966x-miim (MDIO_MSCC_MIIM) - lan966x-switch (LAN966X_SWITCH) +config M24LR + tristate "STMicroelectronics M24LR RFID/NFC EEPROM support" + depends on SYSFS + select REGMAP_I2C + select NVMEM + help + This enables support for STMicroelectronics M24LR RFID/NFC EEPROM + chips. These dual-interface devices expose two I2C addresses: + one for EEPROM memory access and another for control and system + configuration (e.g. UID, password handling). + + This driver provides a sysfs interface for control functions and + integrates with the nvmem subsystem for EEPROM access. + + To compile this driver as a module, choose M here: the + module will be called m24lr. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -75,3 +75,4 @@ lan966x-pci-objs := lan966x_pci.o lan966x-pci-objs += lan966x_pci.dtbo.o obj-$(CONFIG_MCHP_LAN966X_PCI) += lan966x-pci.o obj-y += keba/ +obj-$(CONFIG_M24LR) += m24lr.o
drivers/misc/m24lr.c new file +705 -0
705 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg KH
maintainerRe: [PATCH v3 2/3] misc: add driver for ST M24LR series RFID/NFC EEPROM chips
Quoted 11 lines · Abd-Alrhman Masalkhi
adds support for STMicroelectronics M24LRxx devices, which expose two separate I2C addresses: one for system control and one for EEPROM access. The driver implements both a sysfs-based interface for control registers (e.g. UID, password authentication) and an nvmem provider for EEPROM access.
Signed-off-by Abd-Alrhman Masalkhi <[email protected]>---
Changes in v3:
- Fully support the M24LR chips, including EEPROM access, no need for the standard at24 driver to handle EEPROM separately.
Why isn't this under drivers/misc/eeprom/ instead?
thanks,
greg k-h
Re: [PATCH v3 2/3] misc: add driver for ST M24LR series RFID/NFC EEPROM chips
Hi greg,
Thanks for the feedback.
Quoted 6 lines
Quoted 6 lines
adds support for STMicroelectronics M24LRxx devices, which expose two separate I2C addresses: one for system control and one for EEPROM access. The driver implements both a sysfs-based interface for control registers (e.g. UID, password authentication) and an nvmem provider for EEPROM access.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Abd-Alrhman Masalkhi <[email protected]>---
Changes in v3:
- Fully support the M24LR chips, including EEPROM access, no need for the standard at24 driver to handle EEPROM separately.Why isn't this under
drivers/misc/eeprom/instead?
The M24LR series is a dual-interface EEPROM with both I2C and ISO/IEC 15693 RF support. While it is technically an EEPROM, it also exposes a control interface over I2C via a seprated address, which is used to manage features such as password protection, energy harvesting configuration, and UID access. This control interface is not memory-mapped like traditional EEPROMs, which is why I did not place it under the eeprom
Best regards,
Abd-Alrhman Masalkhi
Greg KH
maintainerRe: [PATCH v3 2/3] misc: add driver for ST M24LR series RFID/NFC EEPROM chips
In reply to Abd-Alrhman MasalkhiQuoted 1 line · Abd-Alrhman Masalkhi
+// SPDX-License-Identifier: GPL-2.0-or-later
Are you sure "or-later" is what you want? Sorry, I have to ask.
Quoted 16 lines
drivers/misc/m24lr.c new file +16
-0+/* +* m24lr.c - Sysfs control interface for ST M24LR series RFID/NFC chips +* +* Copyright (c) 2025 Abd-Alrhman Masalkhi <[email protected]> +* +* This driver implements both the sysfs-based control interface and EEPROM +* access for STMicroelectronics M24LR series chips (e.g., M24LR04E-R). +* It provides access to control registers for features such as password +* authentication, memory protection, and device configuration. In addition, +* it manages read and write operations to the EEPROM region of the chip. +*/ + +#include <linux/i2c.h> +#include <linux/regmap.h> +#include <linux/module.h> +#include <linux/device.h>
drivers/misc/m24lr.c line 27
Quoted 10 lines
drivers/misc/m24lr.c new file +10
-0+#include <linux/of.h> +#include <linux/of_device.h> +#include <linux/nvmem-provider.h> + +#define M24LR_PAGESIZE_DEFAULT 1u + +#define M24LR_WRITE_TIMEOUT 25u +#define M24LR_READ_TIMEOUT (M24LR_WRITE_TIMEOUT) + +#define to_sys_entry (attrp) container_of(attrp, struct m24lr_sys_entry, attr)
This shouldn't be needed, something seems odd...
drivers/misc/m24lr.c line 449
Quoted 5 lines
drivers/misc/m24lr.c new file +5
-0+static ssize_t m24lr_ctl_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct m24lr *m24lr =i2c_get_clientdata (to_i2c_client (dev)); +struct m24lr_sys_entry *entry =to_sys_entry (attr);
Why isn't this just going off of the device? Are you using single show/store callbacks for multiple attribute types?
Review
Quoted 2 lines
(quoted diff) +2
-0+ unsigned int reg_size = entry->reg_size; + unsigned int reg_addr = entry->reg_addr;
Ah, you are. Are you sure you need/want to do that?
drivers/misc/m24lr.c line 455
Quoted 4 lines
drivers/misc/m24lr.c new file +4
-0+u8 output[8 ]; +int err =0 ; + +if (unlikely (!count))
likely/unlikely can ONLY be used when you can benchmark the difference in the speed of not having it. For a sysfs file, that's not needed at all, please remove all of these.
drivers/misc/m24lr.c line 465
Quoted 10 lines
drivers/misc/m24lr.c new file +10
-0+return -EINVAL ; + +if (count > (reg_size <<1 )) +return -EINVAL ; + +if (unlikely (!is_power_of_2 (reg_size) || reg_size >8 )) { +dev_dbg (dev, +"Invalid register size: must be a power of 2 and <= 8 bytes (%u)\n" , + reg_size); +return -EIO ;
Not -EINVAL? This isn't an I/O error.
Quoted 40 lines
drivers/misc/m24lr.c new file +40
-0+ } + + err =m24lr_parse_le_value (buf, reg_size, output); +if (err) +return err; + +return m24lr_write (m24lr, (u8 *)&output, reg_size, reg_addr, false); +} + +static ssize_t m24lr_ctl_show (struct device *dev,struct device_attribute *attr, +char *buf) +{ +long ret; +u64 val; +__le64 input =0 ; +struct m24lr *m24lr =i2c_get_clientdata (to_i2c_client (dev)); +struct m24lr_sys_entry *entry =to_sys_entry (attr); +unsigned int reg_addr = entry->reg_addr; +unsigned int reg_size = entry->reg_size; + +if (unlikely (!is_power_of_2 (reg_size) || reg_size >8 )) { +dev_dbg (dev, +"Invalid register size: must be a power of 2 and <= 8 bytes (%u)\n" , + reg_size); +return -EIO ; + } + + ret =m24lr_read (m24lr, (u8 *)&input, reg_size, reg_addr, false); +if (IS_ERR_VALUE (ret)) +return ret; + +if (ret != reg_size) +return -EIO ; + +switch (reg_size) { +case 1 : + val = *(u8 *)&input; +break ; +case 2 : + val =le16_to_cpu ((__le16 )input);
drivers/misc/m24lr.c line 515
Quoted 10 lines
drivers/misc/m24lr.c new file +10
-0+break ; +case 4 : + val =le32_to_cpu ((__le32 )input); +break ; +case 8 : + val =le64_to_cpu ((__le64 )input); +break ; + }; + +return sysfs_emit (buf,"%llx\n" , val);
Why are "raw" read/writes happening from sysfs to the chip? That feels wrong, and an abuse of the sysfs api.
If you really want "raw" access, make it a binary file that userspace can mmap or read/write from directly, with the kernel getting out of the way entirely.
Quoted 8 lines
drivers/misc/m24lr.c new file +8
-0+ n_sss = chip->n_sss_entries; +if (n_sss) { + sss =devm_kzalloc (dev, n_sss *sizeof (struct m24lr_sys_entry ), +GFP_KERNEL ); +if (!sss) +return -ENOMEM ; + +for (i =0 ; i < n_sss; i++) {
drivers/misc/m24lr.c line 632
Quoted 10 lines
drivers/misc/m24lr.c new file +10
-0+char *name =devm_kasprintf (dev,GFP_KERNEL ,"sss%d" , i); + + sss[i].reg_size =1 ; + sss[i].reg_addr = i; + sss[i].attr.attr.name = name; + sss[i].attr.attr.mode =0600 ; + sss[i].attr.show = m24lr_ctl_show; + sss[i].attr.store = m24lr_ctl_store; + + err =device_create_file (dev, &sss[i].attr);
You just raced with userspace and lost. This is not how to do this, please do not dynamically create attributes (hint, this should have errored out as you didn't correctly initialize them), but also:
drivers/misc/m24lr.c line 636
Quoted 4 lines
drivers/misc/m24lr.c new file +4
-0+if (err) +dev_warn (dev, +"Failed to create sysfs entry '%s'\n" , + name);
You do not unwind properly if an error happens.
Just use a default attribute group attached to the driver and the driver core will handle all of that logic for you automatically. Making the code smaller and even better yet, correct :)
thanks,
greg k-h
Re: [PATCH v3 2/3] misc: add driver for ST M24LR series RFID/NFC EEPROM chips
Hi greg,
Thank you for the detailed feedback.
Quoted 3 lines
Quoted 1 line
+// SPDX-License-Identifier: GPL-2.0-or-later
Are you sure "or-later" is what you want? Sorry, I have to ask.
I will remove the or-later part, lol
Quoted 9 lines
drivers/misc/m24lr.c line 27
Quoted 7 lines
drivers/misc/m24lr.c new file +7
-0+ +#define M24LR_PAGESIZE_DEFAULT 1u + +#define M24LR_WRITE_TIMEOUT 25u +#define M24LR_READ_TIMEOUT (M24LR_WRITE_TIMEOUT) + +#define to_sys_entry (attrp) container_of(attrp, struct m24lr_sys_entry, attr)This shouldn't be needed, something seems odd...
I will remove the M24LR_PAGESIZE_DEFAULT, i do not needed any more and about the to_sys_entry, i am using it in show and store callbacks
Quoted 9 lines
drivers/misc/m24lr.c line 449
Quoted 5 lines
drivers/misc/m24lr.c new file +5
-0+static ssize_t m24lr_ctl_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct m24lr *m24lr =i2c_get_clientdata (to_i2c_client (dev)); +struct m24lr_sys_entry *entry =to_sys_entry (attr);Why isn't this just going off of the device? Are you using single show/store callbacks for multiple attribute types?
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ unsigned int reg_size = entry->reg_size; + unsigned int reg_addr = entry->reg_addr;Ah, you are. Are you sure you need/want to do that?
For registers that do not require any special processing, it's sufficient to directly pass the value to the device. In such cases, a generic store callback is appropriate. Other registers that require specific handling have dedicated store callbacks. For example, the unlock attribute uses its own specialized implementation.
Quoted 8 lines
drivers/misc/m24lr.c line 455
Quoted 4 lines
drivers/misc/m24lr.c new file +4
-0+u8 output[8 ]; +int err =0 ; + +if (unlikely (!count))likely/unlikely can ONLY be used when you can benchmark the difference in the speed of not having it. For a sysfs file, that's not needed at all, please remove all of these.
Alright, i will do that
Quoted 4 lines
Quoted 4 lines
drivers/misc/m24lr.c new file +4
-0+return -EINVAL ; + +if (count > (reg_size <<1 )) +return -EINVAL ;
Quoted 8 lines
drivers/misc/m24lr.c line 465
Quoted 6 lines
drivers/misc/m24lr.c new file +6
-0+ +if (unlikely (!is_power_of_2 (reg_size) || reg_size >8 )) { +dev_dbg (dev, +"Invalid register size: must be a power of 2 and <= 8 bytes (%u)\n" , + reg_size); +return -EIO ;Not
-EINVAL? This isn't an I/O error.
The last if statement is primarily for debugging purposes. The reg_size value is specified internally by the driver (not user-controlled), so this check helps catch potential mistakes in the driver's sysfs entry definitions. That's why I used -EIO instead of -EINVAL, as it's not due to invalid user input but rather an internal misconfiguration.
Quoted 14 lines
Quoted 14 lines
drivers/misc/m24lr.c new file +14
-0+ n_sss = chip->n_sss_entries; +if (n_sss) { + sss =devm_kzalloc (dev, n_sss *sizeof (struct m24lr_sys_entry ), +GFP_KERNEL ); +if (!sss) +return -ENOMEM ; + +for (i =0 ; i < n_sss; i++) { +char *name =devm_kasprintf (dev,GFP_KERNEL ,"sss%d" , i); + + sss[i].reg_size =1 ; + sss[i].reg_addr = i; + sss[i].attr.attr.name = name; + sss[i].attr.attr.mode =0600 ;
Quoted 8 lines
drivers/misc/m24lr.c line 632
Quoted 4 lines
drivers/misc/m24lr.c new file +4
-0+ sss[i].attr.show = m24lr_ctl_show; + sss[i].attr.store = m24lr_ctl_store; + + err =device_create_file (dev, &sss[i].attr);You just raced with userspace and lost. This is not how to do this, please do not dynamically create attributes (hint, this should have errored out as you didn't correctly initialize them), but also:
I didn't fully understand where the race condition comes from. Is the issue caused by calling device_create_file() from within the probe() function, or is it due to the fact that the attributes are being allocated dynamically rather than defined statically?
Quoted 11 lines
drivers/misc/m24lr.c line 636
Quoted 5 lines
drivers/misc/m24lr.c new file +4
-0+if (err) +dev_warn (dev, +"Failed to create sysfs entry '%s'\n" , + name);You do not unwind properly if an error happens.
Just use a default attribute group attached to the driver and the driver core will handle all of that logic for you automatically. Making the code smaller and even better yet, correct :)
Thanks for clarifying this point. I'll rework the implementation to use a default attribute_group
Best regards,
Abd-Alrhman Masalkhi
Greg KH
maintainerRe: [PATCH v3 2/3] misc: add driver for ST M24LR series RFID/NFC EEPROM chips
Quoted 8 lines · Abd-Alrhman Masalkhi
Quoted 7 lines
drivers/misc/m24lr.c line 465
Quoted 5 lines
drivers/misc/m24lr.c new file +5
-0+if (unlikely (!is_power_of_2 (reg_size) || reg_size >8 )) { +dev_dbg (dev, +"Invalid register size: must be a power of 2 and <= 8 bytes (%u)\n" , + reg_size); +return -EIO ;Not
-EINVAL? This isn't an I/O error.
Quoted 5 lines
The last if statement is primarily for debugging purposes. The
reg_sizevalue is specified internally by the driver (not user-controlled), so this check helps catch potential mistakes in the driver's sysfs entry definitions. That's why I used-EIOinstead of-EINVAL, as it's not due to invalid user input but rather an internal misconfiguration.
But you just leaked your internal check to userspace in a potential error code, so you must justify why userspace would ever see it and what it should do with it :)
Just make it EINVAL please. And if this is something that can't actually happen, don't check it at all.
Quoted 16 lines
Quoted 7 lines
Quoted 7 lines
drivers/misc/m24lr.c new file +7
-0+for (i =0 ; i < n_sss; i++) { +char *name =devm_kasprintf (dev,GFP_KERNEL ,"sss%d" , i); + + sss[i].reg_size =1 ; + sss[i].reg_addr = i; + sss[i].attr.attr.name = name; + sss[i].attr.attr.mode =0600 ;Quoted 8 lines
drivers/misc/m24lr.c line 632
Quoted 4 lines
drivers/misc/m24lr.c new file +4
-0+ sss[i].attr.show = m24lr_ctl_show; + sss[i].attr.store = m24lr_ctl_store; + + err =device_create_file (dev, &sss[i].attr);You just raced with userspace and lost. This is not how to do this, please do not dynamically create attributes (hint, this should have errored out as you didn't correctly initialize them), but also:
Quoted 4 lines
I didn't fully understand where the race condition comes from. Is the issue caused by calling
device_create_file()from within theprobe()function, or is it due to the fact that the attributes are being allocated dynamically rather than defined statically?
From calling device_create_file() at any point in time. The driver core should be doing that, not individual drivers.
thanks,
greg k-h
kernel test robot
build botRe: [PATCH v3 2/3] misc: add driver for ST M24LR series RFID/NFC EEPROM chips
In reply to Abd-Alrhman Masalkhikernel test robot noticed the following build warnings:
Hi Abd-Alrhman,
kernel test robot noticed the following build warnings:
[auto build test WARNING on char-misc/char-misc-linus]
[also build test WARNING on soc/for-next robh/for-next driver-core/driver-core-testing driver-core/driver-core-next driver-core/driver-core-linus v6.15] [cannot apply to char-misc/char-misc-testing char-misc/char-misc-next linus/master next-20250606]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Abd-Alrhman-Masalkhi/dt-bindings-eeprom-Add-ST-M24LR-support/20250606-201000 base: char-misc/char-misc-linus patch link: https://lore.kernel.org/r/20250606120631.3140054-3-abd.masalkhi%40gmail.com patch subject: [PATCH v3 2/3] misc: add driver for ST M24LR series RFID/NFC EEPROM chips config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20250607/[email protected]/config) compiler: sh4-linux-gcc (GCC) 15.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250607/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/misc/m24lr.c:341: warning: Function parameter or struct member 'is_eeprom' not described in 'm24lr_write'
vim +341 drivers/misc/m24lr.c
322
323 /**
324 * m24lr_write - write buffer to M24LR device with page alignment handling
325 * @m24lr: pointer to driver context
326 * @buf: data buffer to write
327 * @size: number of bytes to write
328 * @offset: target register address in the device
329 *
330 * Writes data to the M24LR device using regmap, split into chunks no larger
331 * than page_size to respect device-specific write limitations (e.g., page
332 * size or I2C hold-time concerns). Each chunk is aligned to the page boundary
333 * defined by page_size.
334 *
335 * Returns:
336 * Total number of bytes written on success,
337 * A negative error code if any write fails.
338 */
339 static ssize_t m24lr_write(struct m24lr *m24lr, const u8 *buf, size_t size,
340 unsigned int offset, bool is_eeprom)
> 341 { 342 unsigned int n, next_sector;
343 struct regmap *regmap;
344 ssize_t ret = 0;
345 long err;
346
347 if (is_eeprom)
348 regmap = m24lr->eeprom_regmap;
349 else
350 regmap = m24lr->ctl_regmap;
351
352 n = min(size, m24lr->page_size);
353 next_sector = roundup(offset + 1, m24lr->page_size);
354 if (offset + n > next_sector)
355 n = next_sector - offset;
356
357 mutex_lock(&m24lr->lock);
358 while (n) {
359 err = m24lr_regmap_write(regmap, buf, n, offset);
360 if (IS_ERR_VALUE(err)) {
361 mutex_unlock(&m24lr->lock);
362 if (ret)
363 return ret;
364 else
365 return err;
366 }
367
368 offset += n;
369 size -= n;
370 ret += n;
371 n = min(size, m24lr->page_size);
372 }
373 mutex_unlock(&m24lr->lock);
374
375 return ret;
376 }
377
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v3 3/3 ABI: sysfs: add documentation for ST M24LR EEPROM and control interface
In reply to Abd-Alrhman MasalkhiAdd sysfs ABI documentation for the STMicroelectronics M24LR device, covering both the control interface (e.g., unlock, password update, UID, memory size, and SSS entries) and EEPROM access via the nvmem subsystem.
---
Changes in v3:
- Updated sysfs entry paths to use <busnum>-<primary-addr> to reflect the control address.
Changes in v2:
- Added initial sysfs ABI documentation.
--- .../ABI/testing/sysfs-bus-i2c-devices-m24lr | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +96 -0
@@ -0,0 +1,96 @@ +What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/unlock +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Write-only attribute used to present a password and unlock + access to protected areas of the M24LR chip, including + configuration registers such as the Sector Security Status + (SSS) bytes. A valid password must be written to enable write + access to these regions via the I2C interface. + + Format: + - Hexadecimal string representing a 32-bit (4-byte) password + - Accepts 1 to 8 hex digits (e.g., "c", "1F", "a1b2c3d4") + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Behavior: + - If the password matches the internal stored value, + access to protected memory/configuration is granted + - If the password does not match the internally stored value, + it will fail silently + +What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/new_pass +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Write-only attribute used to update the password required to + unlock the M24LR chip. + + Format: + - Hexadecimal string representing a new 32-bit password + - Accepts 1 to 8 hex digits (e.g., "1A", "ffff", "c0ffee00") + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Behavior: + - Overwrites the current password stored in the I2C password + register + - Requires the device to be unlocked before changing the + password + - If the device is locked, the write silently fails + +What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/uid +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read-only attribute that exposes the 8-byte unique identifier + programmed into the M24LR chip at the factory. + + Format: + - Lowercase hexadecimal string representing a 64-bit value + - 1 to 16 hex digits (e.g., "e00204f12345678") + - No "0x" prefix + - Includes a trailing newline + +What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/mem_size +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read-only attribute that exposes the internal memory size code + of the M24LR device, as stored in the system register area. + + Format: + - Unsigned 8-bit integer + - Includes a trailing newline + + Notes: + - Value is encoded by the chip and corresponds to the EEPROM + size (e.g., 3 = 4 kbit for M24LR04E-R) + +What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/sss<N> +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read/write attribute representing the Sector Security Status + (SSS) byte for EEPROM sector <N> in the M24LR chips. Each sector + has one SSS byte, which defines I2c and RF access control via a + combination of protection and password settings. + + Format: + - Read: returns a 8-bit hexadecimal value followed by a + newline + - Write: requires exactly one or two hexadecimal digits + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Notes: + - Refer to the M24LR chip datasheet for full bit definitions + and usage + - Write access requires prior password authentication in I2C + mode
Signature · 1 line
2.43.0
Greg KH
maintainerRe: [PATCH v3 3/3] ABI: sysfs: add documentation for ST M24LR EEPROM and control interface
Quoted 23 lines · Abd-Alrhman Masalkhi
Add sysfs ABI documentation for the STMicroelectronics M24LR device, covering both the control interface (e.g., unlock, password update, UID, memory size, and SSS entries) and EEPROM access via the nvmem subsystem.
Signed-off-by Abd-Alrhman Masalkhi <[email protected]>---
Changes in v3:
- Updated sysfs entry paths to use <busnum>-<primary-addr> to reflect the control address.Changes in v2:
- Added initial sysfs ABI documentation.--- .../ABI/testing/sysfs-bus-i2c-devices-m24lr | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lrDocumentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +0
-0
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 2
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +2
-0@@ -0,0 +1,96 @@ +What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/unlock +Date: 2025-05-31
It's later than this.
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 3
Quoted 1 line
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +1
-0+KernelVersion: 6.16
This will not be showing up in 6.16, sorry, it's too late for that.
Quoted 9 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +9
-0+Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Write-only attribute used to present a password and unlock + access to protected areas of the M24LR chip, including + configuration registers such as the Sector Security Status + (SSS) bytes. A valid password must be written to enable write + access to these regions via the I2C interface. + + Format:
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 22
Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +10
-0+ - Hexadecimal string representing a 32-bit (4-byte) password + - Accepts 1 to 8 hex digits (e.g., "c", "1F", "a1b2c3d4") + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Behavior: + - If the password matches the internal stored value, + access to protected memory/configuration is granted + - If the password does not match the internally stored value, + it will fail silently
Why is the kernel in the business of adding passwords to devices? That feels wrong, and a way to just flood the device with a "try all the values" attempt if needed.
Quoted 12 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +12
-0+What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/sss<N> +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read/write attribute representing the Sector Security Status + (SSS) byte for EEPROM sector <N> in the M24LR chips. Each sector + has one SSS byte, which defines I2c and RF access control via a + combination of protection and password settings. + + Format: + - Read: returns a 8-bit hexadecimal value followed by a
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 96
Quoted 10 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +10
-0+ newline + - Write: requires exactly one or two hexadecimal digits + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Notes: + - Refer to the M24LR chip datasheet for full bit definitions + and usage + - Write access requires prior password authentication in I2C + mode
How "deep" does this sysfs tree get here? This feels like the wrong api for read/write to the device, just do it with a single binary file if you really want a "passthrough" way to get to the hardware.
thanks,
greg k-h
Re: [PATCH v3 3/3] ABI: sysfs: add documentation for ST M24LR EEPROM and control interface
Hi greg,
Thanks for the feedback.
Quoted 9 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 22
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +5
-0+ Behavior: + - If the password matches the internal stored value, + access to protected memory/configuration is granted + - If the password does not match the internally stored value, + it will fail silentlyWhy is the kernel in the business of adding passwords to devices? That feels wrong, and a way to just flood the device with a "try all the values" attempt if needed.
You're absolutely right, implementing password-based access in kernel space isn't ideal. However, this behavior is defined by the hardware itself. The M24LR chips require the user to "unlock" the device by writing a password before certain registers become writable (such as the Sector Security Status registors) and unfortunately, the chip does not provide any status or feedback to indicate whether the unlock was successful, which limits what the driver can safely report or validate.
Quoted 17 lines
Quoted 17 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +17
-0+What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/sss<N> +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read/write attribute representing the Sector Security Status + (SSS) byte for EEPROM sector <N> in the M24LR chips. Each sector + has one SSS byte, which defines I2c and RF access control via a + combination of protection and password settings. + Format: + - Read: returns a 8-bit hexadecimal value followed by a + newline + - Write: requires exactly one or two hexadecimal digits + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Notes:
Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 96
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +4
-0+ - Refer to the M24LR chip datasheet for full bit definitions + and usage + - Write access requires prior password authentication in I2C + modeHow "deep" does this sysfs tree get here? This feels like the wrong api for read/write to the device, just do it with a single binary file if you really want a "passthrough" way to get to the hardware.
The depth of the sysfs tree depends on the M24LR variant. For example, the M24LR04E-R has 4 sectors, resulting in 4 entries: sss0 through sss3.
I understand the concern about exposing multiple sysfs entries. The reason for this design is that each sector has its own SSS byte, and separating them helps reflect the per-sector nature of the access control. That said, I'm open to refactoring this to expose the SSS area via a single binary file if that's more in line with expected kernel interfaces.
Best regards,
Abd-Alrhman Masalkhi
Greg KH
maintainerRe: [PATCH v3 3/3] ABI: sysfs: add documentation for ST M24LR EEPROM and control interface
Quoted 51 lines · Abd-Alrhman Masalkhi
Hi greg,
Thanks for the feedback.
Quoted 9 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 22
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +5
-0+ Behavior: + - If the password matches the internal stored value, + access to protected memory/configuration is granted + - If the password does not match the internally stored value, + it will fail silentlyWhy is the kernel in the business of adding passwords to devices? That feels wrong, and a way to just flood the device with a "try all the values" attempt if needed.
You're absolutely right, implementing password-based access in kernel space isn't ideal. However, this behavior is defined by the hardware itself. The M24LR chips require the user to "unlock" the device by writing a password before certain registers become writable (such as the Sector Security Status registors) and unfortunately, the chip does not provide any status or feedback to indicate whether the unlock was successful, which limits what the driver can safely report or validate.
Quoted 17 lines
Quoted 17 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +17
-0+What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/sss<N> +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read/write attribute representing the Sector Security Status + (SSS) byte for EEPROM sector <N> in the M24LR chips. Each sector + has one SSS byte, which defines I2c and RF access control via a + combination of protection and password settings. + Format: + - Read: returns a 8-bit hexadecimal value followed by a + newline + - Write: requires exactly one or two hexadecimal digits + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Notes:Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 96
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +4
-0+ - Refer to the M24LR chip datasheet for full bit definitions + and usage + - Write access requires prior password authentication in I2C + modeHow "deep" does this sysfs tree get here? This feels like the wrong api for read/write to the device, just do it with a single binary file if you really want a "passthrough" way to get to the hardware.
The depth of the sysfs tree depends on the M24LR variant. For example, the M24LR04E-R has 4 sectors, resulting in 4 entries: sss0 through sss3.
Quoted 6 lines
I understand the concern about exposing multiple sysfs entries. The reason for this design is that each sector has its own SSS byte, and separating them helps reflect the per-sector nature of the access control. That said, I'm open to refactoring this to expose the SSS area via a single binary file if that's more in line with expected kernel interfaces.
Who and what is going to be talking to this device through this interface? Is this unique and special to ONLY this one chip/device or does it fit in with all other types of this device (i.e. eeproms)? You can't create a userspace api without actually having a user at all, so if there is no userspace code using this, why even have this?
thanks,
greg k-h
Re: [PATCH v3 1/3] dt-bindings: eeprom: Add ST M24LR support
Hi Greg,
Quoted 36 lines
Quoted 29 lines
Quoted 17 lines
Quoted 17 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +17
-0+What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/sss<N> +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read/write attribute representing the Sector Security Status + (SSS) byte for EEPROM sector <N> in the M24LR chips. Each sector + has one SSS byte, which defines I2c and RF access control via a + combination of protection and password settings. + Format: + - Read: returns a 8-bit hexadecimal value followed by a + newline + - Write: requires exactly one or two hexadecimal digits + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Notes:Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 96
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +4
-0+ - Refer to the M24LR chip datasheet for full bit definitions + and usage + - Write access requires prior password authentication in I2C + modeHow "deep" does this sysfs tree get here? This feels like the wrong api for read/write to the device, just do it with a single binary file if you really want a "passthrough" way to get to the hardware.
The depth of the sysfs tree depends on the M24LR variant. For example, the M24LR04E-R has 4 sectors, resulting in 4 entries: sss0 through sss3.
Quoted 6 lines
I understand the concern about exposing multiple sysfs entries. The reason for this design is that each sector has its own SSS byte, and separating them helps reflect the per-sector nature of the access control. That said, I'm open to refactoring this to expose the SSS area via a single binary file if that's more in line with expected kernel interfaces.
Quoted 5 lines
Who and what is going to be talking to this device through this interface? Is this unique and special to ONLY this one chip/device or does it fit in with all other types of this device (i.e. eeproms)? You can't create a userspace api without actually having a user at all, so if there is no userspace code using this, why even have this?
A userspace application specific to the M24LR series is intended to interface with this driver. The M24LR devices support dual access to the EEPROM: via I2C and over RFID. The purpose of exposing the Sector Security Status (SSS) registers to userspace is to provide dynamic control over when and how the EEPROM is accessible to an RFID reader. This allows userspace to decide whether to permit or deny EEPROM reads/writes via RFID, or to configure protection for specific memory sectors.
The SSS registers define per-sector read/write permissions and password protection, directly determining how external RFID readers interact with the tag. By exposing this configuration through sysfs, userspace software can modify RFID access behavior at runtime for example, to enable secure provisioning workflows, implement time-based access, or prevent unauthorized access after setup.
Given that this is a per-sector control mechanism unique to the M24LR series, would exposing the entire SSS region via a single binary sysfs file be considered more appropriate than individual attributes per sector?
Best regards,
Abd-Alrhman Masalkhi
Re: [PATCH v3 3/3] ABI: sysfs: add documentation for ST M24LR EEPROM and control interface
In reply to Greg KHHi Greg,
Quoted 36 lines
Quoted 29 lines
Quoted 17 lines
Quoted 17 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +17
-0+What: /sys/bus/i2c/devices/<busnum>-<primary-addr>/sss<N> +Date: 2025-05-31 +KernelVersion: 6.16 +Contact: Abd-Alrhman Masalkhi <[email protected]> +Description: + Read/write attribute representing the Sector Security Status + (SSS) byte for EEPROM sector <N> in the M24LR chips. Each sector + has one SSS byte, which defines I2c and RF access control via a + combination of protection and password settings. + Format: + - Read: returns a 8-bit hexadecimal value followed by a + newline + - Write: requires exactly one or two hexadecimal digits + - No "0x" prefix, whitespace, or trailing newline + - Case-insensitive + + Notes:Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr line 96
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-i2c-devices-m24lr new file +4
-0+ - Refer to the M24LR chip datasheet for full bit definitions + and usage + - Write access requires prior password authentication in I2C + modeHow "deep" does this sysfs tree get here? This feels like the wrong api for read/write to the device, just do it with a single binary file if you really want a "passthrough" way to get to the hardware.
The depth of the sysfs tree depends on the M24LR variant. For example, the M24LR04E-R has 4 sectors, resulting in 4 entries: sss0 through sss3.
Quoted 6 lines
I understand the concern about exposing multiple sysfs entries. The reason for this design is that each sector has its own SSS byte, and separating them helps reflect the per-sector nature of the access control. That said, I'm open to refactoring this to expose the SSS area via a single binary file if that's more in line with expected kernel interfaces.
Quoted 5 lines
Who and what is going to be talking to this device through this interface? Is this unique and special to ONLY this one chip/device or does it fit in with all other types of this device (i.e. eeproms)? You can't create a userspace api without actually having a user at all, so if there is no userspace code using this, why even have this?
A userspace application specific to the M24LR series is intended to interface with this driver. The M24LR devices support dual access to the EEPROM: via I2C and over RFID. The purpose of exposing the Sector Security Status (SSS) registers to userspace is to provide dynamic control over when and how the EEPROM is accessible to an RFID reader. This allows userspace to decide whether to permit or deny EEPROM reads/writes via RFID, or to configure protection for specific memory sectors.
The SSS registers define per-sector read/write permissions and password protection, directly determining how external RFID readers interact with the tag. By exposing this configuration through sysfs, userspace software can modify RFID access behavior at runtime for example, to enable secure provisioning workflows, implement time-based access, or prevent unauthorized access after setup.
Given that this is a per-sector control mechanism unique to the M24LR series, would exposing the entire SSS region via a single binary sysfs file be considered more appropriate than individual attributes per sector?
Best regards,
Abd-Alrhman Masalkhi