diff options
author | Lad, Prabhakar <prabhakar.csengg@gmail.com> | 2013-06-25 11:54:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-25 19:52:29 -0400 |
commit | 151328c828795574bed6ce8b37c3d0bd586e162f (patch) | |
tree | 9b304c8d03c64a8846c1fa32a5bf27abae11f04c /drivers/net/ethernet/ti | |
parent | 6892b41d9701283085b655c6086fb57a5d63fa47 (diff) |
net: davinci_emac: simplify the OF parser code
This patch cleans up the OF parser code, removes unnecessary checks
on of_property_read_*() and guards davinci_emac_of_match table with
CONFIG_OF.
Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ti')
-rw-r--r-- | drivers/net/ethernet/ti/davinci_emac.c | 67 |
1 files changed, 23 insertions, 44 deletions
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 7a66f9c33159..f118d7133128 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c | |||
@@ -1754,29 +1754,22 @@ static const struct net_device_ops emac_netdev_ops = { | |||
1754 | #endif | 1754 | #endif |
1755 | }; | 1755 | }; |
1756 | 1756 | ||
1757 | #ifdef CONFIG_OF | 1757 | static struct emac_platform_data * |
1758 | static struct emac_platform_data | 1758 | davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) |
1759 | *davinci_emac_of_get_pdata(struct platform_device *pdev, | ||
1760 | struct emac_priv *priv) | ||
1761 | { | 1759 | { |
1762 | struct device_node *np; | 1760 | struct device_node *np; |
1763 | struct emac_platform_data *pdata = NULL; | 1761 | struct emac_platform_data *pdata = NULL; |
1764 | const u8 *mac_addr; | 1762 | const u8 *mac_addr; |
1765 | u32 data; | ||
1766 | int ret; | ||
1767 | 1763 | ||
1768 | pdata = pdev->dev.platform_data; | 1764 | if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node) |
1769 | if (!pdata) { | 1765 | return pdev->dev.platform_data; |
1770 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | 1766 | |
1771 | if (!pdata) | 1767 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
1772 | goto nodata; | 1768 | if (!pdata) |
1773 | } | 1769 | return NULL; |
1774 | 1770 | ||
1775 | np = pdev->dev.of_node; | 1771 | np = pdev->dev.of_node; |
1776 | if (!np) | 1772 | pdata->version = EMAC_VERSION_2; |
1777 | goto nodata; | ||
1778 | else | ||
1779 | pdata->version = EMAC_VERSION_2; | ||
1780 | 1773 | ||
1781 | if (!is_valid_ether_addr(pdata->mac_addr)) { | 1774 | if (!is_valid_ether_addr(pdata->mac_addr)) { |
1782 | mac_addr = of_get_mac_address(np); | 1775 | mac_addr = of_get_mac_address(np); |
@@ -1784,47 +1777,31 @@ static struct emac_platform_data | |||
1784 | memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); | 1777 | memcpy(pdata->mac_addr, mac_addr, ETH_ALEN); |
1785 | } | 1778 | } |
1786 | 1779 | ||
1787 | ret = of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &data); | 1780 | of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", |
1788 | if (!ret) | 1781 | &pdata->ctrl_reg_offset); |
1789 | pdata->ctrl_reg_offset = data; | ||
1790 | 1782 | ||
1791 | ret = of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset", | 1783 | of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset", |
1792 | &data); | 1784 | &pdata->ctrl_mod_reg_offset); |
1793 | if (!ret) | ||
1794 | pdata->ctrl_mod_reg_offset = data; | ||
1795 | 1785 | ||
1796 | ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-offset", &data); | 1786 | of_property_read_u32(np, "ti,davinci-ctrl-ram-offset", |
1797 | if (!ret) | 1787 | &pdata->ctrl_ram_offset); |
1798 | pdata->ctrl_ram_offset = data; | ||
1799 | 1788 | ||
1800 | ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-size", &data); | 1789 | of_property_read_u32(np, "ti,davinci-ctrl-ram-size", |
1801 | if (!ret) | 1790 | &pdata->ctrl_ram_size); |
1802 | pdata->ctrl_ram_size = data; | ||
1803 | 1791 | ||
1804 | ret = of_property_read_u32(np, "ti,davinci-rmii-en", &data); | 1792 | of_property_read_u8(np, "ti,davinci-rmii-en", &pdata->rmii_en); |
1805 | if (!ret) | ||
1806 | pdata->rmii_en = data; | ||
1807 | 1793 | ||
1808 | ret = of_property_read_u32(np, "ti,davinci-no-bd-ram", &data); | 1794 | pdata->no_bd_ram = of_property_read_bool(np, "ti,davinci-no-bd-ram"); |
1809 | if (!ret) | ||
1810 | pdata->no_bd_ram = data; | ||
1811 | 1795 | ||
1812 | priv->phy_node = of_parse_phandle(np, "phy-handle", 0); | 1796 | priv->phy_node = of_parse_phandle(np, "phy-handle", 0); |
1813 | if (!priv->phy_node) | 1797 | if (!priv->phy_node) |
1814 | pdata->phy_id = ""; | 1798 | pdata->phy_id = ""; |
1815 | 1799 | ||
1816 | pdev->dev.platform_data = pdata; | 1800 | pdev->dev.platform_data = pdata; |
1817 | nodata: | 1801 | |
1818 | return pdata; | 1802 | return pdata; |
1819 | } | 1803 | } |
1820 | #else | 1804 | |
1821 | static struct emac_platform_data | ||
1822 | *davinci_emac_of_get_pdata(struct platform_device *pdev, | ||
1823 | struct emac_priv *priv) | ||
1824 | { | ||
1825 | return pdev->dev.platform_data; | ||
1826 | } | ||
1827 | #endif | ||
1828 | /** | 1805 | /** |
1829 | * davinci_emac_probe - EMAC device probe | 1806 | * davinci_emac_probe - EMAC device probe |
1830 | * @pdev: The DaVinci EMAC device that we are removing | 1807 | * @pdev: The DaVinci EMAC device that we are removing |
@@ -2045,11 +2022,13 @@ static const struct dev_pm_ops davinci_emac_pm_ops = { | |||
2045 | .resume = davinci_emac_resume, | 2022 | .resume = davinci_emac_resume, |
2046 | }; | 2023 | }; |
2047 | 2024 | ||
2025 | #if IS_ENABLED(CONFIG_OF) | ||
2048 | static const struct of_device_id davinci_emac_of_match[] = { | 2026 | static const struct of_device_id davinci_emac_of_match[] = { |
2049 | {.compatible = "ti,davinci-dm6467-emac", }, | 2027 | {.compatible = "ti,davinci-dm6467-emac", }, |
2050 | {}, | 2028 | {}, |
2051 | }; | 2029 | }; |
2052 | MODULE_DEVICE_TABLE(of, davinci_emac_of_match); | 2030 | MODULE_DEVICE_TABLE(of, davinci_emac_of_match); |
2031 | #endif | ||
2053 | 2032 | ||
2054 | /* davinci_emac_driver: EMAC platform driver structure */ | 2033 | /* davinci_emac_driver: EMAC platform driver structure */ |
2055 | static struct platform_driver davinci_emac_driver = { | 2034 | static struct platform_driver davinci_emac_driver = { |