Skip to content

Commit 17fdf31

Browse files
linuswbroonie
authored andcommitted
ASoC: pcm6240: Drop bogus code handling IRQ as GPIO
The current code for the IRQ in pcm6240 makes no sense: it looks up an IRQ with of_irq_get(), treat it as a GPIO by issuing gpio_request(), gpio_direction_input() and gpio_to_irq() on it. This is just wrong, if the device tree assigns the IRQ from a GPIO number this is just incorrect: it is clearly stated that GPIO providers and IRQ providers are orthogonal. It is possible to look up an IRQ to a corresponding GPIO line but this is taking an IRQ and pretending it's a GPIO, which is just semantically wrong. Drop the offending code and treat the IRQ that we get from the device tree as any other IRQ, see for example other codec drivers. The DT bindings for this codec does not have any in-tree DTS files, which may explain why things are weird. As a bonus, this moves the driver away from the legacy <linux/gpio.h> include. Signed-off-by: Linus Walleij <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent ef5aa8b commit 17fdf31

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

sound/soc/codecs/pcm6240.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <linux/unaligned.h>
1616
#include <linux/firmware.h>
17-
#include <linux/gpio.h>
17+
#include <linux/gpio/consumer.h>
1818
#include <linux/i2c.h>
1919
#include <linux/module.h>
2020
#include <linux/of_irq.h>
@@ -2035,10 +2035,8 @@ static const struct regmap_config pcmdevice_i2c_regmap = {
20352035

20362036
static void pcmdevice_remove(struct pcmdevice_priv *pcm_dev)
20372037
{
2038-
if (gpio_is_valid(pcm_dev->irq_info.gpio)) {
2039-
gpio_free(pcm_dev->irq_info.gpio);
2040-
free_irq(pcm_dev->irq_info.nmb, pcm_dev);
2041-
}
2038+
if (pcm_dev->irq)
2039+
free_irq(pcm_dev->irq, pcm_dev);
20422040
mutex_destroy(&pcm_dev->codec_lock);
20432041
}
20442042

@@ -2109,7 +2107,7 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c)
21092107
ndev = 1;
21102108
dev_addrs[0] = i2c->addr;
21112109
}
2112-
pcm_dev->irq_info.gpio = of_irq_get(np, 0);
2110+
pcm_dev->irq = of_irq_get(np, 0);
21132111

21142112
for (i = 0; i < ndev; i++)
21152113
pcm_dev->addr[i] = dev_addrs[i];
@@ -2132,22 +2130,10 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c)
21322130

21332131
if (pcm_dev->chip_id == PCM1690)
21342132
goto skip_interrupt;
2135-
if (gpio_is_valid(pcm_dev->irq_info.gpio)) {
2136-
dev_dbg(pcm_dev->dev, "irq-gpio = %d", pcm_dev->irq_info.gpio);
2137-
2138-
ret = gpio_request(pcm_dev->irq_info.gpio, "PCMDEV-IRQ");
2139-
if (!ret) {
2140-
int gpio = pcm_dev->irq_info.gpio;
2141-
2142-
gpio_direction_input(gpio);
2143-
pcm_dev->irq_info.nmb = gpio_to_irq(gpio);
2144-
2145-
} else
2146-
dev_err(pcm_dev->dev, "%s: GPIO %d request error\n",
2147-
__func__, pcm_dev->irq_info.gpio);
2133+
if (pcm_dev->irq) {
2134+
dev_dbg(pcm_dev->dev, "irq = %d", pcm_dev->irq);
21482135
} else
2149-
dev_err(pcm_dev->dev, "Looking up irq-gpio failed %d\n",
2150-
pcm_dev->irq_info.gpio);
2136+
dev_err(pcm_dev->dev, "No irq provided\n");
21512137

21522138
skip_interrupt:
21532139
ret = devm_snd_soc_register_component(&i2c->dev,

sound/soc/codecs/pcm6240.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,6 @@ struct pcmdevice_regbin {
208208
struct pcmdevice_config_info **cfg_info;
209209
};
210210

211-
struct pcmdevice_irqinfo {
212-
int gpio;
213-
int nmb;
214-
};
215-
216211
struct pcmdevice_priv {
217212
struct snd_soc_component *component;
218213
struct i2c_client *client;
@@ -221,7 +216,7 @@ struct pcmdevice_priv {
221216
struct gpio_desc *hw_rst;
222217
struct regmap *regmap;
223218
struct pcmdevice_regbin regbin;
224-
struct pcmdevice_irqinfo irq_info;
219+
int irq;
225220
unsigned int addr[PCMDEVICE_MAX_I2C_DEVICES];
226221
unsigned int chip_id;
227222
int cur_conf;

0 commit comments

Comments
 (0)