From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: vkoul@kernel.org, broonie@kernel.org
Cc: yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
lgirdwood@gmail.com, peter.ujfalusi@linux.intel.com,
kai.vehmanen@linux.intel.com, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, patches@opensource.cirrus.com
Subject: [PATCH v4 2/4] soundwire: bus: Don't unassign dev_num before unregistering device
Date: Tue, 24 Nov 2026 16:09:59 +0000 [thread overview]
Message-ID: <20261124161001.702882-3-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20261124161001.702882-1-ckeepax@opensource.cirrus.com>
Don't mark dev_num as unassigned until after the driver remove has
been called. The driver may want to communicate with the device
as part of the driver remove operation, so the dev_num should
remain assigned until that has completed. This requires moving from
device_unregister() to manually calling device_del() and device_put()
to ensure that the slave struct isn't freed too early.
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
No changes since v3.
drivers/soundwire/bus.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
index 15c66effbf4f4..001407fa50ddc 100644
--- a/drivers/soundwire/bus.c
+++ b/drivers/soundwire/bus.c
@@ -175,8 +175,18 @@ static int sdw_delete_slave(struct device *dev, void *data)
sdw_slave_debugfs_exit(slave);
- mutex_lock(&bus->bus_lock);
+ /*
+ * Split device_unregister(), the framework level needs to access
+ * members of the slave structure after the slave driver has been
+ * removed, thus the device_put() needs to be delayed. The device
+ * number needs to be marked as unused and the slave needs to be
+ * removed from the slave list. These can't be done before the
+ * drivers remove callback as the remove callback should still
+ * be able to communicate with the device.
+ */
+ device_del(dev);
+ mutex_lock(&bus->bus_lock);
if (slave->dev_num) { /* clear dev_num if assigned */
clear_bit(slave->dev_num, bus->assigned);
if (bus->ops && bus->ops->put_device_num)
@@ -185,7 +195,8 @@ static int sdw_delete_slave(struct device *dev, void *data)
list_del_init(&slave->node);
mutex_unlock(&bus->bus_lock);
- device_unregister(dev);
+ put_device(dev);
+
return 0;
}
--
2.47.3
next prev parent reply other threads:[~2026-11-24 16:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 16:09 [PATCH v4 0/4] Allow SoundWire devices to communicate during remove Charles Keepax
2026-11-24 16:09 ` [PATCH v4 1/4] ASoC: SOF: Intel: Add IRQ chip to distribute the SoundWire IRQ Charles Keepax
2026-11-24 16:36 ` sashiko-bot
2026-11-24 16:49 ` Pierre-Louis Bossart
2026-11-24 17:06 ` Charles Keepax
2026-11-24 18:33 ` Pierre-Louis Bossart
2026-11-24 16:09 ` Charles Keepax [this message]
2026-11-24 16:10 ` [PATCH v4 3/4] soundwire: bus: Expose a helper to remove devices from the bus Charles Keepax
2026-11-24 16:29 ` sashiko-bot
2026-11-24 16:10 ` [PATCH v4 4/4] soundwire: intel_auxdevice: Don't disable IRQs before removing children Charles Keepax
2026-11-24 16:27 ` sashiko-bot
2026-11-24 18:27 ` Pierre-Louis Bossart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261124161001.702882-3-ckeepax@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=broonie@kernel.org \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.