[PATCH v6 0/2] spi: add new_device/delete_device sysfs interface

Vishwaroop A posted 2 patches 1 week, 4 days ago
.../ABI/testing/sysfs-class-spi-master        |  34 +++
Documentation/spi/index.rst                   |   1 +
Documentation/spi/instantiating-devices.rst   |  88 +++++++
drivers/spi/spi.c                             | 238 +++++++++++++++++-
include/linux/spi/spi.h                       |  21 ++
5 files changed, 376 insertions(+), 6 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-class-spi-master
create mode 100644 Documentation/spi/instantiating-devices.rst
[PATCH v6 0/2] spi: add new_device/delete_device sysfs interface
Posted by Vishwaroop A 1 week, 4 days ago
Add I2C-style new_device/delete_device sysfs attributes to SPI host
controllers, allowing userspace to instantiate and remove SPI devices
at runtime without device-tree changes.

Patch 1 adds the new_device/delete_device attributes and the supporting
infrastructure (userspace_clients list, locking, dead flag).
Patch 2 adds the ABI and user-facing documentation.

Changes since v5:
  - Rebased on next-20260707 (v7.2-rc2); applies cleanly.
  - Added missing kernel-doc entries for the new struct fields
    (@userspace_node, @userspace_clients, @userspace_clients_lock,
    @dead).
  - new_device_store(): reject chip_select > U8_MAX to avoid silent
    truncation in spi_set_chipselect(); parse with %u instead of %hu.
  - new_device_store(): reject mode bits outside SPI_MODE_USER_MASK
    (mirrors spidev's SPI_IOC_WR_MODE32 filter).
  - new_device_store(): drop the unused 'n' / '%n' from sscanf().
  - Minor comment cleanup.

Changes since v4:
  - Removed spi_unregister_device() call from new_device_store()'s
    ctlr->dead teardown path; it raced with
    device_for_each_child(__unregister) in spi_unregister_controller().

Changes since v3:
  - Replaced holding add_lock across __spi_add_device() + list
    insertion (which caused an ABBA deadlock with kernfs) by a
    ctlr->dead flag checked under add_lock / userspace_clients_lock.
  - Used a compile-time #if IS_ENABLED() guard for the ctlr->dead
    check in __spi_add_device(), since the dead field is conditional.

Changes since v2:
  - Gated sysfs attributes and locking on CONFIG_SPI_DYNAMIC.

Changes since v1:
  - Added locking to prevent races between new_device_store() and
    concurrent spi_unregister_controller().

Link: https://lore.kernel.org/linux-spi/20260517201602.498135-1-va@nvidia.com/  # v5
Link: https://lore.kernel.org/linux-tegra/909f0c92-d110-4253-903e-5c81e21e12c9@nvidia.com/

Vishwaroop A (2):
  spi: add new_device/delete_device sysfs interface
  docs: spi: add documentation for userspace device instantiation

 .../ABI/testing/sysfs-class-spi-master        |  34 +++
 Documentation/spi/index.rst                   |   1 +
 Documentation/spi/instantiating-devices.rst   |  88 +++++++
 drivers/spi/spi.c                             | 238 +++++++++++++++++-
 include/linux/spi/spi.h                       |  21 ++
 5 files changed, 376 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-spi-master
 create mode 100644 Documentation/spi/instantiating-devices.rst


base-commit: be5c93fa674f0fc3c8f359c2143abce6bbb422e6
-- 
2.17.1
Re: [PATCH v6 0/2] spi: add new_device/delete_device sysfs interface
Posted by Mark Brown 1 week, 4 days ago
On Tue, Jul 14, 2026 at 10:09:42AM +0000, Vishwaroop A wrote:
> Add I2C-style new_device/delete_device sysfs attributes to SPI host
> controllers, allowing userspace to instantiate and remove SPI devices
> at runtime without device-tree changes.

Please don't send new patches in reply to old patches or serieses, this
makes it harder for both people and tools to understand what is going
on - it can bury things in mailboxes and make it difficult to keep track
of what current patches are, both for the new patches and the old ones.