kernel-hacking-2024-linux-s.../drivers/nvmem
Miquel Raynal 0331c61194 nvmem: core: Expose cells through sysfs
The binary content of nvmem devices is available to the user so in the
easiest cases, finding the content of a cell is rather easy as it is
just a matter of looking at a known and fixed offset. However, nvmem
layouts have been recently introduced to cope with more advanced
situations, where the offset and size of the cells is not known in
advance or is dynamic. When using layouts, more advanced parsers are
used by the kernel in order to give direct access to the content of each
cell, regardless of its position/size in the underlying
device. Unfortunately, these information are not accessible by users,
unless by fully re-implementing the parser logic in userland.

Let's expose the cells and their content through sysfs to avoid these
situations. Of course the relevant NVMEM sysfs Kconfig option must be
enabled for this support to be available.

Not all nvmem devices expose cells. Indeed, the .bin_attrs attribute
group member will be filled at runtime only when relevant and will
remain empty otherwise. In this case, as the cells attribute group will
be empty, it will not lead to any additional folder/file creation.

Exposed cells are read-only. There is, in practice, everything in the
core to support a write path, but as I don't see any need for that, I
prefer to keep the interface simple (and probably safer). The interface
is documented as being in the "testing" state which means we can later
add a write attribute if though relevant.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Tested-by: Rafał Miłecki <rafal@milecki.pl>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20231215111536.316972-9-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-12-15 13:30:08 +01:00
..
layouts nvmem: core: Rework layouts to become regular devices 2023-12-15 13:30:07 +01:00
apple-efuses.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
bcm-ocotp.c nvmem: Explicitly include correct DT includes 2023-08-23 16:34:01 +02:00
brcm_nvram.c nvmem: brcm_nvram: Use devm_platform_get_and_ioremap_resource() 2023-08-23 16:34:00 +02:00
core.c nvmem: core: Expose cells through sysfs 2023-12-15 13:30:08 +01:00
imx-iim.c nvmem: Explicitly include correct DT includes 2023-08-23 16:34:01 +02:00
imx-ocotp-ele.c nvmem: Explicitly include correct DT includes 2023-08-23 16:34:01 +02:00
imx-ocotp-scu.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
imx-ocotp.c nvmem: Move and rename ->fixup_cell_info() 2023-12-15 13:30:07 +01:00
internals.h nvmem: core: Expose cells through sysfs 2023-12-15 13:30:08 +01:00
jz4780-efuse.c
Kconfig nvmem: core: Rework layouts to become regular devices 2023-12-15 13:30:07 +01:00
lan9662-otpc.c
layerscape-sfp.c
layouts.c nvmem: core: Rework layouts to become regular devices 2023-12-15 13:30:07 +01:00
lpc18xx_eeprom.c
lpc18xx_otp.c nvmem: Explicitly include correct DT includes 2023-08-23 16:34:01 +02:00
Makefile nvmem: core: Rework layouts to become regular devices 2023-12-15 13:30:07 +01:00
meson-efuse.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
meson-mx-efuse.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
microchip-otpc.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
mtk-efuse.c nvmem: Move and rename ->fixup_cell_info() 2023-12-15 13:30:07 +01:00
mxs-ocotp.c nvmem: Use device_get_match_data() 2023-10-21 19:19:15 +02:00
nintendo-otp.c nvmem: nintendo-otp: Use devm_platform_ioremap_resource() 2023-04-05 19:41:12 +02:00
qcom-spmi-sdam.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
qfprom.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
qoriq-efuse.c nvmem: add new NXP QorIQ eFuse driver 2023-08-23 16:34:01 +02:00
rave-sp-eeprom.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
rmem.c nvmem: rmem: Use NVMEM_DEVID_AUTO 2023-06-15 13:42:18 +02:00
rockchip-efuse.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
rockchip-otp.c nvmem: rockchip-otp: Add support for RK3588 2023-06-15 13:42:17 +02:00
sc27xx-efuse.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
sec-qfprom.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
snvs_lpgpr.c nvmem: Explicitly include correct DT includes 2023-08-23 16:34:01 +02:00
sprd-efuse.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
stm32-bsec-optee-ta.c
stm32-bsec-optee-ta.h
stm32-romem.c nvmem: Use device_get_match_data() 2023-10-21 19:19:15 +02:00
sunplus-ocotp.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
sunxi_sid.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
u-boot-env.c nvmem: u-boot-env:: Replace zero-length array with DECLARE_FLEX_ARRAY() helper 2023-08-23 16:34:02 +02:00
uniphier-efuse.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00
vf610-ocotp.c nvmem: vf610-ocotp: Use devm_platform_get_and_ioremap_resource() 2023-04-05 19:41:13 +02:00
zynqmp_nvmem.c nvmem: add explicit config option to read old syntax fixed OF cells 2023-10-21 19:19:06 +02:00