Re: [PATCH v4 2/2] spmi: core: Add generic DebugFS interface for bus inspection
From: Abel Vesa
Date: Fri Oct 30 2026 - 12:45:52 EST
On 26-10-30 10:29:47, vamshi gajjela wrote:
> From: Vamshi Gajjela <vamshigajjela@xxxxxxxxxx>
>
> Introduce a generic, controller-agnostic DebugFS interface in the SPMI
> core under /sys/kernel/debug/spmi/spmi-<nr>/:
> - name: Displays the controller parent device name and OF node.
> - xfer: Transactional interface supporting register reads, writes,
> and directed command opcodes with automatic opcode selection.
>
> Because raw writes and commands to PMICs can damage hardware and bypass
> client drivers and their regmap caches, write ('w') and command ('c')
> operations are disabled by default behind SPMI_ALLOW_WRITE_DEBUGFS. When
> enabled, they restrict access to root (mode 0600) and mark the kernel
> tainted with TAINT_USER.
>
> Detailed interface syntax and parameters are documented in
> Documentation/ABI/testing/debugfs-spmi.
>
> Co-developed-by: Jim Wylder <jwylder@xxxxxxxxxx>
> Signed-off-by: Jim Wylder <jwylder@xxxxxxxxxx>
> Signed-off-by: Vamshi Gajjela <vamshigajjela@xxxxxxxxxx>
> ---
> Documentation/ABI/testing/debugfs-spmi | 68 +++++
> MAINTAINERS | 1 +
> drivers/spmi/Makefile | 1 +
> drivers/spmi/spmi-core.c | 20 +-
> drivers/spmi/spmi-debugfs.c | 341 +++++++++++++++++++++++++
> drivers/spmi/spmi-internal.h | 28 ++
> include/linux/spmi.h | 6 +
> 7 files changed, 459 insertions(+), 6 deletions(-)
> create mode 100644 Documentation/ABI/testing/debugfs-spmi
> create mode 100644 drivers/spmi/spmi-debugfs.c
> create mode 100644 drivers/spmi/spmi-internal.h
>
> diff --git a/Documentation/ABI/testing/debugfs-spmi b/Documentation/ABI/testing/debugfs-spmi
> new file mode 100644
> index 000000000000..6a0bff9027a4
> --- /dev/null
> +++ b/Documentation/ABI/testing/debugfs-spmi
> @@ -0,0 +1,68 @@
> +What: /sys/kernel/debug/spmi/spmi-<nr>/name
> +Date: October 2026
> +KernelVersion: 7.4
> +Contact: vamshi gajjela <vamshigajjela@xxxxxxxxxx>
> +Description:
> + Displays the SPMI controller parent device name and
> + associated Device Tree node.
> +Users: Debugging, hardware diagnostics
> +
> +What: /sys/kernel/debug/spmi/spmi-<nr>/xfer
> +Date: October 2026
> +KernelVersion: 7.4
This patch won't make it into 7.4, so you can say 7.5 here.
> +Contact: vamshi gajjela <vamshigajjela@xxxxxxxxxx>
> +Description:
> + Transactional interface for raw SPMI bus operations:
> +
> + - Register Read:
> + exec 3<> xfer && echo "r <sid> <addr> [len]" >&3 && cat <&3
> + Reads 1 to 16 bytes starting at <addr> from slave <sid>.
> + The optional [len] parameter defaults to 1 byte.
> + Output is formatted as:
> + 0x<addr>: <byte0> <byte1> ...
> + Each open file descriptor maintains an independent response
> + buffer. Reading from the same open file descriptor consumes
> + the response; subsequent reads return EOF (0 bytes) until a
> + new read command is written.
> +
[...]
> +
> +void spmi_controller_debugfs_init(struct spmi_controller *ctrl)
> +{
> + struct dentry *dentry;
> + char name[32];
> +
> + if (IS_ERR_OR_NULL(spmi_debugfs_root))
> + return;
> +
> + snprintf(name, sizeof(name), "spmi-%u", ctrl->nr);
> + dentry = debugfs_create_dir(name, spmi_debugfs_root);
> + if (IS_ERR_OR_NULL(dentry))
> + return;
No need to check debugfs return values, please drop these.
Also, the dir name is the same as dev_name(&ctrl->dev), so please use that.