ar71xx: Add kernel 4.9 support
[openwrt/staging/mkresin.git] / target / linux / ar71xx / files / drivers / net / ethernet / atheros / ag71xx / ag71xx_mdio.c
index e123505c7a54099531ad74e13bded545b0332291..2915476569c5c7fba1558d6fa7fab521f2b37f60 100644 (file)
@@ -181,6 +181,9 @@ static int ag71xx_mdio_reset(struct mii_bus *bus)
        ag71xx_mdio_wr(am, AG71XX_REG_MII_CFG, t);
        udelay(100);
 
+       if (am->pdata->reset)
+               am->pdata->reset(bus);
+
        return 0;
 }
 
@@ -205,7 +208,7 @@ static int ag71xx_mdio_write(struct mii_bus *bus, int addr, int reg, u16 val)
        return 0;
 }
 
-static int __devinit ag71xx_mdio_probe(struct platform_device *pdev)
+static int ag71xx_mdio_probe(struct platform_device *pdev)
 {
        struct ag71xx_mdio_platform_data *pdata;
        struct ag71xx_mdio *am;
@@ -231,7 +234,7 @@ static int __devinit ag71xx_mdio_probe(struct platform_device *pdev)
        if (!res) {
                dev_err(&pdev->dev, "no iomem resource found\n");
                err = -ENXIO;
-               goto err_out;
+               goto err_free_mdio;
        }
 
        am->mdio_base = ioremap_nocache(res->start, res->end - res->start + 1);
@@ -251,7 +254,11 @@ static int __devinit ag71xx_mdio_probe(struct platform_device *pdev)
        am->mii_bus->read = ag71xx_mdio_read;
        am->mii_bus->write = ag71xx_mdio_write;
        am->mii_bus->reset = ag71xx_mdio_reset;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,5,0)
        am->mii_bus->irq = am->mii_irq;
+#else
+       memcpy(am->mii_bus->irq, am->mii_irq, sizeof(am->mii_bus->irq));
+#endif
        am->mii_bus->priv = am;
        am->mii_bus->parent = &pdev->dev;
        snprintf(am->mii_bus->id, MII_BUS_ID_SIZE, "%s", dev_name(&pdev->dev));
@@ -281,7 +288,7 @@ err_out:
        return err;
 }
 
-static int __devexit ag71xx_mdio_remove(struct platform_device *pdev)
+static int ag71xx_mdio_remove(struct platform_device *pdev)
 {
        struct ag71xx_mdio *am = platform_get_drvdata(pdev);
 
@@ -298,7 +305,7 @@ static int __devexit ag71xx_mdio_remove(struct platform_device *pdev)
 
 static struct platform_driver ag71xx_mdio_driver = {
        .probe          = ag71xx_mdio_probe,
-       .remove         = __exit_p(ag71xx_mdio_remove),
+       .remove         = ag71xx_mdio_remove,
        .driver = {
                .name   = "ag71xx-mdio",
        }