]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soundwire: bus: Move irq mapping cleanup into devres
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Thu, 5 Dec 2024 11:33:15 +0000 (11:33 +0000)
committerVinod Koul <vkoul@kernel.org>
Mon, 23 Dec 2024 06:11:09 +0000 (11:41 +0530)
Currently the IRQ mapping is disposed off in sdw_drv_remove(), however
if the SoundWire device uses devres this can run before the actual device
clean up, potentially clearing the mapping whilst it is still in use.
Make this devres safe by also moving the sdw_irq_dispose_mapping into
devres.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20241205113315.2266313-1-ckeepax@opensource.cirrus.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/bus_type.c
drivers/soundwire/irq.c
drivers/soundwire/irq.h

index 77dc094075e131582d55c3379b738598f4e1b654..e98d5db81b1ced347b62478df62949f0e76e081a 100644 (file)
@@ -167,9 +167,6 @@ static int sdw_drv_remove(struct device *dev)
 
        slave->probed = false;
 
-       if (slave->prop.use_domain_irq)
-               sdw_irq_dispose_mapping(slave);
-
        mutex_unlock(&slave->sdw_dev_lock);
 
        if (drv->remove)
index 0c08cebb1235cb28f86e1a78aaee757472f56c1b..c237e6d0766b330c77515641ea143667e334716d 100644 (file)
@@ -46,14 +46,18 @@ void sdw_irq_delete(struct sdw_bus *bus)
        irq_domain_remove(bus->domain);
 }
 
+static void sdw_irq_dispose_mapping(void *data)
+{
+       struct sdw_slave *slave = data;
+
+       irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
+}
+
 void sdw_irq_create_mapping(struct sdw_slave *slave)
 {
        slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num);
        if (!slave->irq)
                dev_warn(&slave->dev, "Failed to map IRQ\n");
-}
 
-void sdw_irq_dispose_mapping(struct sdw_slave *slave)
-{
-       irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
+       devm_add_action_or_reset(&slave->dev, sdw_irq_dispose_mapping, slave);
 }
index 58a58046d92b83adcc5fb769de7d43c9158ce5eb..86e2318409dab8b8137df45586029a6312ee61ff 100644 (file)
@@ -16,7 +16,6 @@ int sdw_irq_create(struct sdw_bus *bus,
                   struct fwnode_handle *fwnode);
 void sdw_irq_delete(struct sdw_bus *bus);
 void sdw_irq_create_mapping(struct sdw_slave *slave);
-void sdw_irq_dispose_mapping(struct sdw_slave *slave);
 
 #else /* CONFIG_IRQ_DOMAIN */
 
@@ -34,10 +33,6 @@ static inline void sdw_irq_create_mapping(struct sdw_slave *slave)
 {
 }
 
-static inline void sdw_irq_dispose_mapping(struct sdw_slave *slave)
-{
-}
-
 #endif /* CONFIG_IRQ_DOMAIN */
 
 #endif /* __SDW_IRQ_H */