aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8731.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-02-16 14:35:43 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-02-18 06:25:48 -0500
commita8035c8f04477895207b92915b908344749be336 (patch)
treed85620b978b2ffff54b8ed6b5bc25c7cfba9c14d /sound/soc/codecs/wm8731.c
parent7ee753804185eb0a46ac964fd6a6564bd67290c9 (diff)
ASoC: Shuffle WM8731 SPI and I2C device registration
This is a pure code motion patch intended to improve reviewability of a following patch moving WM8731 to use more standard device registration. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8731.c')
-rw-r--r--sound/soc/codecs/wm8731.c215
1 files changed, 112 insertions, 103 deletions
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c
index c6db67793777..3ff971aeba21 100644
--- a/sound/soc/codecs/wm8731.c
+++ b/sound/soc/codecs/wm8731.c
@@ -36,6 +36,11 @@ struct wm8731_priv {
36 unsigned int sysclk; 36 unsigned int sysclk;
37}; 37};
38 38
39#ifdef CONFIG_SPI_MASTER
40static int wm8731_spi_write(struct spi_device *spi, const char *data, int len);
41static struct spi_driver wm8731_spi_driver;
42#endif
43
39/* 44/*
40 * wm8731 register cache 45 * wm8731 register cache
41 * We can't read the WM8731 register space when we are 46 * We can't read the WM8731 register space when we are
@@ -544,54 +549,9 @@ pcm_err:
544 549
545static struct snd_soc_device *wm8731_socdev; 550static struct snd_soc_device *wm8731_socdev;
546 551
547#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
548
549/*
550 * WM8731 2 wire address is determined by GPIO5
551 * state during powerup.
552 * low = 0x1a
553 * high = 0x1b
554 */
555
556static int wm8731_i2c_probe(struct i2c_client *i2c,
557 const struct i2c_device_id *id)
558{
559 struct snd_soc_device *socdev = wm8731_socdev;
560 struct snd_soc_codec *codec = socdev->card->codec;
561 int ret;
562
563 i2c_set_clientdata(i2c, codec);
564 codec->control_data = i2c;
565
566 ret = wm8731_init(socdev);
567 if (ret < 0)
568 pr_err("failed to initialise WM8731\n");
569
570 return ret;
571}
572 552
573static int wm8731_i2c_remove(struct i2c_client *client) 553#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
574{ 554static struct i2c_driver wm8731_i2c_driver;
575 struct snd_soc_codec *codec = i2c_get_clientdata(client);
576 kfree(codec->reg_cache);
577 return 0;
578}
579
580static const struct i2c_device_id wm8731_i2c_id[] = {
581 { "wm8731", 0 },
582 { }
583};
584MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
585
586static struct i2c_driver wm8731_i2c_driver = {
587 .driver = {
588 .name = "WM8731 I2C Codec",
589 .owner = THIS_MODULE,
590 },
591 .probe = wm8731_i2c_probe,
592 .remove = wm8731_i2c_remove,
593 .id_table = wm8731_i2c_id,
594};
595 555
596static int wm8731_add_i2c_device(struct platform_device *pdev, 556static int wm8731_add_i2c_device(struct platform_device *pdev,
597 const struct wm8731_setup_data *setup) 557 const struct wm8731_setup_data *setup)
@@ -634,62 +594,6 @@ err_driver:
634} 594}
635#endif 595#endif
636 596
637#if defined(CONFIG_SPI_MASTER)
638static int __devinit wm8731_spi_probe(struct spi_device *spi)
639{
640 struct snd_soc_device *socdev = wm8731_socdev;
641 struct snd_soc_codec *codec = socdev->card->codec;
642 int ret;
643
644 codec->control_data = spi;
645
646 ret = wm8731_init(socdev);
647 if (ret < 0)
648 dev_err(&spi->dev, "failed to initialise WM8731\n");
649
650 return ret;
651}
652
653static int __devexit wm8731_spi_remove(struct spi_device *spi)
654{
655 return 0;
656}
657
658static struct spi_driver wm8731_spi_driver = {
659 .driver = {
660 .name = "wm8731",
661 .bus = &spi_bus_type,
662 .owner = THIS_MODULE,
663 },
664 .probe = wm8731_spi_probe,
665 .remove = __devexit_p(wm8731_spi_remove),
666};
667
668static int wm8731_spi_write(struct spi_device *spi, const char *data, int len)
669{
670 struct spi_transfer t;
671 struct spi_message m;
672 u8 msg[2];
673
674 if (len <= 0)
675 return 0;
676
677 msg[0] = data[0];
678 msg[1] = data[1];
679
680 spi_message_init(&m);
681 memset(&t, 0, (sizeof t));
682
683 t.tx_buf = &msg[0];
684 t.len = len;
685
686 spi_message_add_tail(&t, &m);
687 spi_sync(spi, &m);
688
689 return len;
690}
691#endif /* CONFIG_SPI_MASTER */
692
693static int wm8731_probe(struct platform_device *pdev) 597static int wm8731_probe(struct platform_device *pdev)
694{ 598{
695 struct snd_soc_device *socdev = platform_get_drvdata(pdev); 599 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
@@ -772,6 +676,111 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = {
772}; 676};
773EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731); 677EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
774 678
679#if defined(CONFIG_SPI_MASTER)
680static int __devinit wm8731_spi_probe(struct spi_device *spi)
681{
682 struct snd_soc_device *socdev = wm8731_socdev;
683 struct snd_soc_codec *codec = socdev->card->codec;
684 int ret;
685
686 codec->control_data = spi;
687
688 ret = wm8731_init(socdev);
689 if (ret < 0)
690 dev_err(&spi->dev, "failed to initialise WM8731\n");
691
692 return ret;
693}
694
695static int __devexit wm8731_spi_remove(struct spi_device *spi)
696{
697 return 0;
698}
699
700static struct spi_driver wm8731_spi_driver = {
701 .driver = {
702 .name = "wm8731",
703 .bus = &spi_bus_type,
704 .owner = THIS_MODULE,
705 },
706 .probe = wm8731_spi_probe,
707 .remove = __devexit_p(wm8731_spi_remove),
708};
709
710static int wm8731_spi_write(struct spi_device *spi, const char *data, int len)
711{
712 struct spi_transfer t;
713 struct spi_message m;
714 u8 msg[2];
715
716 if (len <= 0)
717 return 0;
718
719 msg[0] = data[0];
720 msg[1] = data[1];
721
722 spi_message_init(&m);
723 memset(&t, 0, (sizeof t));
724
725 t.tx_buf = &msg[0];
726 t.len = len;
727
728 spi_message_add_tail(&t, &m);
729 spi_sync(spi, &m);
730
731 return len;
732}
733#endif /* CONFIG_SPI_MASTER */
734
735#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
736/*
737 * WM8731 2 wire address is determined by GPIO5
738 * state during powerup.
739 * low = 0x1a
740 * high = 0x1b
741 */
742
743static int wm8731_i2c_probe(struct i2c_client *i2c,
744 const struct i2c_device_id *id)
745{
746 struct snd_soc_device *socdev = wm8731_socdev;
747 struct snd_soc_codec *codec = socdev->card->codec;
748 int ret;
749
750 i2c_set_clientdata(i2c, codec);
751 codec->control_data = i2c;
752
753 ret = wm8731_init(socdev);
754 if (ret < 0)
755 pr_err("failed to initialise WM8731\n");
756
757 return ret;
758}
759
760static int wm8731_i2c_remove(struct i2c_client *client)
761{
762 struct snd_soc_codec *codec = i2c_get_clientdata(client);
763 kfree(codec->reg_cache);
764 return 0;
765}
766
767static const struct i2c_device_id wm8731_i2c_id[] = {
768 { "wm8731", 0 },
769 { }
770};
771MODULE_DEVICE_TABLE(i2c, wm8731_i2c_id);
772
773static struct i2c_driver wm8731_i2c_driver = {
774 .driver = {
775 .name = "WM8731 I2C Codec",
776 .owner = THIS_MODULE,
777 },
778 .probe = wm8731_i2c_probe,
779 .remove = wm8731_i2c_remove,
780 .id_table = wm8731_i2c_id,
781};
782#endif
783
775static int __init wm8731_modinit(void) 784static int __init wm8731_modinit(void)
776{ 785{
777 return snd_soc_register_dai(&wm8731_dai); 786 return snd_soc_register_dai(&wm8731_dai);