From: Mark Brown Date: Wed, 3 Aug 2011 08:30:57 +0000 (+0900) Subject: ASoC: Add SPI support for WM8741 X-Git-Tag: MMI-PSA29.97-13-9~16612^2~952 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=39e9b8d25d1c3a11e41e0044e010034a883f02ef;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git ASoC: Add SPI support for WM8741 Signed-off-by: Mark Brown Acked-by: Liam Girdwood --- diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c index 00f80f7655cb..9f6e952da8ec 100644 --- a/sound/soc/codecs/wm8741.c +++ b/sound/soc/codecs/wm8741.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -547,6 +548,43 @@ static struct i2c_driver wm8741_i2c_driver = { }; #endif +#if defined(CONFIG_SPI_MASTER) +static int __devinit wm8741_spi_probe(struct spi_device *spi) +{ + struct wm8741_priv *wm8741; + int ret; + + wm8741 = kzalloc(sizeof(struct wm8741_priv), GFP_KERNEL); + if (wm8741 == NULL) + return -ENOMEM; + + wm8741->control_type = SND_SOC_SPI; + spi_set_drvdata(spi, wm8741); + + ret = snd_soc_register_codec(&spi->dev, + &soc_codec_dev_wm8741, &wm8741_dai, 1); + if (ret < 0) + kfree(wm8741); + return ret; +} + +static int __devexit wm8741_spi_remove(struct spi_device *spi) +{ + snd_soc_unregister_codec(&spi->dev); + kfree(spi_get_drvdata(spi)); + return 0; +} + +static struct spi_driver wm8741_spi_driver = { + .driver = { + .name = "wm8741", + .owner = THIS_MODULE, + }, + .probe = wm8741_spi_probe, + .remove = __devexit_p(wm8741_spi_remove), +}; +#endif /* CONFIG_SPI_MASTER */ + static int __init wm8741_modinit(void) { int ret = 0; @@ -556,6 +594,13 @@ static int __init wm8741_modinit(void) if (ret != 0) pr_err("Failed to register WM8741 I2C driver: %d\n", ret); #endif +#if defined(CONFIG_SPI_MASTER) + ret = spi_register_driver(&wm8741_spi_driver); + if (ret != 0) { + printk(KERN_ERR "Failed to register wm8741 SPI driver: %d\n", + ret); + } +#endif return ret; } @@ -563,6 +608,9 @@ module_init(wm8741_modinit); static void __exit wm8741_exit(void) { +#if defined(CONFIG_SPI_MASTER) + spi_unregister_driver(&wm8741_spi_driver); +#endif #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) i2c_del_driver(&wm8741_i2c_driver); #endif