diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c index 11255460ecb9..528e255d1ffe 100644 --- a/drivers/net/phy/mdio-bitbang.c +++ b/drivers/net/phy/mdio-bitbang.c @@ -19,6 +19,9 @@ #include #include +#define MDIO_READ 2 +#define MDIO_WRITE 1 + #define MDIO_C45 (1<<15) #define MDIO_C45_ADDR (MDIO_C45 | 0) #define MDIO_C45_READ (MDIO_C45 | 3) @@ -212,6 +215,10 @@ struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl) bus->read = mdiobb_read; bus->write = mdiobb_write; bus->priv = ctrl; + if (!ctrl->override_op_c22) { + ctrl->op_c22_read = MDIO_READ; + ctrl->op_c22_write = MDIO_WRITE; + } return bus; } diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c index d85bc1a98647..13ec31e89e94 100644 --- a/drivers/net/phy/mdio-gpio.c +++ b/drivers/net/phy/mdio-gpio.c @@ -27,9 +27,6 @@ #include #include -#define MDIO_READ 2 -#define MDIO_WRITE 1 - struct mdio_gpio_info { struct mdiobb_ctrl ctrl; struct gpio_desc *mdc, *mdio, *mdo; @@ -139,9 +136,7 @@ static struct mii_bus *mdio_gpio_bus_init(struct device *dev, of_device_is_compatible(dev->of_node, "microchip,mdio-smi0")) { bitbang->ctrl.op_c22_read = 0; bitbang->ctrl.op_c22_write = 0; - } else { - bitbang->ctrl.op_c22_read = MDIO_READ; - bitbang->ctrl.op_c22_write = MDIO_WRITE; + bitbang->ctrl.override_op_c22 = 1; } dev_set_drvdata(dev, new_bus); diff --git a/include/linux/mdio-bitbang.h b/include/linux/mdio-bitbang.h index 8ae0b3835233..5016e6f60de3 100644 --- a/include/linux/mdio-bitbang.h +++ b/include/linux/mdio-bitbang.h @@ -33,6 +33,7 @@ struct mdiobb_ops { struct mdiobb_ctrl { const struct mdiobb_ops *ops; + unsigned int override_op_c22; u8 op_c22_read; u8 op_c22_write; };