Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: bus: Move irq mapping cleanup into devres

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>

authored by

Charles Keepax and committed by
Vinod Koul
a5fef9ba 40384c84

+8 -12
-3
drivers/soundwire/bus_type.c
··· 167 167 168 168 slave->probed = false; 169 169 170 - if (slave->prop.use_domain_irq) 171 - sdw_irq_dispose_mapping(slave); 172 - 173 170 mutex_unlock(&slave->sdw_dev_lock); 174 171 175 172 if (drv->remove)
+8 -4
drivers/soundwire/irq.c
··· 46 46 irq_domain_remove(bus->domain); 47 47 } 48 48 49 + static void sdw_irq_dispose_mapping(void *data) 50 + { 51 + struct sdw_slave *slave = data; 52 + 53 + irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num)); 54 + } 55 + 49 56 void sdw_irq_create_mapping(struct sdw_slave *slave) 50 57 { 51 58 slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num); 52 59 if (!slave->irq) 53 60 dev_warn(&slave->dev, "Failed to map IRQ\n"); 54 - } 55 61 56 - void sdw_irq_dispose_mapping(struct sdw_slave *slave) 57 - { 58 - irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num)); 62 + devm_add_action_or_reset(&slave->dev, sdw_irq_dispose_mapping, slave); 59 63 }
-5
drivers/soundwire/irq.h
··· 16 16 struct fwnode_handle *fwnode); 17 17 void sdw_irq_delete(struct sdw_bus *bus); 18 18 void sdw_irq_create_mapping(struct sdw_slave *slave); 19 - void sdw_irq_dispose_mapping(struct sdw_slave *slave); 20 19 21 20 #else /* CONFIG_IRQ_DOMAIN */ 22 21 ··· 30 31 } 31 32 32 33 static inline void sdw_irq_create_mapping(struct sdw_slave *slave) 33 - { 34 - } 35 - 36 - static inline void sdw_irq_dispose_mapping(struct sdw_slave *slave) 37 34 { 38 35 } 39 36