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>
This commit is contained in:
parent
6892b41d97
commit
151328c828
1 changed files with 23 additions and 44 deletions
|
@ -1754,29 +1754,22 @@ static const struct net_device_ops emac_netdev_ops = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_OF
|
static struct emac_platform_data *
|
||||||
static struct emac_platform_data
|
davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
|
||||||
*davinci_emac_of_get_pdata(struct platform_device *pdev,
|
|
||||||
struct emac_priv *priv)
|
|
||||||
{
|
{
|
||||||
struct device_node *np;
|
struct device_node *np;
|
||||||
struct emac_platform_data *pdata = NULL;
|
struct emac_platform_data *pdata = NULL;
|
||||||
const u8 *mac_addr;
|
const u8 *mac_addr;
|
||||||
u32 data;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
pdata = pdev->dev.platform_data;
|
if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node)
|
||||||
if (!pdata) {
|
return pdev->dev.platform_data;
|
||||||
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
|
||||||
if (!pdata)
|
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
||||||
goto nodata;
|
if (!pdata)
|
||||||
}
|
return NULL;
|
||||||
|
|
||||||
np = pdev->dev.of_node;
|
np = pdev->dev.of_node;
|
||||||
if (!np)
|
pdata->version = EMAC_VERSION_2;
|
||||||
goto nodata;
|
|
||||||
else
|
|
||||||
pdata->version = EMAC_VERSION_2;
|
|
||||||
|
|
||||||
if (!is_valid_ether_addr(pdata->mac_addr)) {
|
if (!is_valid_ether_addr(pdata->mac_addr)) {
|
||||||
mac_addr = of_get_mac_address(np);
|
mac_addr = of_get_mac_address(np);
|
||||||
|
@ -1784,47 +1777,31 @@ static struct emac_platform_data
|
||||||
memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
|
memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &data);
|
of_property_read_u32(np, "ti,davinci-ctrl-reg-offset",
|
||||||
if (!ret)
|
&pdata->ctrl_reg_offset);
|
||||||
pdata->ctrl_reg_offset = data;
|
|
||||||
|
|
||||||
ret = of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset",
|
of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset",
|
||||||
&data);
|
&pdata->ctrl_mod_reg_offset);
|
||||||
if (!ret)
|
|
||||||
pdata->ctrl_mod_reg_offset = data;
|
|
||||||
|
|
||||||
ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-offset", &data);
|
of_property_read_u32(np, "ti,davinci-ctrl-ram-offset",
|
||||||
if (!ret)
|
&pdata->ctrl_ram_offset);
|
||||||
pdata->ctrl_ram_offset = data;
|
|
||||||
|
|
||||||
ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-size", &data);
|
of_property_read_u32(np, "ti,davinci-ctrl-ram-size",
|
||||||
if (!ret)
|
&pdata->ctrl_ram_size);
|
||||||
pdata->ctrl_ram_size = data;
|
|
||||||
|
|
||||||
ret = of_property_read_u32(np, "ti,davinci-rmii-en", &data);
|
of_property_read_u8(np, "ti,davinci-rmii-en", &pdata->rmii_en);
|
||||||
if (!ret)
|
|
||||||
pdata->rmii_en = data;
|
|
||||||
|
|
||||||
ret = of_property_read_u32(np, "ti,davinci-no-bd-ram", &data);
|
pdata->no_bd_ram = of_property_read_bool(np, "ti,davinci-no-bd-ram");
|
||||||
if (!ret)
|
|
||||||
pdata->no_bd_ram = data;
|
|
||||||
|
|
||||||
priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
|
priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
|
||||||
if (!priv->phy_node)
|
if (!priv->phy_node)
|
||||||
pdata->phy_id = "";
|
pdata->phy_id = "";
|
||||||
|
|
||||||
pdev->dev.platform_data = pdata;
|
pdev->dev.platform_data = pdata;
|
||||||
nodata:
|
|
||||||
return pdata;
|
return pdata;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static struct emac_platform_data
|
|
||||||
*davinci_emac_of_get_pdata(struct platform_device *pdev,
|
|
||||||
struct emac_priv *priv)
|
|
||||||
{
|
|
||||||
return pdev->dev.platform_data;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* davinci_emac_probe - EMAC device probe
|
* davinci_emac_probe - EMAC device probe
|
||||||
* @pdev: The DaVinci EMAC device that we are removing
|
* @pdev: The DaVinci EMAC device that we are removing
|
||||||
|
@ -2045,11 +2022,13 @@ static const struct dev_pm_ops davinci_emac_pm_ops = {
|
||||||
.resume = davinci_emac_resume,
|
.resume = davinci_emac_resume,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_OF)
|
||||||
static const struct of_device_id davinci_emac_of_match[] = {
|
static const struct of_device_id davinci_emac_of_match[] = {
|
||||||
{.compatible = "ti,davinci-dm6467-emac", },
|
{.compatible = "ti,davinci-dm6467-emac", },
|
||||||
{},
|
{},
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
|
MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* davinci_emac_driver: EMAC platform driver structure */
|
/* davinci_emac_driver: EMAC platform driver structure */
|
||||||
static struct platform_driver davinci_emac_driver = {
|
static struct platform_driver davinci_emac_driver = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue