From 9e30d7718bb7402c7bdee631ad2aae2658c324f0 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 11 Feb 2009 08:28:04 +0100 Subject: ASoC: Fix forgotten replacements of socdev->codec The snd_soc_codec was moved into socdev->card, but this change wasn't applied in some places. Fixed now. Signed-off-by: Takashi Iwai --- sound/soc/pxa/poodle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc/pxa/poodle.c') diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index 6e9827189fff..3a62d4354ef6 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -77,7 +77,7 @@ static void poodle_ext_control(struct snd_soc_codec *codec) static int poodle_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->socdev->codec; + struct snd_soc_codec *codec = rtd->socdev->card->codec; /* check the jack status at stream startup */ poodle_ext_control(codec); -- cgit v1.2.3 From 5998102b9095fdb7c67755812038612afea315c5 Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Mon, 16 Feb 2009 20:49:16 +0000 Subject: ASoC: Refactor WM8731 device registration Move the WM8731 driver to use a more standard device registration scheme where the device can be registered independantly of the ASoC probe. As a transition measure push the current manual code for registering the WM8731 into the individual machine driver probes. This allows separate patches to update the relevant architecture files with less risk of merge issues. Signed-off-by: Mark Brown --- sound/soc/atmel/sam9g20_wm8731.c | 43 ++++- sound/soc/codecs/wm8731.c | 334 +++++++++++++++++---------------------- sound/soc/codecs/wm8731.h | 6 - sound/soc/pxa/corgi.c | 43 ++++- sound/soc/pxa/poodle.c | 41 ++++- 5 files changed, 256 insertions(+), 211 deletions(-) (limited to 'sound/soc/pxa/poodle.c') diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index aa524235fd98..173a239a541c 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -280,15 +281,41 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = { .set_bias_level = at91sam9g20ek_set_bias_level, }; -static struct wm8731_setup_data at91sam9g20ek_wm8731_setup = { - .i2c_bus = 0, - .i2c_address = 0x1b, -}; +/* + * FIXME: This is a temporary bodge to avoid cross-tree merge issues. + * New drivers should register the wm8731 I2C device in the machine + * setup code (under arch/arm for ARM systems). + */ +static int wm8731_i2c_register(void) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = 0x1b; + strlcpy(info.type, "wm8731", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(0); + if (!adapter) { + printk(KERN_ERR "can't get i2c adapter 0\n"); + return -ENODEV; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + printk(KERN_ERR "can't add i2c device at 0x%x\n", + (unsigned int)info.addr); + return -ENODEV; + } + + return 0; +} static struct snd_soc_device at91sam9g20ek_snd_devdata = { .card = &snd_soc_at91sam9g20ek, .codec_dev = &soc_codec_dev_wm8731, - .codec_data = &at91sam9g20ek_wm8731_setup, }; static struct platform_device *at91sam9g20ek_snd_device; @@ -340,6 +367,10 @@ static int __init at91sam9g20ek_init(void) } ssc_p->ssc = ssc; + ret = wm8731_i2c_register(); + if (ret != 0) + goto err_ssc; + at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); if (!at91sam9g20ek_snd_device) { printk(KERN_ERR "ASoC: Platform device allocation failed\n"); @@ -359,6 +390,8 @@ static int __init at91sam9g20ek_init(void) return ret; err_ssc: + ssc_free(ssc); + ssc_p->ssc = NULL; err_mclk: clk_put(mclk); mclk = NULL; diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 3ff971aeba21..a2c478e53d54 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -29,16 +29,18 @@ #include "wm8731.h" +static struct snd_soc_codec *wm8731_codec; struct snd_soc_codec_device soc_codec_dev_wm8731; /* codec private data */ struct wm8731_priv { + struct snd_soc_codec codec; + u16 reg_cache[WM8731_CACHEREGNUM]; unsigned int sysclk; }; #ifdef CONFIG_SPI_MASTER static int wm8731_spi_write(struct spi_device *spi, const char *data, int len); -static struct spi_driver wm8731_spi_driver; #endif /* @@ -485,55 +487,33 @@ static int wm8731_resume(struct platform_device *pdev) return 0; } -/* - * initialise the WM8731 driver - * register the mixer and dsp interfaces with the kernel - */ -static int wm8731_init(struct snd_soc_device *socdev) +static int wm8731_probe(struct platform_device *pdev) { - struct snd_soc_codec *codec = socdev->card->codec; - int reg, ret = 0; + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + int ret = 0; - codec->name = "WM8731"; - codec->owner = THIS_MODULE; - codec->read = wm8731_read_reg_cache; - codec->write = wm8731_write; - codec->set_bias_level = wm8731_set_bias_level; - codec->dai = &wm8731_dai; - codec->num_dai = 1; - codec->reg_cache_size = ARRAY_SIZE(wm8731_reg); - codec->reg_cache = kmemdup(wm8731_reg, sizeof(wm8731_reg), GFP_KERNEL); - if (codec->reg_cache == NULL) - return -ENOMEM; + if (wm8731_codec == NULL) { + dev_err(&pdev->dev, "Codec device not registered\n"); + return -ENODEV; + } - wm8731_reset(codec); + socdev->card->codec = wm8731_codec; + codec = wm8731_codec; /* register pcms */ ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); if (ret < 0) { - printk(KERN_ERR "wm8731: failed to create pcms\n"); + dev_err(codec->dev, "failed to create pcms: %d\n", ret); goto pcm_err; } - /* power on device */ - wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); - - /* set the update bits */ - reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V); - wm8731_write(codec, WM8731_LOUT1V, reg & ~0x0100); - reg = wm8731_read_reg_cache(codec, WM8731_ROUT1V); - wm8731_write(codec, WM8731_ROUT1V, reg & ~0x0100); - reg = wm8731_read_reg_cache(codec, WM8731_LINVOL); - wm8731_write(codec, WM8731_LINVOL, reg & ~0x0100); - reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); - wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); - snd_soc_add_controls(codec, wm8731_snd_controls, - ARRAY_SIZE(wm8731_snd_controls)); + ARRAY_SIZE(wm8731_snd_controls)); wm8731_add_widgets(codec); ret = snd_soc_init_card(socdev); if (ret < 0) { - printk(KERN_ERR "wm8731: failed to register card\n"); + dev_err(codec->dev, "failed to register card: %d\n", ret); goto card_err; } @@ -543,104 +523,6 @@ card_err: snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); pcm_err: - kfree(codec->reg_cache); - return ret; -} - -static struct snd_soc_device *wm8731_socdev; - - -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) -static struct i2c_driver wm8731_i2c_driver; - -static int wm8731_add_i2c_device(struct platform_device *pdev, - const struct wm8731_setup_data *setup) -{ - struct i2c_board_info info; - struct i2c_adapter *adapter; - struct i2c_client *client; - int ret; - - ret = i2c_add_driver(&wm8731_i2c_driver); - if (ret != 0) { - dev_err(&pdev->dev, "can't add i2c driver\n"); - return ret; - } - - memset(&info, 0, sizeof(struct i2c_board_info)); - info.addr = setup->i2c_address; - strlcpy(info.type, "wm8731", I2C_NAME_SIZE); - - adapter = i2c_get_adapter(setup->i2c_bus); - if (!adapter) { - dev_err(&pdev->dev, "can't get i2c adapter %d\n", - setup->i2c_bus); - goto err_driver; - } - - client = i2c_new_device(adapter, &info); - i2c_put_adapter(adapter); - if (!client) { - dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", - (unsigned int)info.addr); - goto err_driver; - } - - return 0; - -err_driver: - i2c_del_driver(&wm8731_i2c_driver); - return -ENODEV; -} -#endif - -static int wm8731_probe(struct platform_device *pdev) -{ - struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct wm8731_setup_data *setup; - struct snd_soc_codec *codec; - struct wm8731_priv *wm8731; - int ret = 0; - - setup = socdev->codec_data; - codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); - if (codec == NULL) - return -ENOMEM; - - wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); - if (wm8731 == NULL) { - kfree(codec); - return -ENOMEM; - } - - codec->private_data = wm8731; - socdev->card->codec = codec; - mutex_init(&codec->mutex); - INIT_LIST_HEAD(&codec->dapm_widgets); - INIT_LIST_HEAD(&codec->dapm_paths); - - wm8731_socdev = socdev; - ret = -ENODEV; - -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - if (setup->i2c_address) { - codec->hw_write = (hw_write_t)i2c_master_send; - ret = wm8731_add_i2c_device(pdev, setup); - } -#endif -#if defined(CONFIG_SPI_MASTER) - if (setup->spi) { - codec->hw_write = (hw_write_t)wm8731_spi_write; - ret = spi_register_driver(&wm8731_spi_driver); - if (ret != 0) - printk(KERN_ERR "can't add spi driver"); - } -#endif - - if (ret != 0) { - kfree(codec->private_data); - kfree(codec); - } return ret; } @@ -648,22 +530,9 @@ static int wm8731_probe(struct platform_device *pdev) static int wm8731_remove(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); - struct snd_soc_codec *codec = socdev->card->codec; - - if (codec->control_data) - wm8731_set_bias_level(codec, SND_SOC_BIAS_OFF); snd_soc_free_pcms(socdev); snd_soc_dapm_free(socdev); -#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) - i2c_unregister_device(codec->control_data); - i2c_del_driver(&wm8731_i2c_driver); -#endif -#if defined(CONFIG_SPI_MASTER) - spi_unregister_driver(&wm8731_spi_driver); -#endif - kfree(codec->private_data); - kfree(codec); return 0; } @@ -676,37 +545,78 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = { }; EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); -#if defined(CONFIG_SPI_MASTER) -static int __devinit wm8731_spi_probe(struct spi_device *spi) +static int wm8731_register(struct wm8731_priv *wm8731) { - struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->card->codec; int ret; + struct snd_soc_codec *codec = &wm8731->codec; + u16 reg; - codec->control_data = spi; + if (wm8731_codec) { + dev_err(codec->dev, "Another WM8731 is registered\n"); + return -EINVAL; + } - ret = wm8731_init(socdev); - if (ret < 0) - dev_err(&spi->dev, "failed to initialise WM8731\n"); + mutex_init(&codec->mutex); + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); - return ret; -} + codec->private_data = wm8731; + codec->name = "WM8731"; + codec->owner = THIS_MODULE; + codec->read = wm8731_read_reg_cache; + codec->write = wm8731_write; + codec->bias_level = SND_SOC_BIAS_OFF; + codec->set_bias_level = wm8731_set_bias_level; + codec->dai = &wm8731_dai; + codec->num_dai = 1; + codec->reg_cache_size = WM8731_CACHEREGNUM; + codec->reg_cache = &wm8731->reg_cache; + + memcpy(codec->reg_cache, wm8731_reg, sizeof(wm8731_reg)); + + wm8731_dai.dev = codec->dev; + + wm8731_reset(codec); + wm8731_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + + /* Latch the update bits */ + reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V); + wm8731_write(codec, WM8731_LOUT1V, reg & ~0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_ROUT1V); + wm8731_write(codec, WM8731_ROUT1V, reg & ~0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_LINVOL); + wm8731_write(codec, WM8731_LINVOL, reg & ~0x0100); + reg = wm8731_read_reg_cache(codec, WM8731_RINVOL); + wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100); + + wm8731_codec = codec; + + ret = snd_soc_register_codec(codec); + if (ret != 0) { + dev_err(codec->dev, "Failed to register codec: %d\n", ret); + return ret; + } + + ret = snd_soc_register_dai(&wm8731_dai); + if (ret != 0) { + dev_err(codec->dev, "Failed to register DAI: %d\n", ret); + snd_soc_unregister_codec(codec); + return ret; + } -static int __devexit wm8731_spi_remove(struct spi_device *spi) -{ return 0; } -static struct spi_driver wm8731_spi_driver = { - .driver = { - .name = "wm8731", - .bus = &spi_bus_type, - .owner = THIS_MODULE, - }, - .probe = wm8731_spi_probe, - .remove = __devexit_p(wm8731_spi_remove), -}; +static void wm8731_unregister(struct wm8731_priv *wm8731) +{ + wm8731_set_bias_level(&wm8731->codec, SND_SOC_BIAS_OFF); + snd_soc_unregister_dai(&wm8731_dai); + snd_soc_unregister_codec(&wm8731->codec); + kfree(wm8731); + wm8731_codec = NULL; +} +#if defined(CONFIG_SPI_MASTER) static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) { struct spi_transfer t; @@ -730,37 +640,67 @@ static int wm8731_spi_write(struct spi_device *spi, const char *data, int len) return len; } + +static int __devinit wm8731_spi_probe(struct spi_device *spi) +{ + struct snd_soc_codec *codec; + struct wm8731_priv *wm8731; + + wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); + if (wm8731 == NULL) + return -ENOMEM; + + codec = &wm8731->codec; + codec->control_data = spi; + codec->hw_write = (hw_write_t)wm8731_spi_write; + codec->dev = &spi->dev; + + return wm8731_register(wm8731); +} + +static int __devexit wm8731_spi_remove(struct spi_device *spi) +{ + /* FIXME: This isn't actually implemented... */ + return 0; +} + +static struct spi_driver wm8731_spi_driver = { + .driver = { + .name = "wm8731", + .bus = &spi_bus_type, + .owner = THIS_MODULE, + }, + .probe = wm8731_spi_probe, + .remove = __devexit_p(wm8731_spi_remove), +}; #endif /* CONFIG_SPI_MASTER */ #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) -/* - * WM8731 2 wire address is determined by GPIO5 - * state during powerup. - * low = 0x1a - * high = 0x1b - */ - static int wm8731_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct snd_soc_device *socdev = wm8731_socdev; - struct snd_soc_codec *codec = socdev->card->codec; - int ret; + struct wm8731_priv *wm8731; + struct snd_soc_codec *codec; - i2c_set_clientdata(i2c, codec); + wm8731 = kzalloc(sizeof(struct wm8731_priv), GFP_KERNEL); + if (wm8731 == NULL) + return -ENOMEM; + + codec = &wm8731->codec; + codec->hw_write = (hw_write_t)i2c_master_send; + + i2c_set_clientdata(i2c, wm8731); codec->control_data = i2c; - ret = wm8731_init(socdev); - if (ret < 0) - pr_err("failed to initialise WM8731\n"); + codec->dev = &i2c->dev; - return ret; + return wm8731_register(wm8731); } static int wm8731_i2c_remove(struct i2c_client *client) { - struct snd_soc_codec *codec = i2c_get_clientdata(client); - kfree(codec->reg_cache); + struct wm8731_priv *wm8731 = i2c_get_clientdata(client); + wm8731_unregister(wm8731); return 0; } @@ -783,13 +723,33 @@ static struct i2c_driver wm8731_i2c_driver = { static int __init wm8731_modinit(void) { - return snd_soc_register_dai(&wm8731_dai); + int ret; +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + ret = i2c_add_driver(&wm8731_i2c_driver); + if (ret != 0) { + printk(KERN_ERR "Failed to register WM8731 I2C driver: %d\n", + ret); + } +#endif +#if defined(CONFIG_SPI_MASTER) + ret = spi_register_driver(&wm8731_spi_driver); + if (ret != 0) { + printk(KERN_ERR "Failed to register WM8731 SPI driver: %d\n", + ret); + } +#endif + return 0; } module_init(wm8731_modinit); static void __exit wm8731_exit(void) { - snd_soc_unregister_dai(&wm8731_dai); +#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) + i2c_del_driver(&wm8731_i2c_driver); +#endif +#if defined(CONFIG_SPI_MASTER) + spi_unregister_driver(&wm8731_spi_driver); +#endif } module_exit(wm8731_exit); diff --git a/sound/soc/codecs/wm8731.h b/sound/soc/codecs/wm8731.h index 95190e9c0c14..cd7b806e8ad0 100644 --- a/sound/soc/codecs/wm8731.h +++ b/sound/soc/codecs/wm8731.h @@ -34,12 +34,6 @@ #define WM8731_SYSCLK 0 #define WM8731_DAI 0 -struct wm8731_setup_data { - int spi; - int i2c_bus; - unsigned short i2c_address; -}; - extern struct snd_soc_dai wm8731_dai; extern struct snd_soc_codec_device soc_codec_dev_wm8731; diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index 0d41be33d572..eaa66915a324 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -317,19 +317,44 @@ static struct snd_soc_card snd_soc_corgi = { .num_links = 1, }; -/* corgi audio private data */ -static struct wm8731_setup_data corgi_wm8731_setup = { - .i2c_bus = 0, - .i2c_address = 0x1b, -}; - /* corgi audio subsystem */ static struct snd_soc_device corgi_snd_devdata = { .card = &snd_soc_corgi, .codec_dev = &soc_codec_dev_wm8731, - .codec_data = &corgi_wm8731_setup, }; +/* + * FIXME: This is a temporary bodge to avoid cross-tree merge issues. + * New drivers should register the wm8731 I2C device in the machine + * setup code (under arch/arm for ARM systems). + */ +static int wm8731_i2c_register(void) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = 0x1b; + strlcpy(info.type, "wm8731", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(0); + if (!adapter) { + printk(KERN_ERR "can't get i2c adapter 0\n"); + return -ENODEV; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + printk(KERN_ERR "can't add i2c device at 0x%x\n", + (unsigned int)info.addr); + return -ENODEV; + } + + return 0; +} + static struct platform_device *corgi_snd_device; static int __init corgi_init(void) @@ -340,6 +365,10 @@ static int __init corgi_init(void) machine_is_husky())) return -ENODEV; + ret = wm8731_i2c_setup(); + if (ret != 0) + return ret; + corgi_snd_device = platform_device_alloc("soc-audio", -1); if (!corgi_snd_device) return -ENOMEM; diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index 3a62d4354ef6..fd683a0b742d 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -283,17 +283,42 @@ static struct snd_soc_card snd_soc_poodle = { .num_links = 1, }; -/* poodle audio private data */ -static struct wm8731_setup_data poodle_wm8731_setup = { - .i2c_bus = 0, - .i2c_address = 0x1b, -}; +/* + * FIXME: This is a temporary bodge to avoid cross-tree merge issues. + * New drivers should register the wm8731 I2C device in the machine + * setup code (under arch/arm for ARM systems). + */ +static int wm8731_i2c_register(void) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = 0x1b; + strlcpy(info.type, "wm8731", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(0); + if (!adapter) { + printk(KERN_ERR "can't get i2c adapter 0\n"); + return -ENODEV; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + printk(KERN_ERR "can't add i2c device at 0x%x\n", + (unsigned int)info.addr); + return -ENODEV; + } + + return 0; +} /* poodle audio subsystem */ static struct snd_soc_device poodle_snd_devdata = { .card = &snd_soc_poodle, .codec_dev = &soc_codec_dev_wm8731, - .codec_data = &poodle_wm8731_setup, }; static struct platform_device *poodle_snd_device; @@ -305,6 +330,10 @@ static int __init poodle_init(void) if (!machine_is_poodle()) return -ENODEV; + ret = wm8731_i2c_setup(); + if (ret != 0) + return ret; + locomo_gpio_set_dir(&poodle_locomo_device.dev, POODLE_LOCOMO_GPIO_AMP_ON, 0); /* should we mute HP at startup - burning power ?*/ -- cgit v1.2.3 From fc9967576829a01c98e5388410dc12c61006f79f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Wed, 18 Feb 2009 12:34:53 +0000 Subject: ASoC: Fix build for corgi and poodle Signed-off-by: Mark Brown --- sound/soc/pxa/corgi.c | 3 ++- sound/soc/pxa/poodle.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'sound/soc/pxa/poodle.c') diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index eaa66915a324..146973ae0974 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -365,7 +366,7 @@ static int __init corgi_init(void) machine_is_husky())) return -ENODEV; - ret = wm8731_i2c_setup(); + ret = wm8731_i2c_register(); if (ret != 0) return ret; diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index fd683a0b742d..fb17a0a5a093 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -330,7 +331,7 @@ static int __init poodle_init(void) if (!machine_is_poodle()) return -ENODEV; - ret = wm8731_i2c_setup(); + ret = wm8731_i2c_register(); if (ret != 0) return ret; -- cgit v1.2.3 From eb5f6d753e337834c7ceb07824ee472e43d9a7a2 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 12 Mar 2009 11:07:54 +0100 Subject: ASoC: Replace remaining uses of snd_soc_cnew with snd_soc_add_controls. The drivers are basically duplicating the same code over and over. As snd_soc_cnew is going to be made static some time after the next merge window, we might as well convert them now. Signed-off-by: Philipp Zabel Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 23 +++++------------------ sound/soc/codecs/tlv320aic26.c | 11 ++++------- sound/soc/codecs/wm8400.c | 12 ++---------- sound/soc/omap/n810.c | 12 +++++------- sound/soc/pxa/corgi.c | 12 +++++------- sound/soc/pxa/palm27x.c | 13 +++++-------- sound/soc/pxa/poodle.c | 12 +++++------- sound/soc/pxa/spitz.c | 12 +++++------- sound/soc/pxa/tosa.c | 12 +++++------- sound/soc/s3c24xx/neo1973_wm8753.c | 13 +++++-------- 10 files changed, 46 insertions(+), 86 deletions(-) (limited to 'sound/soc/pxa/poodle.c') diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 2137670c9b78..7fa09a387622 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -540,7 +540,6 @@ static int cs4270_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec = cs4270_codec; - unsigned int i; int ret; /* Connect the codec to the socdev. snd_soc_new_pcms() needs this. */ @@ -554,23 +553,11 @@ static int cs4270_probe(struct platform_device *pdev) } /* Add the non-DAPM controls */ - for (i = 0; i < ARRAY_SIZE(cs4270_snd_controls); i++) { - struct snd_kcontrol *kctrl; - - kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); - if (!kctrl) { - dev_err(codec->dev, "error creating control '%s'\n", - cs4270_snd_controls[i].name); - ret = -ENOMEM; - goto error_free_pcms; - } - - ret = snd_ctl_add(codec->card, kctrl); - if (ret < 0) { - dev_err(codec->dev, "error adding control '%s'\n", - cs4270_snd_controls[i].name); - goto error_free_pcms; - } + ret = snd_soc_add_controls(codec, cs4270_snd_controls, + ARRAY_SIZE(cs4270_snd_controls)); + if (ret < 0) { + dev_err(codec->dev, "failed to add controls\n"); + goto error_free_pcms; } /* And finally, register the socdev */ diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index a7f333fc579e..3387d9e736ea 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -324,9 +324,8 @@ static int aic26_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); struct snd_soc_codec *codec; - struct snd_kcontrol *kcontrol; struct aic26 *aic26; - int i, ret, err; + int ret, err; dev_info(&pdev->dev, "Probing AIC26 SoC CODEC driver\n"); dev_dbg(&pdev->dev, "socdev=%p\n", socdev); @@ -353,11 +352,9 @@ static int aic26_probe(struct platform_device *pdev) /* register controls */ dev_dbg(&pdev->dev, "Registering controls\n"); - for (i = 0; i < ARRAY_SIZE(aic26_snd_controls); i++) { - kcontrol = snd_soc_cnew(&aic26_snd_controls[i], codec, NULL); - err = snd_ctl_add(codec->card, kcontrol); - WARN_ON(err < 0); - } + err = snd_soc_add_controls(codec, aic26_snd_controls, + ARRAY_SIZE(aic26_snd_controls)); + WARN_ON(err < 0); /* CODEC is setup, we can register the card now */ dev_dbg(&pdev->dev, "Registering card\n"); diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 4e1cefff8483..744e0dc73be4 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -351,16 +351,8 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, /* add non dapm controls */ static int wm8400_add_controls(struct snd_soc_codec *codec) { - int err, i; - - for (i = 0; i < ARRAY_SIZE(wm8400_snd_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8400_snd_controls[i],codec, - NULL)); - if (err < 0) - return err; - } - return 0; + return snd_soc_add_controls(codec, wm8400_snd_controls, + ARRAY_SIZE(wm8400_snd_controls)); } /* diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c index 9f037cd0191d..86471fd6340f 100644 --- a/sound/soc/omap/n810.c +++ b/sound/soc/omap/n810.c @@ -248,7 +248,7 @@ static const struct snd_kcontrol_new aic33_n810_controls[] = { static int n810_aic33_init(struct snd_soc_codec *codec) { - int i, err; + int err; /* Not connected */ snd_soc_dapm_nc_pin(codec, "MONO_LOUT"); @@ -256,12 +256,10 @@ static int n810_aic33_init(struct snd_soc_codec *codec) snd_soc_dapm_nc_pin(codec, "HPRCOM"); /* Add N810 specific controls */ - for (i = 0; i < ARRAY_SIZE(aic33_n810_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&aic33_n810_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, aic33_n810_controls, + ARRAY_SIZE(aic33_n810_controls)); + if (err < 0) + return err; /* Add N810 specific widgets */ snd_soc_dapm_new_controls(codec, aic33_dapm_widgets, diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index 146973ae0974..02263e5d8f03 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c @@ -276,18 +276,16 @@ static const struct snd_kcontrol_new wm8731_corgi_controls[] = { */ static int corgi_wm8731_init(struct snd_soc_codec *codec) { - int i, err; + int err; snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN"); /* Add corgi specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8731_corgi_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8731_corgi_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8731_corgi_controls, + ARRAY_SIZE(wm8731_corgi_controls)); + if (err < 0) + return err; /* Add corgi specific widgets */ snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index 29958cd9daec..48a73f64500b 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c @@ -146,19 +146,16 @@ static const struct snd_kcontrol_new palm27x_controls[] = { static int palm27x_ac97_init(struct snd_soc_codec *codec) { - int i, err; + int err; snd_soc_dapm_nc_pin(codec, "OUT3"); snd_soc_dapm_nc_pin(codec, "MONOOUT"); /* add palm27x specific controls */ - for (i = 0; i < ARRAY_SIZE(palm27x_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&palm27x_controls[i], - codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, palm27x_controls, + ARRAY_SIZE(palm27x_controls)); + if (err < 0) + return err; /* add palm27x specific widgets */ snd_soc_dapm_new_controls(codec, palm27x_dapm_widgets, diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index fb17a0a5a093..ef7c6c8dc8f1 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c @@ -241,19 +241,17 @@ static const struct snd_kcontrol_new wm8731_poodle_controls[] = { */ static int poodle_wm8731_init(struct snd_soc_codec *codec) { - int i, err; + int err; snd_soc_dapm_nc_pin(codec, "LLINEIN"); snd_soc_dapm_nc_pin(codec, "RLINEIN"); snd_soc_dapm_enable_pin(codec, "MICIN"); /* Add poodle specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8731_poodle_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8731_poodle_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8731_poodle_controls, + ARRAY_SIZE(wm8731_poodle_controls)); + if (err < 0) + return err; /* Add poodle specific widgets */ snd_soc_dapm_new_controls(codec, wm8731_dapm_widgets, diff --git a/sound/soc/pxa/spitz.c b/sound/soc/pxa/spitz.c index 1aafd8c645a1..6ca9f53080c6 100644 --- a/sound/soc/pxa/spitz.c +++ b/sound/soc/pxa/spitz.c @@ -278,7 +278,7 @@ static const struct snd_kcontrol_new wm8750_spitz_controls[] = { */ static int spitz_wm8750_init(struct snd_soc_codec *codec) { - int i, err; + int err; /* NC codec pins */ snd_soc_dapm_nc_pin(codec, "RINPUT1"); @@ -290,12 +290,10 @@ static int spitz_wm8750_init(struct snd_soc_codec *codec) snd_soc_dapm_nc_pin(codec, "MONO1"); /* Add spitz specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8750_spitz_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8750_spitz_controls[i], codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8750_spitz_controls, + ARRAY_SIZE(wm8750_spitz_controls)); + if (err < 0) + return err; /* Add spitz specific widgets */ snd_soc_dapm_new_controls(codec, wm8750_dapm_widgets, diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c index 09b5bada03b9..fc781374b1bf 100644 --- a/sound/soc/pxa/tosa.c +++ b/sound/soc/pxa/tosa.c @@ -188,18 +188,16 @@ static const struct snd_kcontrol_new tosa_controls[] = { static int tosa_ac97_init(struct snd_soc_codec *codec) { - int i, err; + int err; snd_soc_dapm_nc_pin(codec, "OUT3"); snd_soc_dapm_nc_pin(codec, "MONOOUT"); /* add tosa specific controls */ - for (i = 0; i < ARRAY_SIZE(tosa_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&tosa_controls[i],codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, tosa_controls, + ARRAY_SIZE(tosa_controls)); + if (err < 0) + return err; /* add tosa specific widgets */ snd_soc_dapm_new_controls(codec, tosa_dapm_widgets, diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 5f6aeec0437d..289fadf60b10 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c @@ -498,7 +498,7 @@ static const struct snd_kcontrol_new wm8753_neo1973_controls[] = { */ static int neo1973_wm8753_init(struct snd_soc_codec *codec) { - int i, err; + int err; pr_debug("Entered %s\n", __func__); @@ -518,13 +518,10 @@ static int neo1973_wm8753_init(struct snd_soc_codec *codec) set_scenario_endpoints(codec, NEO_AUDIO_OFF); /* add neo1973 specific controls */ - for (i = 0; i < ARRAY_SIZE(wm8753_neo1973_controls); i++) { - err = snd_ctl_add(codec->card, - snd_soc_cnew(&wm8753_neo1973_controls[i], - codec, NULL)); - if (err < 0) - return err; - } + err = snd_soc_add_controls(codec, wm8753_neo1973_controls, + ARRAY_SIZE(8753_neo1973_controls)); + if (err < 0) + return err; /* set up neo1973 specific audio routes */ err = snd_soc_dapm_add_routes(codec, dapm_routes, -- cgit v1.2.3