netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/4] net: ethernet: renesas: rswitch: Simplify struct phy * handling
Date: Fri, 27 Jan 2023 09:34:39 +0100	[thread overview]
Message-ID: <CAMuHMdXGNWZ6NQxFKKJ-aWKO6YG=dD+jeJynDyK9XZNRx=hgJA@mail.gmail.com> (raw)
In-Reply-To: <20230127014812.1656340-3-yoshihiro.shimoda.uh@renesas.com>

Hi Shimoda-san,

On Fri, Jan 27, 2023 at 2:49 AM Yoshihiro Shimoda
<yoshihiro.shimoda.uh@renesas.com> wrote:
> Simplify struct phy *serdes handling by keeping the valiable in
> the struct rswitch_device.
>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Thanks for your patch!

> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -1222,49 +1222,40 @@ static void rswitch_phylink_deinit(struct rswitch_device *rdev)
>         phylink_destroy(rdev->phylink);
>  }
>
> -static int rswitch_serdes_set_params(struct rswitch_device *rdev)
> +static int rswitch_serdes_phy_get(struct rswitch_device *rdev)
>  {
>         struct device_node *port = rswitch_get_port_node(rdev);
>         struct phy *serdes;
> -       int err;
>
>         serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL);
>         of_node_put(port);
>         if (IS_ERR(serdes))
>                 return PTR_ERR(serdes);

You may as well just return serdes...

> +       rdev->serdes = serdes;

... and move the above assignment into the caller.
That would save one if (...) check.

After that, not much is left in this function, so I'm wondering if it
can just be inlined at the single callsite?

BTW, there seem to be several calls to rswitch_get_port_node(), which
calls into DT tree traversal, so you may want to call it once, and store
a pointer to the port device node, too.  Then rswitch_serdes_phy_get()
becomes a candidate for manual inlining for sure.

> +
> +       return 0;
> +}
> +
> +static int rswitch_serdes_set_params(struct rswitch_device *rdev)
> +{
> +       int err;
>
> -       err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET,
> +       err = phy_set_mode_ext(rdev->serdes, PHY_MODE_ETHERNET,
>                                rdev->etha->phy_interface);
>         if (err < 0)
>                 return err;
>
> -       return phy_set_speed(serdes, rdev->etha->speed);
> +       return phy_set_speed(rdev->serdes, rdev->etha->speed);
>  }
>
>  static int rswitch_serdes_init(struct rswitch_device *rdev)
>  {
> -       struct device_node *port = rswitch_get_port_node(rdev);
> -       struct phy *serdes;
> -
> -       serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL);
> -       of_node_put(port);
> -       if (IS_ERR(serdes))
> -               return PTR_ERR(serdes);
> -
> -       return phy_init(serdes);
> +       return phy_init(rdev->serdes);
>  }

As this is now a one-line function, just call phy_init() in all
callers instead?

>
>  static int rswitch_serdes_deinit(struct rswitch_device *rdev)
>  {
> -       struct device_node *port = rswitch_get_port_node(rdev);
> -       struct phy *serdes;
> -
> -       serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL);
> -       of_node_put(port);
> -       if (IS_ERR(serdes))
> -               return PTR_ERR(serdes);
> -
> -       return phy_exit(serdes);
> +       return phy_exit(rdev->serdes);
>  }

Just call phy_exit() in all callers instead?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2023-01-27  8:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-27  1:48 [PATCH net-next v3 0/4] net: ethernet: renesas: rswitch: Modify initialization for SERDES and PHY Yoshihiro Shimoda
2023-01-27  1:48 ` [PATCH net-next v3 1/4] net: phylink: Set host_interfaces for a non-sfp PHY Yoshihiro Shimoda
2023-01-27  1:48 ` [PATCH net-next v3 2/4] net: ethernet: renesas: rswitch: Simplify struct phy * handling Yoshihiro Shimoda
2023-01-27  8:34   ` Geert Uytterhoeven [this message]
2023-01-27 10:49     ` Yoshihiro Shimoda
2023-01-27  1:48 ` [PATCH net-next v3 3/4] net: ethernet: renesas: rswitch: Enable ovr_host_interfaces Yoshihiro Shimoda
2023-01-27  1:48 ` [PATCH net-next v3 4/4] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Yoshihiro Shimoda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMuHMdXGNWZ6NQxFKKJ-aWKO6YG=dD+jeJynDyK9XZNRx=hgJA@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).