Commit 796ff73a authored by Mark Brown's avatar Mark Brown

Merge remote-tracking branches 'asoc/topic/hisi', 'asoc/topic/img',...

Merge remote-tracking branches 'asoc/topic/hisi', 'asoc/topic/img', 'asoc/topic/jack' and 'asoc/topic/jz4740' into asoc-next
...@@ -203,9 +203,6 @@ static int imx_es8328_remove(struct platform_device *pdev) ...@@ -203,9 +203,6 @@ static int imx_es8328_remove(struct platform_device *pdev)
{ {
struct imx_es8328_data *data = platform_get_drvdata(pdev); struct imx_es8328_data *data = platform_get_drvdata(pdev);
snd_soc_jack_free_gpios(&headset_jack, ARRAY_SIZE(headset_jack_gpios),
headset_jack_gpios);
snd_soc_unregister_card(&data->card); snd_soc_unregister_card(&data->card);
return 0; return 0;
......
...@@ -104,12 +104,6 @@ static int asoc_simple_card_init_jack(struct snd_soc_card *card, ...@@ -104,12 +104,6 @@ static int asoc_simple_card_init_jack(struct snd_soc_card *card,
return 0; return 0;
} }
static void asoc_simple_card_remove_jack(struct asoc_simple_jack *sjack)
{
if (gpio_is_valid(sjack->gpio.gpio))
snd_soc_jack_free_gpios(&sjack->jack, 1, &sjack->gpio);
}
static int asoc_simple_card_startup(struct snd_pcm_substream *substream) static int asoc_simple_card_startup(struct snd_pcm_substream *substream)
{ {
struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data;
...@@ -493,10 +487,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev) ...@@ -493,10 +487,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
static int asoc_simple_card_remove(struct platform_device *pdev) static int asoc_simple_card_remove(struct platform_device *pdev)
{ {
struct snd_soc_card *card = platform_get_drvdata(pdev); struct snd_soc_card *card = platform_get_drvdata(pdev);
struct simple_card_data *priv = snd_soc_card_get_drvdata(card);
asoc_simple_card_remove_jack(&priv->hp_jack);
asoc_simple_card_remove_jack(&priv->mic_jack);
return asoc_simple_card_clean_reference(card); return asoc_simple_card_clean_reference(card);
} }
......
...@@ -517,7 +517,7 @@ static int hi6210_i2s_dai_probe(struct snd_soc_dai *dai) ...@@ -517,7 +517,7 @@ static int hi6210_i2s_dai_probe(struct snd_soc_dai *dai)
} }
static struct snd_soc_dai_ops hi6210_i2s_dai_ops = { static const struct snd_soc_dai_ops hi6210_i2s_dai_ops = {
.trigger = hi6210_i2s_trigger, .trigger = hi6210_i2s_trigger,
.hw_params = hi6210_i2s_hw_params, .hw_params = hi6210_i2s_hw_params,
.set_fmt = hi6210_i2s_set_fmt, .set_fmt = hi6210_i2s_set_fmt,
......
...@@ -443,7 +443,7 @@ static int img_i2s_in_probe(struct platform_device *pdev) ...@@ -443,7 +443,7 @@ static int img_i2s_in_probe(struct platform_device *pdev)
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE; SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE;
i2s->dai_driver.ops = &img_i2s_in_dai_ops; i2s->dai_driver.ops = &img_i2s_in_dai_ops;
rst = devm_reset_control_get(dev, "rst"); rst = devm_reset_control_get_exclusive(dev, "rst");
if (IS_ERR(rst)) { if (IS_ERR(rst)) {
if (PTR_ERR(rst) == -EPROBE_DEFER) { if (PTR_ERR(rst) == -EPROBE_DEFER) {
ret = -EPROBE_DEFER; ret = -EPROBE_DEFER;
......
...@@ -446,7 +446,7 @@ static int img_i2s_out_probe(struct platform_device *pdev) ...@@ -446,7 +446,7 @@ static int img_i2s_out_probe(struct platform_device *pdev)
i2s->channel_base = base + (max_i2s_chan_pow_2 * 0x20); i2s->channel_base = base + (max_i2s_chan_pow_2 * 0x20);
i2s->rst = devm_reset_control_get(&pdev->dev, "rst"); i2s->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst");
if (IS_ERR(i2s->rst)) { if (IS_ERR(i2s->rst)) {
if (PTR_ERR(i2s->rst) != -EPROBE_DEFER) if (PTR_ERR(i2s->rst) != -EPROBE_DEFER)
dev_err(&pdev->dev, "No top level reset found\n"); dev_err(&pdev->dev, "No top level reset found\n");
......
...@@ -224,7 +224,7 @@ static int img_prl_out_probe(struct platform_device *pdev) ...@@ -224,7 +224,7 @@ static int img_prl_out_probe(struct platform_device *pdev)
prl->base = base; prl->base = base;
prl->rst = devm_reset_control_get(&pdev->dev, "rst"); prl->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst");
if (IS_ERR(prl->rst)) { if (IS_ERR(prl->rst)) {
if (PTR_ERR(prl->rst) != -EPROBE_DEFER) if (PTR_ERR(prl->rst) != -EPROBE_DEFER)
dev_err(&pdev->dev, "No top level reset found\n"); dev_err(&pdev->dev, "No top level reset found\n");
......
...@@ -727,7 +727,7 @@ static int img_spdif_in_probe(struct platform_device *pdev) ...@@ -727,7 +727,7 @@ static int img_spdif_in_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
rst = devm_reset_control_get(&pdev->dev, "rst"); rst = devm_reset_control_get_exclusive(&pdev->dev, "rst");
if (IS_ERR(rst)) { if (IS_ERR(rst)) {
if (PTR_ERR(rst) == -EPROBE_DEFER) { if (PTR_ERR(rst) == -EPROBE_DEFER) {
ret = -EPROBE_DEFER; ret = -EPROBE_DEFER;
......
...@@ -334,7 +334,7 @@ static int img_spdif_out_probe(struct platform_device *pdev) ...@@ -334,7 +334,7 @@ static int img_spdif_out_probe(struct platform_device *pdev)
spdif->base = base; spdif->base = base;
spdif->rst = devm_reset_control_get(&pdev->dev, "rst"); spdif->rst = devm_reset_control_get_exclusive(&pdev->dev, "rst");
if (IS_ERR(spdif->rst)) { if (IS_ERR(spdif->rst)) {
if (PTR_ERR(spdif->rst) != -EPROBE_DEFER) if (PTR_ERR(spdif->rst) != -EPROBE_DEFER)
dev_err(&pdev->dev, "No top level reset found\n"); dev_err(&pdev->dev, "No top level reset found\n");
......
...@@ -173,20 +173,8 @@ static int byt_max98090_probe(struct platform_device *pdev) ...@@ -173,20 +173,8 @@ static int byt_max98090_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int byt_max98090_remove(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
struct byt_max98090_private *priv = snd_soc_card_get_drvdata(card);
snd_soc_jack_free_gpios(&priv->jack, ARRAY_SIZE(hs_jack_gpios),
hs_jack_gpios);
return 0;
}
static struct platform_driver byt_max98090_driver = { static struct platform_driver byt_max98090_driver = {
.probe = byt_max98090_probe, .probe = byt_max98090_probe,
.remove = byt_max98090_remove,
.driver = { .driver = {
.name = "byt-max98090", .name = "byt-max98090",
.pm = &snd_soc_pm_ops, .pm = &snd_soc_pm_ops,
......
...@@ -133,6 +133,7 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream, ...@@ -133,6 +133,7 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream,
{ {
struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
uint32_t conf, ctrl; uint32_t conf, ctrl;
int ret;
if (dai->active) if (dai->active)
return 0; return 0;
...@@ -141,7 +142,9 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream, ...@@ -141,7 +142,9 @@ static int jz4740_i2s_startup(struct snd_pcm_substream *substream,
ctrl |= JZ_AIC_CTRL_FLUSH; ctrl |= JZ_AIC_CTRL_FLUSH;
jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl); jz4740_i2s_write(i2s, JZ_REG_AIC_CTRL, ctrl);
clk_prepare_enable(i2s->clk_i2s); ret = clk_prepare_enable(i2s->clk_i2s);
if (ret)
return ret;
conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
conf |= JZ_AIC_CONF_ENABLE; conf |= JZ_AIC_CONF_ENABLE;
...@@ -352,11 +355,18 @@ static int jz4740_i2s_resume(struct snd_soc_dai *dai) ...@@ -352,11 +355,18 @@ static int jz4740_i2s_resume(struct snd_soc_dai *dai)
{ {
struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
uint32_t conf; uint32_t conf;
int ret;
clk_prepare_enable(i2s->clk_aic); ret = clk_prepare_enable(i2s->clk_aic);
if (ret)
return ret;
if (dai->active) { if (dai->active) {
clk_prepare_enable(i2s->clk_i2s); ret = clk_prepare_enable(i2s->clk_i2s);
if (ret) {
clk_disable_unprepare(i2s->clk_aic);
return ret;
}
conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF); conf = jz4740_i2s_read(i2s, JZ_REG_AIC_CONF);
conf |= JZ_AIC_CONF_ENABLE; conf |= JZ_AIC_CONF_ENABLE;
...@@ -387,8 +397,11 @@ static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai) ...@@ -387,8 +397,11 @@ static int jz4740_i2s_dai_probe(struct snd_soc_dai *dai)
{ {
struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai); struct jz4740_i2s *i2s = snd_soc_dai_get_drvdata(dai);
uint32_t conf; uint32_t conf;
int ret;
clk_prepare_enable(i2s->clk_aic); ret = clk_prepare_enable(i2s->clk_aic);
if (ret)
return ret;
jz4740_i2c_init_pcm_config(i2s); jz4740_i2c_init_pcm_config(i2s);
snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data, snd_soc_dai_init_dma_data(dai, &i2s->playback_dma_data,
......
...@@ -513,15 +513,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) ...@@ -513,15 +513,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int ams_delta_card_remove(struct snd_soc_card *card)
{
snd_soc_jack_free_gpios(&ams_delta_hook_switch,
ARRAY_SIZE(ams_delta_hook_switch_gpios),
ams_delta_hook_switch_gpios);
return 0;
}
/* DAI glue - connects codec <--> CPU */ /* DAI glue - connects codec <--> CPU */
static struct snd_soc_dai_link ams_delta_dai_link = { static struct snd_soc_dai_link ams_delta_dai_link = {
.name = "CX20442", .name = "CX20442",
...@@ -540,7 +531,6 @@ static struct snd_soc_dai_link ams_delta_dai_link = { ...@@ -540,7 +531,6 @@ static struct snd_soc_dai_link ams_delta_dai_link = {
static struct snd_soc_card ams_delta_audio_card = { static struct snd_soc_card ams_delta_audio_card = {
.name = "AMS_DELTA", .name = "AMS_DELTA",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = ams_delta_card_remove,
.dai_link = &ams_delta_dai_link, .dai_link = &ams_delta_dai_link,
.num_links = 1, .num_links = 1,
......
...@@ -208,18 +208,6 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd) ...@@ -208,18 +208,6 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
return ret; return ret;
} }
static int omap_twl4030_card_remove(struct snd_soc_card *card)
{
struct omap_twl4030 *priv = snd_soc_card_get_drvdata(card);
if (priv->jack_detect > 0)
snd_soc_jack_free_gpios(&priv->hs_jack,
ARRAY_SIZE(hs_jack_gpios),
hs_jack_gpios);
return 0;
}
/* Digital audio interface glue - connects codec <--> CPU */ /* Digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link omap_twl4030_dai_links[] = { static struct snd_soc_dai_link omap_twl4030_dai_links[] = {
{ {
...@@ -247,7 +235,6 @@ static struct snd_soc_dai_link omap_twl4030_dai_links[] = { ...@@ -247,7 +235,6 @@ static struct snd_soc_dai_link omap_twl4030_dai_links[] = {
/* Audio machine driver */ /* Audio machine driver */
static struct snd_soc_card omap_twl4030_card = { static struct snd_soc_card omap_twl4030_card = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = omap_twl4030_card_remove,
.dai_link = omap_twl4030_dai_links, .dai_link = omap_twl4030_dai_links,
.num_links = ARRAY_SIZE(omap_twl4030_dai_links), .num_links = ARRAY_SIZE(omap_twl4030_dai_links),
......
...@@ -311,14 +311,6 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) ...@@ -311,14 +311,6 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
return err; return err;
} }
static int rx51_card_remove(struct snd_soc_card *card)
{
snd_soc_jack_free_gpios(&rx51_av_jack, ARRAY_SIZE(rx51_av_jack_gpios),
rx51_av_jack_gpios);
return 0;
}
/* Digital audio interface glue - connects codec <--> CPU */ /* Digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link rx51_dai[] = { static struct snd_soc_dai_link rx51_dai[] = {
{ {
...@@ -361,7 +353,6 @@ static struct snd_soc_codec_conf rx51_codec_conf[] = { ...@@ -361,7 +353,6 @@ static struct snd_soc_codec_conf rx51_codec_conf[] = {
static struct snd_soc_card rx51_sound_card = { static struct snd_soc_card rx51_sound_card = {
.name = "RX-51", .name = "RX-51",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = rx51_card_remove,
.dai_link = rx51_dai, .dai_link = rx51_dai,
.num_links = ARRAY_SIZE(rx51_dai), .num_links = ARRAY_SIZE(rx51_dai),
.aux_dev = rx51_aux_dev, .aux_dev = rx51_aux_dev,
......
...@@ -138,13 +138,6 @@ static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) ...@@ -138,13 +138,6 @@ static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd)
return err; return err;
} }
static int hx4700_card_remove(struct snd_soc_card *card)
{
snd_soc_jack_free_gpios(&hs_jack, 1, &hs_jack_gpio);
return 0;
}
/* hx4700 digital audio interface glue - connects codec <--> CPU */ /* hx4700 digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link hx4700_dai = { static struct snd_soc_dai_link hx4700_dai = {
.name = "ak4641", .name = "ak4641",
...@@ -163,7 +156,6 @@ static struct snd_soc_dai_link hx4700_dai = { ...@@ -163,7 +156,6 @@ static struct snd_soc_dai_link hx4700_dai = {
static struct snd_soc_card snd_soc_card_hx4700 = { static struct snd_soc_card snd_soc_card_hx4700 = {
.name = "iPAQ hx4700", .name = "iPAQ hx4700",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = hx4700_card_remove,
.dai_link = &hx4700_dai, .dai_link = &hx4700_dai,
.num_links = 1, .num_links = 1,
.dapm_widgets = hx4700_dapm_widgets, .dapm_widgets = hx4700_dapm_widgets,
......
...@@ -170,14 +170,6 @@ static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) ...@@ -170,14 +170,6 @@ static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int h1940_uda1380_card_remove(struct snd_soc_card *card)
{
snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
hp_jack_gpios);
return 0;
}
/* s3c24xx digital audio interface glue - connects codec <--> CPU */ /* s3c24xx digital audio interface glue - connects codec <--> CPU */
static struct snd_soc_dai_link h1940_uda1380_dai[] = { static struct snd_soc_dai_link h1940_uda1380_dai[] = {
{ {
...@@ -197,7 +189,6 @@ static struct snd_soc_dai_link h1940_uda1380_dai[] = { ...@@ -197,7 +189,6 @@ static struct snd_soc_dai_link h1940_uda1380_dai[] = {
static struct snd_soc_card h1940_asoc = { static struct snd_soc_card h1940_asoc = {
.name = "h1940", .name = "h1940",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = h1940_uda1380_card_remove,
.dai_link = h1940_uda1380_dai, .dai_link = h1940_uda1380_dai,
.num_links = ARRAY_SIZE(h1940_uda1380_dai), .num_links = ARRAY_SIZE(h1940_uda1380_dai),
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "s3c24xx-i2s.h" #include "s3c24xx-i2s.h"
static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd); static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd);
static int rx1950_uda1380_card_remove(struct snd_soc_card *card);
static int rx1950_startup(struct snd_pcm_substream *substream); static int rx1950_startup(struct snd_pcm_substream *substream);
static int rx1950_hw_params(struct snd_pcm_substream *substream, static int rx1950_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params); struct snd_pcm_hw_params *params);
...@@ -118,7 +117,6 @@ static const struct snd_soc_dapm_route audio_map[] = { ...@@ -118,7 +117,6 @@ static const struct snd_soc_dapm_route audio_map[] = {
static struct snd_soc_card rx1950_asoc = { static struct snd_soc_card rx1950_asoc = {
.name = "rx1950", .name = "rx1950",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = rx1950_uda1380_card_remove,
.dai_link = rx1950_uda1380_dai, .dai_link = rx1950_uda1380_dai,
.num_links = ARRAY_SIZE(rx1950_uda1380_dai), .num_links = ARRAY_SIZE(rx1950_uda1380_dai),
...@@ -219,14 +217,6 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) ...@@ -219,14 +217,6 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int rx1950_uda1380_card_remove(struct snd_soc_card *card)
{
snd_soc_jack_free_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
hp_jack_gpios);
return 0;
}
static int __init rx1950_init(void) static int __init rx1950_init(void)
{ {
int ret; int ret;
......
...@@ -160,14 +160,6 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd) ...@@ -160,14 +160,6 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd)
return err; return err;
} }
static int smartq_wm8987_card_remove(struct snd_soc_card *card)
{
snd_soc_jack_free_gpios(&smartq_jack, ARRAY_SIZE(smartq_jack_gpios),
smartq_jack_gpios);
return 0;
}
static struct snd_soc_dai_link smartq_dai[] = { static struct snd_soc_dai_link smartq_dai[] = {
{ {
.name = "wm8987", .name = "wm8987",
...@@ -186,7 +178,6 @@ static struct snd_soc_dai_link smartq_dai[] = { ...@@ -186,7 +178,6 @@ static struct snd_soc_dai_link smartq_dai[] = {
static struct snd_soc_card snd_soc_smartq = { static struct snd_soc_card snd_soc_smartq = {
.name = "SmartQ", .name = "SmartQ",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = smartq_wm8987_card_remove,
.dai_link = smartq_dai, .dai_link = smartq_dai,
.num_links = ARRAY_SIZE(smartq_dai), .num_links = ARRAY_SIZE(smartq_dai),
......
...@@ -22,6 +22,12 @@ ...@@ -22,6 +22,12 @@
#include <linux/suspend.h> #include <linux/suspend.h>
#include <trace/events/asoc.h> #include <trace/events/asoc.h>
struct jack_gpio_tbl {
int count;
struct snd_soc_jack *jack;
struct snd_soc_jack_gpio *gpios;
};
/** /**
* snd_soc_codec_set_jack - configure codec jack. * snd_soc_codec_set_jack - configure codec jack.
* @codec: CODEC * @codec: CODEC
...@@ -36,7 +42,7 @@ int snd_soc_codec_set_jack(struct snd_soc_codec *codec, ...@@ -36,7 +42,7 @@ int snd_soc_codec_set_jack(struct snd_soc_codec *codec,
if (codec->driver->set_jack) if (codec->driver->set_jack)
return codec->driver->set_jack(codec, jack, data); return codec->driver->set_jack(codec, jack, data);
else else
return -EINVAL; return -ENOTSUPP;
} }
EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack); EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack);
...@@ -355,6 +361,28 @@ static int snd_soc_jack_pm_notifier(struct notifier_block *nb, ...@@ -355,6 +361,28 @@ static int snd_soc_jack_pm_notifier(struct notifier_block *nb,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static void jack_free_gpios(struct snd_soc_jack *jack, int count,
struct snd_soc_jack_gpio *gpios)
{
int i;
for (i = 0; i < count; i++) {
gpiod_unexport(gpios[i].desc);
unregister_pm_notifier(&gpios[i].pm_notifier);
free_irq(gpiod_to_irq(gpios[i].desc), &gpios[i]);
cancel_delayed_work_sync(&gpios[i].work);
gpiod_put(gpios[i].desc);
gpios[i].jack = NULL;
}
}
static void jack_devres_free_gpios(struct device *dev, void *res)
{
struct jack_gpio_tbl *tbl = res;
jack_free_gpios(tbl->jack, tbl->count, tbl->gpios);
}
/** /**
* snd_soc_jack_add_gpios - Associate GPIO pins with an ASoC jack * snd_soc_jack_add_gpios - Associate GPIO pins with an ASoC jack
* *
...@@ -369,6 +397,14 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, ...@@ -369,6 +397,14 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
struct snd_soc_jack_gpio *gpios) struct snd_soc_jack_gpio *gpios)
{ {
int i, ret; int i, ret;
struct jack_gpio_tbl *tbl;
tbl = devres_alloc(jack_devres_free_gpios, sizeof(*tbl), GFP_KERNEL);
if (!tbl)
return -ENOMEM;
tbl->jack = jack;
tbl->count = count;
tbl->gpios = gpios;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
if (!gpios[i].name) { if (!gpios[i].name) {
...@@ -446,12 +482,14 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, ...@@ -446,12 +482,14 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
msecs_to_jiffies(gpios[i].debounce_time)); msecs_to_jiffies(gpios[i].debounce_time));
} }
devres_add(jack->card->dev, tbl);
return 0; return 0;
err: err:
gpio_free(gpios[i].gpio); gpio_free(gpios[i].gpio);
undo: undo:
snd_soc_jack_free_gpios(jack, i, gpios); jack_free_gpios(jack, i, gpios);
devres_free(tbl);
return ret; return ret;
} }
...@@ -493,16 +531,8 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpiods); ...@@ -493,16 +531,8 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_add_gpiods);
void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count, void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
struct snd_soc_jack_gpio *gpios) struct snd_soc_jack_gpio *gpios)
{ {
int i; jack_free_gpios(jack, count, gpios);
devres_destroy(jack->card->dev, jack_devres_free_gpios, NULL, NULL);
for (i = 0; i < count; i++) {
gpiod_unexport(gpios[i].desc);
unregister_pm_notifier(&gpios[i].pm_notifier);
free_irq(gpiod_to_irq(gpios[i].desc), &gpios[i]);
cancel_delayed_work_sync(&gpios[i].work);
gpiod_put(gpios[i].desc);
gpios[i].jack = NULL;
}
} }
EXPORT_SYMBOL_GPL(snd_soc_jack_free_gpios); EXPORT_SYMBOL_GPL(snd_soc_jack_free_gpios);
#endif /* CONFIG_GPIOLIB */ #endif /* CONFIG_GPIOLIB */
...@@ -124,18 +124,6 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -124,18 +124,6 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int tegra_alc5632_card_remove(struct snd_soc_card *card)
{
struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(card);
if (gpio_is_valid(machine->gpio_hp_det)) {
snd_soc_jack_free_gpios(&tegra_alc5632_hs_jack, 1,
&tegra_alc5632_hp_jack_gpio);
}
return 0;
}
static struct snd_soc_dai_link tegra_alc5632_dai = { static struct snd_soc_dai_link tegra_alc5632_dai = {
.name = "ALC5632", .name = "ALC5632",
.stream_name = "ALC5632 PCM", .stream_name = "ALC5632 PCM",
...@@ -150,7 +138,6 @@ static struct snd_soc_dai_link tegra_alc5632_dai = { ...@@ -150,7 +138,6 @@ static struct snd_soc_dai_link tegra_alc5632_dai = {
static struct snd_soc_card snd_soc_tegra_alc5632 = { static struct snd_soc_card snd_soc_tegra_alc5632 = {
.name = "tegra-alc5632", .name = "tegra-alc5632",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = tegra_alc5632_card_remove,
.dai_link = &tegra_alc5632_dai, .dai_link = &tegra_alc5632_dai,
.num_links = 1, .num_links = 1,
.controls = tegra_alc5632_controls, .controls = tegra_alc5632_controls,
......
...@@ -176,23 +176,6 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -176,23 +176,6 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int tegra_max98090_card_remove(struct snd_soc_card *card)
{
struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card);
if (gpio_is_valid(machine->gpio_hp_det)) {
snd_soc_jack_free_gpios(&tegra_max98090_hp_jack, 1,
&tegra_max98090_hp_jack_gpio);
}
if (gpio_is_valid(machine->gpio_mic_det)) {
snd_soc_jack_free_gpios(&tegra_max98090_mic_jack, 1,
&tegra_max98090_mic_jack_gpio);
}
return 0;
}
static struct snd_soc_dai_link tegra_max98090_dai = { static struct snd_soc_dai_link tegra_max98090_dai = {
.name = "max98090", .name = "max98090",
.stream_name = "max98090 PCM", .stream_name = "max98090 PCM",
...@@ -206,7 +189,6 @@ static struct snd_soc_dai_link tegra_max98090_dai = { ...@@ -206,7 +189,6 @@ static struct snd_soc_dai_link tegra_max98090_dai = {
static struct snd_soc_card snd_soc_tegra_max98090 = { static struct snd_soc_card snd_soc_tegra_max98090 = {
.name = "tegra-max98090", .name = "tegra-max98090",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = tegra_max98090_card_remove,
.dai_link = &tegra_max98090_dai, .dai_link = &tegra_max98090_dai,
.num_links = 1, .num_links = 1,
.controls = tegra_max98090_controls, .controls = tegra_max98090_controls,
......
...@@ -126,18 +126,6 @@ static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -126,18 +126,6 @@ static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int tegra_rt5640_card_remove(struct snd_soc_card *card)
{
struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card);
if (gpio_is_valid(machine->gpio_hp_det)) {
snd_soc_jack_free_gpios(&tegra_rt5640_hp_jack, 1,
&tegra_rt5640_hp_jack_gpio);
}
return 0;
}
static struct snd_soc_dai_link tegra_rt5640_dai = { static struct snd_soc_dai_link tegra_rt5640_dai = {
.name = "RT5640", .name = "RT5640",
.stream_name = "RT5640 PCM", .stream_name = "RT5640 PCM",
...@@ -151,7 +139,6 @@ static struct snd_soc_dai_link tegra_rt5640_dai = { ...@@ -151,7 +139,6 @@ static struct snd_soc_dai_link tegra_rt5640_dai = {
static struct snd_soc_card snd_soc_tegra_rt5640 = { static struct snd_soc_card snd_soc_tegra_rt5640 = {
.name = "tegra-rt5640", .name = "tegra-rt5640",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = tegra_rt5640_card_remove,
.dai_link = &tegra_rt5640_dai, .dai_link = &tegra_rt5640_dai,
.num_links = 1, .num_links = 1,
.controls = tegra_rt5640_controls, .controls = tegra_rt5640_controls,
......
...@@ -169,23 +169,6 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd) ...@@ -169,23 +169,6 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd)
return 0; return 0;
} }
static int tegra_rt5677_card_remove(struct snd_soc_card *card)
{
struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(card);
if (gpio_is_valid(machine->gpio_hp_det)) {
snd_soc_jack_free_gpios(&tegra_rt5677_hp_jack, 1,
&tegra_rt5677_hp_jack_gpio);
}
if (gpio_is_valid(machine->gpio_mic_present)) {
snd_soc_jack_free_gpios(&tegra_rt5677_mic_jack, 1,
&tegra_rt5677_mic_jack_gpio);
}
return 0;
}
static struct snd_soc_dai_link tegra_rt5677_dai = { static struct snd_soc_dai_link tegra_rt5677_dai = {
.name = "RT5677", .name = "RT5677",
.stream_name = "RT5677 PCM", .stream_name = "RT5677 PCM",
...@@ -199,7 +182,6 @@ static struct snd_soc_dai_link tegra_rt5677_dai = { ...@@ -199,7 +182,6 @@ static struct snd_soc_dai_link tegra_rt5677_dai = {
static struct snd_soc_card snd_soc_tegra_rt5677 = { static struct snd_soc_card snd_soc_tegra_rt5677 = {
.name = "tegra-rt5677", .name = "tegra-rt5677",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.remove = tegra_rt5677_card_remove,
.dai_link = &tegra_rt5677_dai, .dai_link = &tegra_rt5677_dai,
.num_links = 1, .num_links = 1,
.controls = tegra_rt5677_controls, .controls = tegra_rt5677_controls,
......
...@@ -203,12 +203,6 @@ static int tegra_wm8903_remove(struct snd_soc_card *card) ...@@ -203,12 +203,6 @@ static int tegra_wm8903_remove(struct snd_soc_card *card)
snd_soc_get_pcm_runtime(card, card->dai_link[0].name); snd_soc_get_pcm_runtime(card, card->dai_link[0].name);
struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_codec *codec = codec_dai->codec; struct snd_soc_codec *codec = codec_dai->codec;
struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card);
if (gpio_is_valid(machine->gpio_hp_det)) {
snd_soc_jack_free_gpios(&tegra_wm8903_hp_jack, 1,
&tegra_wm8903_hp_jack_gpio);
}
wm8903_mic_detect(codec, NULL, 0, 0); wm8903_mic_detect(codec, NULL, 0, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment