Skip to content

spi: add new_device/delete_device sysfs interface

Vishwaroop A linux-doc linux-spi 9 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v9 Latest2 patches 1 replyIn review
  2. v82 patches 2 repliesSuperseded
  3. v72 patches 0 repliesSuperseded
Earlier versions · 6
VersionPostedPatchesRepliesStatus
v62 patches2 repliesSuperseded
v52 patches0 repliesSuperseded
v42 patches1 replySuperseded
v32 patches1 replySuperseded
v22 patches2 repliesSuperseded
v12 patches1 replySuperseded

Changes in v9 from the cover letter

- Restrict the interface to SPI host controllers. (Mark Brown)
- Emit a change uevent after the late-created sysfs attributes become available, so userspace can detect when the interface is ready. (Mark Brown)
- Update the ABI date and target kernel version, and clarify the host-only interface and change notification in the documentation. (Mark Brown)
- Rebase on next-20260731 (v7.2-rc5).

Patches in v9 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2spi: add new_device/delete_device sysfs interfacedrivers/spi/spi.c include/linux/spi/spi.h+264 -00 replies
2/2docs: spi: add documentation for userspace device instantiationDocumentation/ABI/testing/sysfs-class-spi-master Documentation/spi/index.rst Documentation/spi/instantiating-devices.rst+123 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v9 yet.

Read the v9 thread

Cover letter [PATCH v9 0/2] spi: add new_device/delete_device sysfs interface

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, manual sysfs group registration). Patch 2 adds the ABI and user-facing documentation.

Changes since v8:
- Restrict the interface to SPI host controllers. (Mark Brown)
- Emit a change uevent after the late-created sysfs attributes become available, so userspace can detect when the interface is ready. (Mark Brown)
- Update the ABI date and target kernel version, and clarify the host-only interface and change notification in the documentation. (Mark Brown)
- Rebase on next-20260731 (v7.2-rc5).

Changes since v7:
- Remove the redundant CONFIG_SPI_DYNAMIC guard around

    spi_controller_groups[].  (Jon Hunter)

- Restore the original add_lock release point; the userspace sysfs group is removed and drained before the lock is taken. (Jon Hunter)
- Remove the redundant dead flag and retain the base-tree device_is_registered() teardown check. (Jon Hunter)
- Simplify parsing, diagnostics and comments. (Jon Hunter)

Changes since v6:
- new_device_store(): reject empty device names. (Mark Brown)
- Move sysfs userspace group registration out of the automatic ctlr->dev.groups path; create it manually at the end of spi_register_controller() and remove it at the start of spi_unregister_controller(). (Mark Brown)
- Drop userspace_clients_lock; reuse the existing add_lock. new_device_store() calls __spi_add_device() directly under add_lock; delete_device_store() also takes add_lock. new_device is DEVICE_ATTR_IGNORE_LOCKDEP alongside delete_device to silence the class-level splat. (Jon Hunter)
- kernel-doc / inline comment updates for the new struct fields.

Changes since v5:
- Rebased on next-20260727 (v7.2-rc5); applies cleanly.
- kernel-doc entries for the new struct spi_controller / struct spi_device fields.
- new_device_store(): reject chip_select > U8_MAX; parse with %u.
- new_device_store(): reject mode bits outside SPI_MODE_USER_MASK.
- new_device_store(): drop the unused 'n' / '%n' from sscanf().

Changes since v4:
- Removed spi_unregister_device() call from new_device_store()'s controller-teardown error path.

Changes since v3:
- Replaced holding add_lock across __spi_add_device() + list insertion with the current design: the sysfs group is removed before add_lock is taken, so kernfs_drain() serialises stores with controller unregister.

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().

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                             | 246 ++++++++++++++++++
 include/linux/spi/spi.h                       |  18 ++
 5 files changed, 387 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-spi-master
 create mode 100644 Documentation/spi/instantiating-devices.rst

base-commit: 415606a7be939835db9b0d6b711887586646346d

Signature · 1 line
2.17.1