Skip to content

Commit

Permalink
Merge branch 'sh_eth-simplify-TSU-initialization'
Browse files Browse the repository at this point in the history
Sergei Shtylyov says:

====================
sh_eth: simplify TSU initialization

Here's a set of 2 patches against DaveM's 'net-next.git' repo. With those,
I'm somewhat simplifying the TSU init code in the driver probe() method...
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 15, 2018
2 parents d9631c7 + 9662ec1 commit 5138eb9
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions drivers/net/ethernet/renesas/sh_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
struct sh_eth_private *mdp;
struct net_device *ndev;
int ret, devno;
int ret;

/* get base addr */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Expand All @@ -3137,10 +3137,6 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

devno = pdev->id;
if (devno < 0)
devno = 0;

ret = platform_get_irq(pdev, 0);
if (ret < 0)
goto out_release;
Expand Down Expand Up @@ -3222,8 +3218,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
eth_hw_addr_random(ndev);
}

/* ioremap the TSU registers */
if (mdp->cd->tsu) {
int port = pdev->id < 0 ? 0 : pdev->id % 2;
struct resource *rtsu;

rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
Expand All @@ -3235,31 +3231,30 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
/* We can only request the TSU region for the first port
* 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,
resource_size(rtsu),
dev_name(&pdev->dev))) {
dev_err(&pdev->dev, "can't request TSU resource.\n");
ret = -EBUSY;
goto out_release;
}
/* ioremap the TSU registers */
mdp->tsu_addr = devm_ioremap(&pdev->dev, rtsu->start,
resource_size(rtsu));
if (!mdp->tsu_addr) {
dev_err(&pdev->dev, "TSU region ioremap() failed.\n");
ret = -ENOMEM;
goto out_release;
}
mdp->port = devno % 2;
mdp->port = port;
ndev->features = NETIF_F_HW_VLAN_CTAG_FILTER;
}

/* Need to init only the first port of the two sharing a TSU */
if (devno % 2 == 0) {
if (mdp->cd->chip_reset)
mdp->cd->chip_reset(ndev);
/* Need to init only the first port of the two sharing a TSU */
if (port == 0) {
if (mdp->cd->chip_reset)
mdp->cd->chip_reset(ndev);

if (mdp->cd->tsu) {
/* TSU init (Init only)*/
sh_eth_tsu_init(mdp);
}
Expand Down

0 comments on commit 5138eb9

Please sign in to comment.