The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v7 0/2] spi: add new_device/delete_device sysfs interface
@ 2026-07-28  3:05 Vishwaroop A
  2026-07-28  3:05 ` [PATCH v7 1/2] " Vishwaroop A
  2026-07-28  3:05 ` [PATCH v7 2/2] docs: spi: add documentation for userspace device instantiation Vishwaroop A
  0 siblings, 2 replies; 3+ messages in thread
From: Vishwaroop A @ 2026-07-28  3:05 UTC (permalink / raw)
  To: Mark Brown
  Cc: linux-spi, linux-kernel, Jon Hunter, Thierry Reding,
	Suresh Mangipudi, linux-tegra, Vishwaroop A

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, dead flag).
Patch 2 adds the ABI and user-facing documentation.

Sent as a fresh top-level thread per Mark's feedback on v6.

Changes since v6:
  - new_device_store(): reject empty device names (leading-space input
    like " 0").  Previously produced an empty modalias that could
    never bind a driver.  (Mark)
  - Move sysfs userspace group registration out of the automatic
    ctlr->dev.groups path and into an explicit sysfs_create_group()
    call at the end of spi_register_controller(), after the queue,
    boardinfo matching and DT/ACPI enumeration have all completed.
    Torn down with sysfs_remove_group() at the start of
    spi_unregister_controller() so kernfs_drain naturally serialises
    with in-flight sysfs stores.  (Mark)
  - Drop userspace_clients_lock; reuse the existing add_lock for the
    userspace_clients list and the dead flag.  new_device_store() now
    calls __spi_add_device() directly under add_lock (add_lock is
    already the lock the controller uses to serialise device adds),
    which lets the dead check, __spi_add_device() and list insertion
    happen atomically.  delete_device_store() also takes add_lock.
    new_device is annotated DEVICE_ATTR_IGNORE_LOCKDEP alongside
    delete_device to silence the false-positive class-level splat
    (kernfs_drain has per-node scope, so no real ABBA).  (Jon)
  - kernel-doc / inline comment updates for the new struct fields
    (@userspace_clients now protected by @add_lock, new
    @userspace_registered, updated @dead).

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

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 by a ctlr->dead flag checked under add_lock, so
    add_lock is only held while doing list bookkeeping and can
    be released before device_del().

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/cover.1784000000.git.va@nvidia.com/  # v6
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                             | 270 +++++++++++++++++-
 include/linux/spi/spi.h                       |  23 ++
 5 files changed, 410 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-class-spi-master
 create mode 100644 Documentation/spi/instantiating-devices.rst


base-commit: 0d33d21e47d9dc66f91e44da3fc9220c74d93df7
-- 
2.17.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-28  3:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28  3:05 [PATCH v7 0/2] spi: add new_device/delete_device sysfs interface Vishwaroop A
2026-07-28  3:05 ` [PATCH v7 1/2] " Vishwaroop A
2026-07-28  3:05 ` [PATCH v7 2/2] docs: spi: add documentation for userspace device instantiation Vishwaroop A

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox