diff mbox series

[25/30] net: eepro100: Pass device private data into mdiobus

Message ID 20200523163837.407592-25-marek.vasut+renesas@gmail.com
State New
Headers show
Series [01/30] net: eepro100: Remove EEPRO100_SROM_WRITE | expand

Commit Message

Marek Vasut May 23, 2020, 4:38 p.m. UTC
Instead of doing ethernet device lookup by name every time there
is an MDIO access, pass the driver private data via mdiobus priv
to the MDIO bus accessors.

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
---
 drivers/net/eepro100.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Ramon Fried May 23, 2020, 5:23 p.m. UTC | #1
On Sat, May 23, 2020 at 7:44 PM Marek Vasut <marek.vasut at gmail.com> wrote:
>
> Instead of doing ethernet device lookup by name every time there
> is an MDIO access, pass the driver private data via mdiobus priv
> to the MDIO bus accessors.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
> ---
>  drivers/net/eepro100.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
> index 1c33ec3da2..78dedbdcc9 100644
> --- a/drivers/net/eepro100.c
> +++ b/drivers/net/eepro100.c
> @@ -309,9 +309,7 @@ static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr)
>  static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
>                                 int reg)
>  {
> -       struct eth_device *dev = eth_get_dev_by_name(bus->name);
> -       struct eepro100_priv *priv =
> -               container_of(dev, struct eepro100_priv, dev);
> +       struct eepro100_priv *priv = bus->priv;
>         unsigned short value = 0;
>         int ret;
>
> @@ -331,9 +329,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
>  static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
>                                  int reg, u16 value)
>  {
> -       struct eth_device *dev = eth_get_dev_by_name(bus->name);
> -       struct eepro100_priv *priv =
> -               container_of(dev, struct eepro100_priv, dev);
> +       struct eepro100_priv *priv = bus->priv;
>         int ret;
>
>         ret = verify_phyaddr(priv, addr);
> @@ -486,6 +482,7 @@ static int eepro100_initialize_mii(struct eepro100_priv *priv)
>         strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN);
>         mdiodev->read = eepro100_miiphy_read;
>         mdiodev->write = eepro100_miiphy_write;
> +       mdiodev->priv = priv;
>
>         ret = mdio_register(mdiodev);
>         if (ret < 0) {
> --
> 2.25.1
>
Reviewed-By: Ramon Fried <rfried.dev at gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/eepro100.c b/drivers/net/eepro100.c
index 1c33ec3da2..78dedbdcc9 100644
--- a/drivers/net/eepro100.c
+++ b/drivers/net/eepro100.c
@@ -309,9 +309,7 @@  static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr)
 static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
 				int reg)
 {
-	struct eth_device *dev = eth_get_dev_by_name(bus->name);
-	struct eepro100_priv *priv =
-		container_of(dev, struct eepro100_priv, dev);
+	struct eepro100_priv *priv = bus->priv;
 	unsigned short value = 0;
 	int ret;
 
@@ -331,9 +329,7 @@  static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,
 static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,
 				 int reg, u16 value)
 {
-	struct eth_device *dev = eth_get_dev_by_name(bus->name);
-	struct eepro100_priv *priv =
-		container_of(dev, struct eepro100_priv, dev);
+	struct eepro100_priv *priv = bus->priv;
 	int ret;
 
 	ret = verify_phyaddr(priv, addr);
@@ -486,6 +482,7 @@  static int eepro100_initialize_mii(struct eepro100_priv *priv)
 	strncpy(mdiodev->name, priv->name, MDIO_NAME_LEN);
 	mdiodev->read = eepro100_miiphy_read;
 	mdiodev->write = eepro100_miiphy_write;
+	mdiodev->priv = priv;
 
 	ret = mdio_register(mdiodev);
 	if (ret < 0) {