ASoC: pcm6240: Drop bogus code handling IRQ as GPIO

[ Upstream commit 17fdf318f5fbe5c27353ae917c0c5a2899d9c259 ]

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 <linus.walleij@linaro.org>
Link: https://patch.msgid.link/20250312-pcm-codecs-v1-3-41ffc4f8fc5c@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Linus Walleij
2025-03-12 14:31:52 +01:00
committed by Greg Kroah-Hartman
parent 0076b0423b
commit e8358aa00e
2 changed files with 8 additions and 27 deletions

View File

@@ -14,7 +14,7 @@
#include <linux/unaligned.h>
#include <linux/firmware.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/of_irq.h>
@@ -2035,10 +2035,8 @@ static const struct regmap_config pcmdevice_i2c_regmap = {
static void pcmdevice_remove(struct pcmdevice_priv *pcm_dev)
{
if (gpio_is_valid(pcm_dev->irq_info.gpio)) {
gpio_free(pcm_dev->irq_info.gpio);
free_irq(pcm_dev->irq_info.nmb, pcm_dev);
}
if (pcm_dev->irq)
free_irq(pcm_dev->irq, pcm_dev);
mutex_destroy(&pcm_dev->codec_lock);
}
@@ -2110,7 +2108,7 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c)
ndev = 1;
dev_addrs[0] = i2c->addr;
}
pcm_dev->irq_info.gpio = of_irq_get(np, 0);
pcm_dev->irq = of_irq_get(np, 0);
for (i = 0; i < ndev; i++)
pcm_dev->addr[i] = dev_addrs[i];
@@ -2133,22 +2131,10 @@ static int pcmdevice_i2c_probe(struct i2c_client *i2c)
if (pcm_dev->chip_id == PCM1690)
goto skip_interrupt;
if (gpio_is_valid(pcm_dev->irq_info.gpio)) {
dev_dbg(pcm_dev->dev, "irq-gpio = %d", pcm_dev->irq_info.gpio);
ret = gpio_request(pcm_dev->irq_info.gpio, "PCMDEV-IRQ");
if (!ret) {
int gpio = pcm_dev->irq_info.gpio;
gpio_direction_input(gpio);
pcm_dev->irq_info.nmb = gpio_to_irq(gpio);
} else
dev_err(pcm_dev->dev, "%s: GPIO %d request error\n",
__func__, pcm_dev->irq_info.gpio);
if (pcm_dev->irq) {
dev_dbg(pcm_dev->dev, "irq = %d", pcm_dev->irq);
} else
dev_err(pcm_dev->dev, "Looking up irq-gpio failed %d\n",
pcm_dev->irq_info.gpio);
dev_err(pcm_dev->dev, "No irq provided\n");
skip_interrupt:
ret = devm_snd_soc_register_component(&i2c->dev,

View File

@@ -208,11 +208,6 @@ struct pcmdevice_regbin {
struct pcmdevice_config_info **cfg_info;
};
struct pcmdevice_irqinfo {
int gpio;
int nmb;
};
struct pcmdevice_priv {
struct snd_soc_component *component;
struct i2c_client *client;
@@ -221,7 +216,7 @@ struct pcmdevice_priv {
struct gpio_desc *hw_rst;
struct regmap *regmap;
struct pcmdevice_regbin regbin;
struct pcmdevice_irqinfo irq_info;
int irq;
unsigned int addr[PCMDEVICE_MAX_I2C_DEVICES];
unsigned int chip_id;
int cur_conf;