diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-02-22 09:39:03 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-02-24 18:48:14 -0500 |
commit | 69e169da5a69cc991d54bb4d54f236523145756c (patch) | |
tree | 3aaf59618e0aa27920fb753734d7cc761496ad11 /sound/soc/codecs/wm8753.c | |
parent | d3b894218441ecb1c83e47c682e2d6589ee37a8d (diff) |
ASoC: Shuffle WM8753 device registration code
This patch should be pure code motion, separating that out from the
functional changes to move to new style device registration.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/wm8753.c')
-rw-r--r-- | sound/soc/codecs/wm8753.c | 209 |
1 files changed, 105 insertions, 104 deletions
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 93c22c4f0826..4b426888f98d 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
@@ -51,6 +51,11 @@ | |||
51 | 51 | ||
52 | #include "wm8753.h" | 52 | #include "wm8753.h" |
53 | 53 | ||
54 | #ifdef CONFIG_SPI_MASTER | ||
55 | static struct spi_driver wm8753_spi_driver; | ||
56 | static int wm8753_spi_write(struct spi_device *spi, const char *data, int len); | ||
57 | #endif | ||
58 | |||
54 | static int caps_charge = 2000; | 59 | static int caps_charge = 2000; |
55 | module_param(caps_charge, int, 0); | 60 | module_param(caps_charge, int, 0); |
56 | MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); | 61 | MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); |
@@ -1626,53 +1631,7 @@ pcm_err: | |||
1626 | static struct snd_soc_device *wm8753_socdev; | 1631 | static struct snd_soc_device *wm8753_socdev; |
1627 | 1632 | ||
1628 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 1633 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
1629 | 1634 | static struct i2c_driver wm8753_i2c_driver; | |
1630 | /* | ||
1631 | * WM8753 2 wire address is determined by GPIO5 | ||
1632 | * state during powerup. | ||
1633 | * low = 0x1a | ||
1634 | * high = 0x1b | ||
1635 | */ | ||
1636 | |||
1637 | static int wm8753_i2c_probe(struct i2c_client *i2c, | ||
1638 | const struct i2c_device_id *id) | ||
1639 | { | ||
1640 | struct snd_soc_device *socdev = wm8753_socdev; | ||
1641 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1642 | int ret; | ||
1643 | |||
1644 | i2c_set_clientdata(i2c, codec); | ||
1645 | codec->control_data = i2c; | ||
1646 | |||
1647 | ret = wm8753_init(socdev); | ||
1648 | if (ret < 0) | ||
1649 | pr_err("failed to initialise WM8753\n"); | ||
1650 | |||
1651 | return ret; | ||
1652 | } | ||
1653 | |||
1654 | static int wm8753_i2c_remove(struct i2c_client *client) | ||
1655 | { | ||
1656 | struct snd_soc_codec *codec = i2c_get_clientdata(client); | ||
1657 | kfree(codec->reg_cache); | ||
1658 | return 0; | ||
1659 | } | ||
1660 | |||
1661 | static const struct i2c_device_id wm8753_i2c_id[] = { | ||
1662 | { "wm8753", 0 }, | ||
1663 | { } | ||
1664 | }; | ||
1665 | MODULE_DEVICE_TABLE(i2c, wm8753_i2c_id); | ||
1666 | |||
1667 | static struct i2c_driver wm8753_i2c_driver = { | ||
1668 | .driver = { | ||
1669 | .name = "WM8753 I2C Codec", | ||
1670 | .owner = THIS_MODULE, | ||
1671 | }, | ||
1672 | .probe = wm8753_i2c_probe, | ||
1673 | .remove = wm8753_i2c_remove, | ||
1674 | .id_table = wm8753_i2c_id, | ||
1675 | }; | ||
1676 | 1635 | ||
1677 | static int wm8753_add_i2c_device(struct platform_device *pdev, | 1636 | static int wm8753_add_i2c_device(struct platform_device *pdev, |
1678 | const struct wm8753_setup_data *setup) | 1637 | const struct wm8753_setup_data *setup) |
@@ -1715,63 +1674,6 @@ err_driver: | |||
1715 | } | 1674 | } |
1716 | #endif | 1675 | #endif |
1717 | 1676 | ||
1718 | #if defined(CONFIG_SPI_MASTER) | ||
1719 | static int __devinit wm8753_spi_probe(struct spi_device *spi) | ||
1720 | { | ||
1721 | struct snd_soc_device *socdev = wm8753_socdev; | ||
1722 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1723 | int ret; | ||
1724 | |||
1725 | codec->control_data = spi; | ||
1726 | |||
1727 | ret = wm8753_init(socdev); | ||
1728 | if (ret < 0) | ||
1729 | dev_err(&spi->dev, "failed to initialise WM8753\n"); | ||
1730 | |||
1731 | return ret; | ||
1732 | } | ||
1733 | |||
1734 | static int __devexit wm8753_spi_remove(struct spi_device *spi) | ||
1735 | { | ||
1736 | return 0; | ||
1737 | } | ||
1738 | |||
1739 | static struct spi_driver wm8753_spi_driver = { | ||
1740 | .driver = { | ||
1741 | .name = "wm8753", | ||
1742 | .bus = &spi_bus_type, | ||
1743 | .owner = THIS_MODULE, | ||
1744 | }, | ||
1745 | .probe = wm8753_spi_probe, | ||
1746 | .remove = __devexit_p(wm8753_spi_remove), | ||
1747 | }; | ||
1748 | |||
1749 | static int wm8753_spi_write(struct spi_device *spi, const char *data, int len) | ||
1750 | { | ||
1751 | struct spi_transfer t; | ||
1752 | struct spi_message m; | ||
1753 | u8 msg[2]; | ||
1754 | |||
1755 | if (len <= 0) | ||
1756 | return 0; | ||
1757 | |||
1758 | msg[0] = data[0]; | ||
1759 | msg[1] = data[1]; | ||
1760 | |||
1761 | spi_message_init(&m); | ||
1762 | memset(&t, 0, (sizeof t)); | ||
1763 | |||
1764 | t.tx_buf = &msg[0]; | ||
1765 | t.len = len; | ||
1766 | |||
1767 | spi_message_add_tail(&t, &m); | ||
1768 | spi_sync(spi, &m); | ||
1769 | |||
1770 | return len; | ||
1771 | } | ||
1772 | #endif | ||
1773 | |||
1774 | |||
1775 | static int wm8753_probe(struct platform_device *pdev) | 1677 | static int wm8753_probe(struct platform_device *pdev) |
1776 | { | 1678 | { |
1777 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 1679 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
@@ -1876,6 +1778,105 @@ struct snd_soc_codec_device soc_codec_dev_wm8753 = { | |||
1876 | }; | 1778 | }; |
1877 | EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753); | 1779 | EXPORT_SYMBOL_GPL(soc_codec_dev_wm8753); |
1878 | 1780 | ||
1781 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
1782 | |||
1783 | static int wm8753_i2c_probe(struct i2c_client *i2c, | ||
1784 | const struct i2c_device_id *id) | ||
1785 | { | ||
1786 | struct snd_soc_device *socdev = wm8753_socdev; | ||
1787 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1788 | int ret; | ||
1789 | |||
1790 | i2c_set_clientdata(i2c, codec); | ||
1791 | codec->control_data = i2c; | ||
1792 | |||
1793 | ret = wm8753_init(socdev); | ||
1794 | if (ret < 0) | ||
1795 | pr_err("failed to initialise WM8753\n"); | ||
1796 | |||
1797 | return ret; | ||
1798 | } | ||
1799 | |||
1800 | static int wm8753_i2c_remove(struct i2c_client *client) | ||
1801 | { | ||
1802 | struct snd_soc_codec *codec = i2c_get_clientdata(client); | ||
1803 | kfree(codec->reg_cache); | ||
1804 | return 0; | ||
1805 | } | ||
1806 | |||
1807 | static const struct i2c_device_id wm8753_i2c_id[] = { | ||
1808 | { "wm8753", 0 }, | ||
1809 | { } | ||
1810 | }; | ||
1811 | MODULE_DEVICE_TABLE(i2c, wm8753_i2c_id); | ||
1812 | |||
1813 | static struct i2c_driver wm8753_i2c_driver = { | ||
1814 | .driver = { | ||
1815 | .name = "WM8753 I2C Codec", | ||
1816 | .owner = THIS_MODULE, | ||
1817 | }, | ||
1818 | .probe = wm8753_i2c_probe, | ||
1819 | .remove = wm8753_i2c_remove, | ||
1820 | .id_table = wm8753_i2c_id, | ||
1821 | }; | ||
1822 | #endif | ||
1823 | |||
1824 | #if defined(CONFIG_SPI_MASTER) | ||
1825 | static int wm8753_spi_write(struct spi_device *spi, const char *data, int len) | ||
1826 | { | ||
1827 | struct spi_transfer t; | ||
1828 | struct spi_message m; | ||
1829 | u8 msg[2]; | ||
1830 | |||
1831 | if (len <= 0) | ||
1832 | return 0; | ||
1833 | |||
1834 | msg[0] = data[0]; | ||
1835 | msg[1] = data[1]; | ||
1836 | |||
1837 | spi_message_init(&m); | ||
1838 | memset(&t, 0, (sizeof t)); | ||
1839 | |||
1840 | t.tx_buf = &msg[0]; | ||
1841 | t.len = len; | ||
1842 | |||
1843 | spi_message_add_tail(&t, &m); | ||
1844 | spi_sync(spi, &m); | ||
1845 | |||
1846 | return len; | ||
1847 | } | ||
1848 | |||
1849 | static int __devinit wm8753_spi_probe(struct spi_device *spi) | ||
1850 | { | ||
1851 | struct snd_soc_device *socdev = wm8753_socdev; | ||
1852 | struct snd_soc_codec *codec = socdev->card->codec; | ||
1853 | int ret; | ||
1854 | |||
1855 | codec->control_data = spi; | ||
1856 | |||
1857 | ret = wm8753_init(socdev); | ||
1858 | if (ret < 0) | ||
1859 | dev_err(&spi->dev, "failed to initialise WM8753\n"); | ||
1860 | |||
1861 | return ret; | ||
1862 | } | ||
1863 | |||
1864 | static int __devexit wm8753_spi_remove(struct spi_device *spi) | ||
1865 | { | ||
1866 | return 0; | ||
1867 | } | ||
1868 | |||
1869 | static struct spi_driver wm8753_spi_driver = { | ||
1870 | .driver = { | ||
1871 | .name = "wm8753", | ||
1872 | .bus = &spi_bus_type, | ||
1873 | .owner = THIS_MODULE, | ||
1874 | }, | ||
1875 | .probe = wm8753_spi_probe, | ||
1876 | .remove = __devexit_p(wm8753_spi_remove), | ||
1877 | }; | ||
1878 | #endif | ||
1879 | |||
1879 | static int __init wm8753_modinit(void) | 1880 | static int __init wm8753_modinit(void) |
1880 | { | 1881 | { |
1881 | return snd_soc_register_dais(wm8753_dai, ARRAY_SIZE(wm8753_dai)); | 1882 | return snd_soc_register_dais(wm8753_dai, ARRAY_SIZE(wm8753_dai)); |