mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-09 22:24:04 +08:00
ASoC: wm0010: Move resource acquisition to device probe
This is more idimatic for modern drivers. Also fix a couple of return codes while we're at it. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
bf9d323722
commit
32c50a31aa
@ -799,14 +799,35 @@ static irqreturn_t wm0010_irq(int irq, void *data)
|
|||||||
static int wm0010_probe(struct snd_soc_codec *codec)
|
static int wm0010_probe(struct snd_soc_codec *codec)
|
||||||
{
|
{
|
||||||
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
|
struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
|
||||||
struct spi_device *spi = to_spi_device(wm0010->dev);
|
|
||||||
|
wm0010->codec = codec;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __devinit wm0010_spi_probe(struct spi_device *spi)
|
||||||
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned long gpio_flags;
|
unsigned long gpio_flags;
|
||||||
int ret;
|
int ret;
|
||||||
int trigger;
|
int trigger;
|
||||||
int irq;
|
int irq;
|
||||||
|
struct wm0010_priv *wm0010;
|
||||||
|
|
||||||
wm0010->codec = codec;
|
wm0010 = devm_kzalloc(&spi->dev, sizeof(*wm0010),
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (!wm0010)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
mutex_init(&wm0010->lock);
|
||||||
|
spin_lock_init(&wm0010->irq_lock);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, wm0010);
|
||||||
|
wm0010->dev = &spi->dev;
|
||||||
|
|
||||||
|
if (dev_get_platdata(&spi->dev))
|
||||||
|
memcpy(&wm0010->pdata, dev_get_platdata(&spi->dev),
|
||||||
|
sizeof(wm0010->pdata));
|
||||||
|
|
||||||
init_completion(&wm0010->boot_completion);
|
init_completion(&wm0010->boot_completion);
|
||||||
|
|
||||||
@ -850,7 +871,7 @@ static int wm0010_probe(struct snd_soc_codec *codec)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dev_err(wm0010->dev, "No reset GPIO configured\n");
|
dev_err(wm0010->dev, "No reset GPIO configured\n");
|
||||||
return ret;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
irq = spi->irq;
|
irq = spi->irq;
|
||||||
@ -862,9 +883,11 @@ static int wm0010_probe(struct snd_soc_codec *codec)
|
|||||||
|
|
||||||
ret = request_threaded_irq(irq, NULL, wm0010_irq, trigger,
|
ret = request_threaded_irq(irq, NULL, wm0010_irq, trigger,
|
||||||
"wm0010", wm0010);
|
"wm0010", wm0010);
|
||||||
if (ret)
|
if (ret) {
|
||||||
dev_err(wm0010->dev, "Failed to request IRQ %d: %d\n",
|
dev_err(wm0010->dev, "Failed to request IRQ %d: %d\n",
|
||||||
irq, ret);
|
irq, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
wm0010->irq = irq;
|
wm0010->irq = irq;
|
||||||
|
|
||||||
if (spi->max_speed_hz)
|
if (spi->max_speed_hz)
|
||||||
@ -876,29 +899,6 @@ static int wm0010_probe(struct snd_soc_codec *codec)
|
|||||||
wm0010->state = WM0010_POWER_OFF;
|
wm0010->state = WM0010_POWER_OFF;
|
||||||
spin_unlock_irqrestore(&wm0010->irq_lock, flags);
|
spin_unlock_irqrestore(&wm0010->irq_lock, flags);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int __devinit wm0010_spi_probe(struct spi_device *spi)
|
|
||||||
{
|
|
||||||
struct wm0010_priv *wm0010;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
wm0010 = devm_kzalloc(&spi->dev, sizeof(*wm0010),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (!wm0010)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
mutex_init(&wm0010->lock);
|
|
||||||
spin_lock_init(&wm0010->irq_lock);
|
|
||||||
|
|
||||||
spi_set_drvdata(spi, wm0010);
|
|
||||||
wm0010->dev = &spi->dev;
|
|
||||||
|
|
||||||
if (dev_get_platdata(&spi->dev))
|
|
||||||
memcpy(&wm0010->pdata, dev_get_platdata(&spi->dev),
|
|
||||||
sizeof(wm0010->pdata));
|
|
||||||
|
|
||||||
ret = snd_soc_register_codec(&spi->dev,
|
ret = snd_soc_register_codec(&spi->dev,
|
||||||
&soc_codec_dev_wm0010, wm0010_dai,
|
&soc_codec_dev_wm0010, wm0010_dai,
|
||||||
ARRAY_SIZE(wm0010_dai));
|
ARRAY_SIZE(wm0010_dai));
|
||||||
|
Loading…
Reference in New Issue
Block a user