openwrt/target/linux/generic/pending-3.18/002-phy_drivers_backport.patch
Hauke Mehrtens 4336efe14b kernel: use upstream patches for musl
This replaces the current patches used to make the kernel headers
compatible with musl with the version which was accepted upstream. This
is included in upstream kernel 4.15.
This was compile tested with iproute2 build on all supported kernel
versions with musl and one one with glibc.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2018-01-20 22:11:33 +01:00

553 lines
15 KiB
Diff

--- a/drivers/net/phy/adm6996.c
+++ b/drivers/net/phy/adm6996.c
@@ -289,7 +289,7 @@ static u16
adm6996_read_mii_reg(struct adm6996_priv *priv, enum admreg reg)
{
struct phy_device *phydev = priv->priv;
- struct mii_bus *bus = phydev->mdio.bus;
+ struct mii_bus *bus = phydev->bus;
return bus->read(bus, PHYADDR(reg));
}
@@ -298,7 +298,7 @@ static void
adm6996_write_mii_reg(struct adm6996_priv *priv, enum admreg reg, u16 val)
{
struct phy_device *phydev = priv->priv;
- struct mii_bus *bus = phydev->mdio.bus;
+ struct mii_bus *bus = phydev->bus;
bus->write(bus, PHYADDR(reg), val);
}
@@ -1050,13 +1050,13 @@ static int adm6996_config_init(struct ph
pdev->supported = ADVERTISED_100baseT_Full;
pdev->advertising = ADVERTISED_100baseT_Full;
- if (pdev->mdio.addr != 0) {
+ if (pdev->addr != 0) {
pr_info ("%s: PHY overlaps ADM6996, providing fixed PHY 0x%x.\n"
- , pdev->attached_dev->name, pdev->mdio.addr);
+ , pdev->attached_dev->name, pdev->addr);
return 0;
}
- priv = devm_kzalloc(&pdev->mdio.dev, sizeof(struct adm6996_priv), GFP_KERNEL);
+ priv = devm_kzalloc(&pdev->dev, sizeof(struct adm6996_priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
@@ -1076,7 +1076,7 @@ static int adm6996_config_init(struct ph
}
/*
- * Warning: phydev->priv is NULL if phydev->mdio.addr != 0
+ * Warning: phydev->priv is NULL if phydev->addr != 0
*/
static int adm6996_read_status(struct phy_device *phydev)
{
@@ -1092,7 +1092,7 @@ static int adm6996_read_status(struct ph
}
/*
- * Warning: phydev->priv is NULL if phydev->mdio.addr != 0
+ * Warning: phydev->priv is NULL if phydev->addr != 0
*/
static int adm6996_config_aneg(struct phy_device *phydev)
{
@@ -1101,11 +1101,11 @@ static int adm6996_config_aneg(struct ph
static int adm6996_fixup(struct phy_device *dev)
{
- struct mii_bus *bus = dev->mdio.bus;
+ struct mii_bus *bus = dev->bus;
u16 reg;
/* Our custom registers are at PHY addresses 0-10. Claim those. */
- if (dev->mdio.addr > 10)
+ if (dev->addr > 10)
return 0;
/* look for the switch on the bus */
@@ -1152,6 +1152,7 @@ static struct phy_driver adm6996_phy_dri
.config_aneg = &adm6996_config_aneg,
.read_status = &adm6996_read_status,
.soft_reset = adm6996_soft_reset,
+ .driver = { .owner = THIS_MODULE,},
};
static int adm6996_gpio_probe(struct platform_device *pdev)
@@ -1220,7 +1221,7 @@ static int __init adm6996_init(void)
int err;
phy_register_fixup_for_id(PHY_ANY_ID, adm6996_fixup);
- err = phy_driver_register(&adm6996_phy_driver, THIS_MODULE);
+ err = phy_driver_register(&adm6996_phy_driver);
if (err)
return err;
--- a/drivers/net/phy/ar8216.c
+++ b/drivers/net/phy/ar8216.c
@@ -177,7 +177,7 @@ ar8xxx_phy_check_aneg(struct phy_device
if (ret & BMCR_ANENABLE)
return 0;
- dev_info(&phydev->mdio.dev, "ANEG disabled, re-enabling ...\n");
+ dev_info(&phydev->dev, "ANEG disabled, re-enabling ...\n");
ret |= BMCR_ANENABLE | BMCR_ANRESTART;
return phy_write(phydev, MII_BMCR, ret);
}
@@ -2007,7 +2007,7 @@ ar8xxx_phy_config_init(struct phy_device
priv->phy = phydev;
- if (phydev->mdio.addr != 0) {
+ if (phydev->addr != 0) {
if (chip_is_ar8316(priv)) {
/* switch device has been initialized, reinit */
priv->dev.ports = (AR8216_NUM_PORTS - 1);
@@ -2055,7 +2055,7 @@ ar8xxx_check_link_states(struct ar8xxx_p
/* flush ARL entries for this port if it went down*/
if (!link_new)
priv->chip->atu_flush_port(priv, i);
- dev_info(&priv->phy->mdio.dev, "Port %d is %s\n",
+ dev_info(&priv->phy->dev, "Port %d is %s\n",
i, link_new ? "up" : "down");
}
@@ -2074,10 +2074,10 @@ ar8xxx_phy_read_status(struct phy_device
if (phydev->state == PHY_CHANGELINK)
ar8xxx_check_link_states(priv);
- if (phydev->mdio.addr != 0)
+ if (phydev->addr != 0)
return genphy_read_status(phydev);
- ar8216_read_port_link(priv, phydev->mdio.addr, &link);
+ ar8216_read_port_link(priv, phydev->addr, &link);
phydev->link = !!link.link;
if (!phydev->link)
return 0;
@@ -2107,7 +2107,7 @@ ar8xxx_phy_read_status(struct phy_device
static int
ar8xxx_phy_config_aneg(struct phy_device *phydev)
{
- if (phydev->mdio.addr == 0)
+ if (phydev->addr == 0)
return 0;
return genphy_config_aneg(phydev);
@@ -2162,15 +2162,15 @@ ar8xxx_phy_probe(struct phy_device *phyd
int ret;
/* skip PHYs at unused adresses */
- if (phydev->mdio.addr != 0 && phydev->mdio.addr != 4)
+ if (phydev->addr != 0 && phydev->addr != 4)
return -ENODEV;
- if (!ar8xxx_is_possible(phydev->mdio.bus))
+ if (!ar8xxx_is_possible(phydev->bus))
return -ENODEV;
mutex_lock(&ar8xxx_dev_list_lock);
list_for_each_entry(priv, &ar8xxx_dev_list, list)
- if (priv->mii_bus == phydev->mdio.bus)
+ if (priv->mii_bus == phydev->bus)
goto found;
priv = ar8xxx_create();
@@ -2179,7 +2179,7 @@ ar8xxx_phy_probe(struct phy_device *phyd
goto unlock;
}
- priv->mii_bus = phydev->mdio.bus;
+ priv->mii_bus = phydev->bus;
ret = ar8xxx_probe_switch(priv);
if (ret)
@@ -2200,7 +2200,7 @@ ar8xxx_phy_probe(struct phy_device *phyd
found:
priv->use_count++;
- if (phydev->mdio.addr == 0) {
+ if (phydev->addr == 0) {
if (ar8xxx_has_gige(priv)) {
phydev->supported = SUPPORTED_1000baseT_Full;
phydev->advertising = ADVERTISED_1000baseT_Full;
@@ -2288,21 +2288,33 @@ ar8xxx_phy_soft_reset(struct phy_device
return 0;
}
-static struct phy_driver ar8xxx_phy_driver[] = {
- {
- .phy_id = 0x004d0000,
- .name = "Atheros AR8216/AR8236/AR8316",
- .phy_id_mask = 0xffff0000,
- .features = PHY_BASIC_FEATURES,
- .probe = ar8xxx_phy_probe,
- .remove = ar8xxx_phy_remove,
- .detach = ar8xxx_phy_detach,
- .config_init = ar8xxx_phy_config_init,
- .config_aneg = ar8xxx_phy_config_aneg,
- .read_status = ar8xxx_phy_read_status,
- .soft_reset = ar8xxx_phy_soft_reset,
- }
+static struct phy_driver ar8xxx_phy_driver = {
+ .phy_id = 0x004d0000,
+ .name = "Atheros AR8216/AR8236/AR8316",
+ .phy_id_mask = 0xffff0000,
+ .features = PHY_BASIC_FEATURES,
+ .probe = ar8xxx_phy_probe,
+ .remove = ar8xxx_phy_remove,
+ .detach = ar8xxx_phy_detach,
+ .config_init = ar8xxx_phy_config_init,
+ .config_aneg = ar8xxx_phy_config_aneg,
+ .read_status = ar8xxx_phy_read_status,
+ .soft_reset = ar8xxx_phy_soft_reset,
+ .driver = { .owner = THIS_MODULE },
};
-module_phy_driver(ar8xxx_phy_driver);
+int __init
+ar8xxx_init(void)
+{
+ return phy_driver_register(&ar8xxx_phy_driver);
+}
+
+void __exit
+ar8xxx_exit(void)
+{
+ phy_driver_unregister(&ar8xxx_phy_driver);
+}
+
+module_init(ar8xxx_init);
+module_exit(ar8xxx_exit);
MODULE_LICENSE("GPL");
--- a/drivers/net/phy/ar8327.c
+++ b/drivers/net/phy/ar8327.c
@@ -627,11 +627,11 @@ ar8327_hw_init(struct ar8xxx_priv *priv)
if (!priv->chip_data)
return -ENOMEM;
- if (priv->phy->mdio.dev.of_node)
- ret = ar8327_hw_config_of(priv, priv->phy->mdio.dev.of_node);
+ if (priv->phy->dev.of_node)
+ ret = ar8327_hw_config_of(priv, priv->phy->dev.of_node);
else
ret = ar8327_hw_config_pdata(priv,
- priv->phy->mdio.dev.platform_data);
+ priv->phy->dev.platform_data);
if (ret)
return ret;
--- a/drivers/net/phy/ip17xx.c
+++ b/drivers/net/phy/ip17xx.c
@@ -1273,7 +1273,7 @@ static int ip17xx_probe(struct phy_devic
int err;
/* We only attach to PHY 0, but use all available PHYs */
- if (pdev->mdio.addr != 0)
+ if (pdev->addr != 0)
return -ENODEV;
state = kzalloc(sizeof(*state), GFP_KERNEL);
@@ -1283,7 +1283,7 @@ static int ip17xx_probe(struct phy_devic
dev = &state->dev;
pdev->priv = state;
- state->mii_bus = pdev->mdio.bus;
+ state->mii_bus = pdev->bus;
err = get_model(state);
if (err < 0)
@@ -1295,7 +1295,7 @@ static int ip17xx_probe(struct phy_devic
dev->name = state->regs->NAME;
dev->ops = &ip17xx_ops;
- pr_info("IP17xx: Found %s at %s\n", dev->name, dev_name(&pdev->mdio.dev));
+ pr_info("IP17xx: Found %s at %s\n", dev->name, dev_name(&pdev->dev));
return 0;
error:
@@ -1353,25 +1353,58 @@ static int ip17xx_read_status(struct phy
return 0;
}
-static struct phy_driver ip17xx_driver[] = {
- {
- .name = "IC+ IP17xx",
- .phy_id = 0x02430c00,
- .phy_id_mask = 0x0ffffc00,
- .features = PHY_BASIC_FEATURES,
- .probe = ip17xx_probe,
- .remove = ip17xx_remove,
- .config_init = ip17xx_config_init,
- .config_aneg = ip17xx_config_aneg,
- .aneg_done = ip17xx_aneg_done,
- .update_link = ip17xx_update_link,
- .read_status = ip17xx_read_status,
- }
+static struct phy_driver ip17xx_driver = {
+ .name = "IC+ IP17xx",
+ .phy_id = 0x02430c00,
+ .phy_id_mask = 0x0ffffc00,
+ .features = PHY_BASIC_FEATURES,
+ .probe = ip17xx_probe,
+ .remove = ip17xx_remove,
+ .config_init = ip17xx_config_init,
+ .config_aneg = ip17xx_config_aneg,
+ .aneg_done = ip17xx_aneg_done,
+ .update_link = ip17xx_update_link,
+ .read_status = ip17xx_read_status,
+ .driver = { .owner = THIS_MODULE },
};
-module_phy_driver(ip17xx_driver);
+static struct phy_driver ip175a_driver = {
+ .name = "IC+ IP175A",
+ .phy_id = 0x02430c50,
+ .phy_id_mask = 0x0ffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .probe = ip17xx_probe,
+ .remove = ip17xx_remove,
+ .config_init = ip17xx_config_init,
+ .config_aneg = ip17xx_config_aneg,
+ .aneg_done = ip17xx_aneg_done,
+ .update_link = ip17xx_update_link,
+ .read_status = ip17xx_read_status,
+ .driver = { .owner = THIS_MODULE },
+};
+
+
+int __init ip17xx_init(void)
+{
+ int ret;
+
+ ret = phy_driver_register(&ip175a_driver);
+ if (ret < 0)
+ return ret;
+
+ return phy_driver_register(&ip17xx_driver);
+}
+
+void __exit ip17xx_exit(void)
+{
+ phy_driver_unregister(&ip17xx_driver);
+ phy_driver_unregister(&ip175a_driver);
+}
MODULE_AUTHOR("Patrick Horn <patrick.horn@gmail.com>");
MODULE_AUTHOR("Felix Fietkau <nbd@nbd.name>");
MODULE_AUTHOR("Martin Mares <mj@ucw.cz>");
MODULE_LICENSE("GPL");
+
+module_init(ip17xx_init);
+module_exit(ip17xx_exit);
--- a/drivers/net/phy/mvswitch.c
+++ b/drivers/net/phy/mvswitch.c
@@ -50,17 +50,13 @@ struct mvswitch_priv {
static inline u16
r16(struct phy_device *phydev, int addr, int reg)
{
- struct mii_bus *bus = phydev->mdio.bus;
-
- return bus->read(bus, addr, reg);
+ return phydev->bus->read(phydev->bus, addr, reg);
}
static inline void
w16(struct phy_device *phydev, int addr, int reg, u16 val)
{
- struct mii_bus *bus = phydev->mdio.bus;
-
- bus->write(bus, addr, reg, val);
+ phydev->bus->write(phydev->bus, addr, reg, val);
}
@@ -398,13 +394,12 @@ mvswitch_probe(struct phy_device *pdev)
static int
mvswitch_fixup(struct phy_device *dev)
{
- struct mii_bus *bus = dev->mdio.bus;
u16 reg;
- if (dev->mdio.addr != 0x10)
+ if (dev->addr != 0x10)
return 0;
- reg = bus->read(bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
+ reg = dev->bus->read(dev->bus, MV_PORTREG(IDENT, 0)) & MV_IDENT_MASK;
if (reg != MV_IDENT_VALUE)
return 0;
@@ -425,13 +420,14 @@ static struct phy_driver mvswitch_driver
.config_aneg = &mvswitch_config_aneg,
.aneg_done = &mvswitch_aneg_done,
.read_status = &mvswitch_read_status,
+ .driver = { .owner = THIS_MODULE,},
};
static int __init
mvswitch_init(void)
{
phy_register_fixup_for_id(PHY_ANY_ID, mvswitch_fixup);
- return phy_driver_register(&mvswitch_driver, THIS_MODULE);
+ return phy_driver_register(&mvswitch_driver);
}
static void __exit
--- a/drivers/net/phy/psb6970.c
+++ b/drivers/net/phy/psb6970.c
@@ -70,16 +70,12 @@ struct psb6970_priv {
static u16 psb6970_mii_read(struct phy_device *phydev, int reg)
{
- struct mii_bus *bus = phydev->mdio.bus;
-
- return bus->read(bus, PHYADDR(reg));
+ return phydev->bus->read(phydev->bus, PHYADDR(reg));
}
static void psb6970_mii_write(struct phy_device *phydev, int reg, u16 val)
{
- struct mii_bus *bus = phydev->mdio.bus;
-
- bus->write(bus, PHYADDR(reg), val);
+ phydev->bus->write(phydev->bus, PHYADDR(reg), val);
}
static int
@@ -316,11 +312,11 @@ static int psb6970_config_init(struct ph
priv->phy = pdev;
- if (pdev->mdio.addr == 0)
+ if (pdev->addr == 0)
printk(KERN_INFO "%s: psb6970 switch driver attached.\n",
pdev->attached_dev->name);
- if (pdev->mdio.addr != 0) {
+ if (pdev->addr != 0) {
kfree(priv);
return 0;
}
@@ -388,14 +384,14 @@ static void psb6970_remove(struct phy_de
if (!priv)
return;
- if (pdev->mdio.addr == 0)
+ if (pdev->addr == 0)
unregister_switch(&priv->dev);
kfree(priv);
}
static int psb6970_fixup(struct phy_device *dev)
{
- struct mii_bus *bus = dev->mdio.bus;
+ struct mii_bus *bus = dev->bus;
u16 reg;
/* look for the switch on the bus */
@@ -419,12 +415,13 @@ static struct phy_driver psb6970_driver
.config_init = &psb6970_config_init,
.config_aneg = &psb6970_config_aneg,
.read_status = &psb6970_read_status,
+ .driver = {.owner = THIS_MODULE},
};
int __init psb6970_init(void)
{
phy_register_fixup_for_id(PHY_ANY_ID, psb6970_fixup);
- return phy_driver_register(&psb6970_driver, THIS_MODULE);
+ return phy_driver_register(&psb6970_driver);
}
module_init(psb6970_init);
--- a/drivers/net/phy/rtl8306.c
+++ b/drivers/net/phy/rtl8306.c
@@ -877,7 +877,7 @@ rtl8306_config_init(struct phy_device *p
int err;
/* Only init the switch for the primary PHY */
- if (pdev->mdio.addr != 0)
+ if (pdev->addr != 0)
return 0;
val.value.i = 1;
@@ -887,7 +887,7 @@ rtl8306_config_init(struct phy_device *p
priv->dev.ops = &rtl8306_ops;
priv->do_cpu = 0;
priv->page = -1;
- priv->bus = pdev->mdio.bus;
+ priv->bus = pdev->bus;
chipid = rtl_get(dev, RTL_REG_CHIPID);
chipver = rtl_get(dev, RTL_REG_CHIPVER);
@@ -933,13 +933,13 @@ rtl8306_fixup(struct phy_device *pdev)
u16 chipid;
/* Attach to primary LAN port and WAN port */
- if (pdev->mdio.addr != 0 && pdev->mdio.addr != 4)
+ if (pdev->addr != 0 && pdev->addr != 4)
return 0;
memset(&priv, 0, sizeof(priv));
priv.fixup = true;
priv.page = -1;
- priv.bus = pdev->mdio.bus;
+ priv.bus = pdev->bus;
chipid = rtl_get(&priv.dev, RTL_REG_CHIPID);
if (chipid == 0x5988)
pdev->phy_id = RTL8306_MAGIC;
@@ -957,14 +957,14 @@ rtl8306_probe(struct phy_device *pdev)
* share one rtl_priv instance between virtual phy
* devices on the same bus
*/
- if (priv->bus == pdev->mdio.bus)
+ if (priv->bus == pdev->bus)
goto found;
}
priv = kzalloc(sizeof(struct rtl_priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
- priv->bus = pdev->mdio.bus;
+ priv->bus = pdev->bus;
found:
pdev->priv = priv;
@@ -985,7 +985,7 @@ rtl8306_config_aneg(struct phy_device *p
struct rtl_priv *priv = pdev->priv;
/* Only for WAN */
- if (pdev->mdio.addr == 0)
+ if (pdev->addr == 0)
return 0;
/* Restart autonegotiation */
@@ -1001,7 +1001,7 @@ rtl8306_read_status(struct phy_device *p
struct rtl_priv *priv = pdev->priv;
struct switch_dev *dev = &priv->dev;
- if (pdev->mdio.addr == 4) {
+ if (pdev->addr == 4) {
/* WAN */
pdev->speed = rtl_get(dev, RTL_PORT_REG(4, SPEED)) ? SPEED_100 : SPEED_10;
pdev->duplex = rtl_get(dev, RTL_PORT_REG(4, DUPLEX)) ? DUPLEX_FULL : DUPLEX_HALF;
@@ -1044,6 +1044,7 @@ static struct phy_driver rtl8306_driver
.config_init = &rtl8306_config_init,
.config_aneg = &rtl8306_config_aneg,
.read_status = &rtl8306_read_status,
+ .driver = { .owner = THIS_MODULE,},
};
@@ -1051,7 +1052,7 @@ static int __init
rtl_init(void)
{
phy_register_fixup_for_id(PHY_ANY_ID, rtl8306_fixup);
- return phy_driver_register(&rtl8306_driver, THIS_MODULE);
+ return phy_driver_register(&rtl8306_driver);
}
static void __exit