Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] soundwire: bus_type: Use devres to free slave IDA
@ 2026-08-31 11:29 Richard Fitzgerald
  2026-08-31 11:51 ` Charles Keepax
  2026-09-01 17:15 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Fitzgerald @ 2026-08-31 11:29 UTC (permalink / raw)
  To: vkoul; +Cc: linux-sound, linux-kernel, patches

Create a devres cleanup action to call ida_free(). This ensures that it
is freed after anything that is cleaned up by devres and might have been
using the allocated ID. It also avoids mixing devres and manual cleanup
during sdw_bus_probe().

Fixes: aab12022b076f ("soundwire: bus: Add internal slave ID and use for IRQs")
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 drivers/soundwire/bus_type.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
index d61a97c5b41ef..fea15107cd9b9 100644
--- a/drivers/soundwire/bus_type.c
+++ b/drivers/soundwire/bus_type.c
@@ -71,6 +71,13 @@ int sdw_slave_uevent(const struct device *dev, struct kobj_uevent_env *env)
 	return 0;
 }
 
+static void sdw_slave_ida_free(void *data)
+{
+	struct sdw_slave *slave = data;
+
+	ida_free(&slave->bus->slave_ida, slave->index);
+}
+
 static int sdw_bus_probe(struct device *dev)
 {
 	struct sdw_slave *slave = dev_to_sdw_dev(dev);
@@ -104,15 +111,16 @@ static int sdw_bus_probe(struct device *dev)
 		return ret;
 	}
 	slave->index = ret;
+	ret = devm_add_action_or_reset(dev, sdw_slave_ida_free, slave);
+	if (ret)
+		return ret;
 
 	/* Create IRQ mapping now so the driver can get it in probe() */
 	sdw_irq_create_mapping(slave);
 
 	ret = drv->probe(slave, id);
-	if (ret) {
-		ida_free(&slave->bus->slave_ida, slave->index);
+	if (ret)
 		return ret;
-	}
 
 	mutex_lock(&slave->sdw_dev_lock);
 
@@ -170,8 +178,6 @@ static void sdw_bus_remove(struct device *dev)
 
 	if (drv->remove)
 		drv->remove(slave);
-
-	ida_free(&slave->bus->slave_ida, slave->index);
 }
 
 static void sdw_bus_shutdown(struct device *dev)
-- 
2.47.3


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

* Re: [PATCH] soundwire: bus_type: Use devres to free slave IDA
  2026-08-31 11:29 [PATCH] soundwire: bus_type: Use devres to free slave IDA Richard Fitzgerald
@ 2026-08-31 11:51 ` Charles Keepax
  2026-09-01 17:15 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Charles Keepax @ 2026-08-31 11:51 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: vkoul, linux-sound, linux-kernel, patches

On Mon, Aug 31, 2026 at 12:29:39PM +0100, Richard Fitzgerald wrote:
> Create a devres cleanup action to call ida_free(). This ensures that it
> is freed after anything that is cleaned up by devres and might have been
> using the allocated ID. It also avoids mixing devres and manual cleanup
> during sdw_bus_probe().
> 
> Fixes: aab12022b076f ("soundwire: bus: Add internal slave ID and use for IRQs")
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles

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

* Re: [PATCH] soundwire: bus_type: Use devres to free slave IDA
  2026-08-31 11:29 [PATCH] soundwire: bus_type: Use devres to free slave IDA Richard Fitzgerald
  2026-08-31 11:51 ` Charles Keepax
@ 2026-09-01 17:15 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2026-09-01 17:15 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: linux-sound, linux-kernel, patches


On Mon, 31 Aug 2026 12:29:39 +0100, Richard Fitzgerald wrote:
> Create a devres cleanup action to call ida_free(). This ensures that it
> is freed after anything that is cleaned up by devres and might have been
> using the allocated ID. It also avoids mixing devres and manual cleanup
> during sdw_bus_probe().
> 
> 

Applied, thanks!

[1/1] soundwire: bus_type: Use devres to free slave IDA
      commit: bb22b81339cb97d2eb7ec666bf03f985fe64d6cb

Best regards,
-- 
~Vinod



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

end of thread, other threads:[~2026-09-01 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-31 11:29 [PATCH] soundwire: bus_type: Use devres to free slave IDA Richard Fitzgerald
2026-08-31 11:51 ` Charles Keepax
2026-09-01 17:15 ` Vinod Koul

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