Skip to content

Commit a5fef9b

Browse files
charleskeepaxvinodkoul
authored andcommitted
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>
1 parent 40384c8 commit a5fef9b

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

drivers/soundwire/bus_type.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ static int sdw_drv_remove(struct device *dev)
167167

168168
slave->probed = false;
169169

170-
if (slave->prop.use_domain_irq)
171-
sdw_irq_dispose_mapping(slave);
172-
173170
mutex_unlock(&slave->sdw_dev_lock);
174171

175172
if (drv->remove)

drivers/soundwire/irq.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,18 @@ void sdw_irq_delete(struct sdw_bus *bus)
4646
irq_domain_remove(bus->domain);
4747
}
4848

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+
4956
void sdw_irq_create_mapping(struct sdw_slave *slave)
5057
{
5158
slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num);
5259
if (!slave->irq)
5360
dev_warn(&slave->dev, "Failed to map IRQ\n");
54-
}
5561

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);
5963
}

drivers/soundwire/irq.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ int sdw_irq_create(struct sdw_bus *bus,
1616
struct fwnode_handle *fwnode);
1717
void sdw_irq_delete(struct sdw_bus *bus);
1818
void sdw_irq_create_mapping(struct sdw_slave *slave);
19-
void sdw_irq_dispose_mapping(struct sdw_slave *slave);
2019

2120
#else /* CONFIG_IRQ_DOMAIN */
2221

@@ -34,10 +33,6 @@ static inline void sdw_irq_create_mapping(struct sdw_slave *slave)
3433
{
3534
}
3635

37-
static inline void sdw_irq_dispose_mapping(struct sdw_slave *slave)
38-
{
39-
}
40-
4136
#endif /* CONFIG_IRQ_DOMAIN */
4237

4338
#endif /* __SDW_IRQ_H */

0 commit comments

Comments
 (0)