[PATCH v7 phy-next 17/27] phy: introduce phy_get_max_link_rate() helper for consumers
Geert Uytterhoeven
geert at linux-m68k.org
Thu Apr 30 04:59:53 PDT 2026
Hi Vladimir,
On Thu, 30 Apr 2026 at 13:07, Vladimir Oltean <vladimir.oltean at nxp.com> wrote:
> Consumer drivers shouldn't dereference struct phy, not even to get to
> its attributes.
>
> We have phy_get_bus_width() as a precedent for getting the bus_width
> attribute, so let's add phy_get_max_link_rate() and use it in DRM and
> CAN drivers.
>
> In CAN drivers, the transceiver is acquired through devm_phy_optional_get()
> and NULL is given by the API as a non-error case, so the PHY API should
> also tolerate NULL coming back to it. This means we can further simplify
> the call sites that test for the NULL quality of the transceiver.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean at nxp.com>
> Acked-by: Markus Schneider-Pargmann <msp at baylibre.com> # m_can
Thanks for your patch!
> drivers/net/can/rcar/rcar_canfd.c | 3 +--
Acked-by: Geert Uytterhoeven <geert+renesas at glider.be> # rcar_canfd
> --- a/include/linux/phy/phy.h
> +++ b/include/linux/phy/phy.h
> @@ -57,6 +57,7 @@ int phy_notify_disconnect(struct phy *phy, int port);
> int phy_notify_state(struct phy *phy, union phy_notify state);
> int phy_get_bus_width(struct phy *phy);
> void phy_set_bus_width(struct phy *phy, int bus_width);
> +u32 phy_get_max_link_rate(struct phy *phy);
This (and all the existing getters) should take a "const struct phy *".
> #else
> static inline struct phy *phy_get(struct device *dev, const char *string)
> {
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at 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
More information about the linux-phy
mailing list