net: sh_eth: modify a condition of ioremap for TSU
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Wed, 15 Feb 2012 17:55:01 +0000 (17:55 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 16 Feb 2012 22:08:09 +0000 (17:08 -0500)
If the controller has TSU, the each channel needs TSU registers.
This patch also fixes the iounmap condition in the sh_eth_drv_remove().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/sh_eth.c

index 5a5afbc7273b89b4f6e16efd0448b0a2858bc676..8bd0e58974242e622ea7b39991fd2b2988e68ec7 100644 (file)
@@ -1859,18 +1859,20 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
        /* read and set MAC address */
        read_mac_address(ndev, pd->mac_addr);
 
+       /* ioremap the TSU registers */
+       if (mdp->cd->tsu) {
+               struct resource *rtsu;
+               rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+               if (!rtsu) {
+                       dev_err(&pdev->dev, "Not found TSU resource\n");
+                       goto out_release;
+               }
+               mdp->tsu_addr = ioremap(rtsu->start,
+                                       resource_size(rtsu));
+       }
+
        /* initialize first or needed device */
        if (!devno || pd->needs_init) {
-               if (mdp->cd->tsu) {
-                       struct resource *rtsu;
-                       rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-                       if (!rtsu) {
-                               dev_err(&pdev->dev, "Not found TSU resource\n");
-                               goto out_release;
-                       }
-                       mdp->tsu_addr = ioremap(rtsu->start,
-                                               resource_size(rtsu));
-               }
                if (mdp->cd->chip_reset)
                        mdp->cd->chip_reset(ndev);
 
@@ -1919,7 +1921,8 @@ static int sh_eth_drv_remove(struct platform_device *pdev)
        struct net_device *ndev = platform_get_drvdata(pdev);
        struct sh_eth_private *mdp = netdev_priv(ndev);
 
-       iounmap(mdp->tsu_addr);
+       if (mdp->cd->tsu)
+               iounmap(mdp->tsu_addr);
        sh_mdio_release(ndev);
        unregister_netdev(ndev);
        pm_runtime_disable(&pdev->dev);