提交 9662ec19 编写于 作者: S Sergei Shtylyov 提交者: David S. Miller

sh_eth: get Ether port # only when needed

The dual-port Ether configurations always have a shared TSU to e.g. pass
the packets between those  ports.  With the  TSU init. code gathered under
the single *if*, we now can only get the port # from 'platform_device::id'
only when we actually  need it  (and not recalculate it each time)...
Signed-off-by: NSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 3e14c969
...@@ -3125,7 +3125,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -3125,7 +3125,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
const struct platform_device_id *id = platform_get_device_id(pdev); const struct platform_device_id *id = platform_get_device_id(pdev);
struct sh_eth_private *mdp; struct sh_eth_private *mdp;
struct net_device *ndev; struct net_device *ndev;
int ret, devno; int ret;
/* get base addr */ /* get base addr */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
...@@ -3137,10 +3137,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -3137,10 +3137,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev); pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev); pm_runtime_get_sync(&pdev->dev);
devno = pdev->id;
if (devno < 0)
devno = 0;
ret = platform_get_irq(pdev, 0); ret = platform_get_irq(pdev, 0);
if (ret < 0) if (ret < 0)
goto out_release; goto out_release;
...@@ -3223,6 +3219,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -3223,6 +3219,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
} }
if (mdp->cd->tsu) { if (mdp->cd->tsu) {
int port = pdev->id < 0 ? 0 : pdev->id % 2;
struct resource *rtsu; struct resource *rtsu;
rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1); rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
...@@ -3234,7 +3231,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -3234,7 +3231,7 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
/* We can only request the TSU region for the first port /* We can only request the TSU region for the first port
* of the two sharing this TSU for the probe to succeed... * of the two sharing this TSU for the probe to succeed...
*/ */
if (devno % 2 == 0 && if (port == 0 &&
!devm_request_mem_region(&pdev->dev, rtsu->start, !devm_request_mem_region(&pdev->dev, rtsu->start,
resource_size(rtsu), resource_size(rtsu),
dev_name(&pdev->dev))) { dev_name(&pdev->dev))) {
...@@ -3250,11 +3247,11 @@ static int sh_eth_drv_probe(struct platform_device *pdev) ...@@ -3250,11 +3247,11 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
ret = -ENOMEM; ret = -ENOMEM;
goto out_release; goto out_release;
} }
mdp->port = devno % 2; mdp->port = port;
ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER; ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER;
/* Need to init only the first port of the two sharing a TSU */ /* Need to init only the first port of the two sharing a TSU */
if (devno % 2 == 0) { if (port == 0) {
if (mdp->cd->chip_reset) if (mdp->cd->chip_reset)
mdp->cd->chip_reset(ndev); mdp->cd->chip_reset(ndev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册