Skip to content

Commit 17325a2

Browse files
committed
Merge tag 'soundwire-6.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire
Pull soundwire fix from Vinod Koul: "A single fix for making sdw bus irq conditionally built" * tag 'soundwire-6.6-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire: soundwire: bus: Make IRQ handling conditionally built
2 parents 3439b2a + 3b6c4a1 commit 17325a2

File tree

5 files changed

+115
-33
lines changed

5 files changed

+115
-33
lines changed

drivers/soundwire/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ ifdef CONFIG_DEBUG_FS
1515
soundwire-bus-y += debugfs.o
1616
endif
1717

18+
ifdef CONFIG_IRQ_DOMAIN
19+
soundwire-bus-y += irq.o
20+
endif
21+
1822
#AMD driver
1923
soundwire-amd-y := amd_manager.o
2024
obj-$(CONFIG_SOUNDWIRE_AMD) += soundwire-amd.o

drivers/soundwire/bus.c

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
#include <linux/acpi.h>
55
#include <linux/delay.h>
6-
#include <linux/irq.h>
76
#include <linux/mod_devicetable.h>
87
#include <linux/pm_runtime.h>
98
#include <linux/soundwire/sdw_registers.h>
109
#include <linux/soundwire/sdw.h>
1110
#include <linux/soundwire/sdw_type.h>
1211
#include "bus.h"
12+
#include "irq.h"
1313
#include "sysfs_local.h"
1414

1515
static DEFINE_IDA(sdw_bus_ida);
@@ -25,23 +25,6 @@ static int sdw_get_id(struct sdw_bus *bus)
2525
return 0;
2626
}
2727

28-
static int sdw_irq_map(struct irq_domain *h, unsigned int virq,
29-
irq_hw_number_t hw)
30-
{
31-
struct sdw_bus *bus = h->host_data;
32-
33-
irq_set_chip_data(virq, bus);
34-
irq_set_chip(virq, &bus->irq_chip);
35-
irq_set_nested_thread(virq, 1);
36-
irq_set_noprobe(virq);
37-
38-
return 0;
39-
}
40-
41-
static const struct irq_domain_ops sdw_domain_ops = {
42-
.map = sdw_irq_map,
43-
};
44-
4528
/**
4629
* sdw_bus_master_add() - add a bus Master instance
4730
* @bus: bus instance
@@ -168,13 +151,9 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,
168151
bus->params.curr_bank = SDW_BANK0;
169152
bus->params.next_bank = SDW_BANK1;
170153

171-
bus->irq_chip.name = dev_name(bus->dev);
172-
bus->domain = irq_domain_create_linear(fwnode, SDW_MAX_DEVICES,
173-
&sdw_domain_ops, bus);
174-
if (!bus->domain) {
175-
dev_err(bus->dev, "Failed to add IRQ domain\n");
176-
return -EINVAL;
177-
}
154+
ret = sdw_irq_create(bus, fwnode);
155+
if (ret)
156+
return ret;
178157

179158
return 0;
180159
}
@@ -213,7 +192,7 @@ void sdw_bus_master_delete(struct sdw_bus *bus)
213192
{
214193
device_for_each_child(bus->dev, NULL, sdw_delete_slave);
215194

216-
irq_domain_remove(bus->domain);
195+
sdw_irq_delete(bus);
217196

218197
sdw_master_device_del(bus);
219198

drivers/soundwire/bus_type.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/soundwire/sdw.h>
88
#include <linux/soundwire/sdw_type.h>
99
#include "bus.h"
10+
#include "irq.h"
1011
#include "sysfs_local.h"
1112

1213
/**
@@ -122,11 +123,8 @@ static int sdw_drv_probe(struct device *dev)
122123
if (drv->ops && drv->ops->read_prop)
123124
drv->ops->read_prop(slave);
124125

125-
if (slave->prop.use_domain_irq) {
126-
slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num);
127-
if (!slave->irq)
128-
dev_warn(dev, "Failed to map IRQ\n");
129-
}
126+
if (slave->prop.use_domain_irq)
127+
sdw_irq_create_mapping(slave);
130128

131129
/* init the sysfs as we have properties now */
132130
ret = sdw_slave_sysfs_init(slave);
@@ -176,8 +174,7 @@ static int sdw_drv_remove(struct device *dev)
176174
slave->probed = false;
177175

178176
if (slave->prop.use_domain_irq)
179-
irq_dispose_mapping(irq_find_mapping(slave->bus->domain,
180-
slave->dev_num));
177+
sdw_irq_dispose_mapping(slave);
181178

182179
mutex_unlock(&slave->sdw_dev_lock);
183180

drivers/soundwire/irq.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
// Copyright (C) 2023 Cirrus Logic, Inc. and
3+
// Cirrus Logic International Semiconductor Ltd.
4+
5+
#include <linux/device.h>
6+
#include <linux/fwnode.h>
7+
#include <linux/irq.h>
8+
#include <linux/irqdomain.h>
9+
#include <linux/soundwire/sdw.h>
10+
#include "irq.h"
11+
12+
static int sdw_irq_map(struct irq_domain *h, unsigned int virq,
13+
irq_hw_number_t hw)
14+
{
15+
struct sdw_bus *bus = h->host_data;
16+
17+
irq_set_chip_data(virq, bus);
18+
irq_set_chip(virq, &bus->irq_chip);
19+
irq_set_nested_thread(virq, 1);
20+
irq_set_noprobe(virq);
21+
22+
return 0;
23+
}
24+
25+
static const struct irq_domain_ops sdw_domain_ops = {
26+
.map = sdw_irq_map,
27+
};
28+
29+
int sdw_irq_create(struct sdw_bus *bus,
30+
struct fwnode_handle *fwnode)
31+
{
32+
bus->irq_chip.name = dev_name(bus->dev);
33+
34+
bus->domain = irq_domain_create_linear(fwnode, SDW_MAX_DEVICES,
35+
&sdw_domain_ops, bus);
36+
if (!bus->domain) {
37+
dev_err(bus->dev, "Failed to add IRQ domain\n");
38+
return -EINVAL;
39+
}
40+
41+
return 0;
42+
}
43+
44+
void sdw_irq_delete(struct sdw_bus *bus)
45+
{
46+
irq_domain_remove(bus->domain);
47+
}
48+
49+
void sdw_irq_create_mapping(struct sdw_slave *slave)
50+
{
51+
slave->irq = irq_create_mapping(slave->bus->domain, slave->dev_num);
52+
if (!slave->irq)
53+
dev_warn(&slave->dev, "Failed to map IRQ\n");
54+
}
55+
56+
void sdw_irq_dispose_mapping(struct sdw_slave *slave)
57+
{
58+
irq_dispose_mapping(irq_find_mapping(slave->bus->domain, slave->dev_num));
59+
}

drivers/soundwire/irq.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2023 Cirrus Logic, Inc. and
4+
* Cirrus Logic International Semiconductor Ltd.
5+
*/
6+
7+
#ifndef __SDW_IRQ_H
8+
#define __SDW_IRQ_H
9+
10+
#include <linux/soundwire/sdw.h>
11+
#include <linux/fwnode.h>
12+
13+
#if IS_ENABLED(CONFIG_IRQ_DOMAIN)
14+
15+
int sdw_irq_create(struct sdw_bus *bus,
16+
struct fwnode_handle *fwnode);
17+
void sdw_irq_delete(struct sdw_bus *bus);
18+
void sdw_irq_create_mapping(struct sdw_slave *slave);
19+
void sdw_irq_dispose_mapping(struct sdw_slave *slave);
20+
21+
#else /* CONFIG_IRQ_DOMAIN */
22+
23+
static inline int sdw_irq_create(struct sdw_bus *bus,
24+
struct fwnode_handle *fwnode)
25+
{
26+
return 0;
27+
}
28+
29+
static inline void sdw_irq_delete(struct sdw_bus *bus)
30+
{
31+
}
32+
33+
static inline void sdw_irq_create_mapping(struct sdw_slave *slave)
34+
{
35+
}
36+
37+
static inline void sdw_irq_dispose_mapping(struct sdw_slave *slave)
38+
{
39+
}
40+
41+
#endif /* CONFIG_IRQ_DOMAIN */
42+
43+
#endif /* __SDW_IRQ_H */

0 commit comments

Comments
 (0)