From nobody Thu Apr 2 17:17:17 2026 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11010049.outbound.protection.outlook.com [52.101.84.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B3D7D3A6B93; Fri, 27 Mar 2026 18:49:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.84.49 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774637359; cv=fail; b=mdLfMAYypsgW+Ay7YwtXhIPjXNeFx6jTc893+CNVFuiDaOtc5U1CnPG5WHeh7SfUdaNgQkHn9nus2+dx4Zi6z+3kCMmQgRVnUl3sRuA3hv/VKkGAd4Rl9O2omMv+REWOiaWwk+x2kZO9NoTL+VfAeHBezAXaSyvCz1Jd+Pu8+dY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774637359; c=relaxed/simple; bh=hMDLRXdF1NigX4KqsQUQ4uKayzoPd9xA2A5p872A84I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=aBvJR4xPulv5m0TibsQ+2QWKwD26mVR8QxRwwVbZmuIKWqzhR+QOWHsIIN+Ywm+NcBYOvSbh1HsKUoHkv4fGG+vbJrGWpowjoQnXdG6iI1hP2pvDqvUfhWd3i2NbdpGST1Mve/URu10yBM8zs3fBjSRlZ3H49xUKF6OpK8zarR8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=VctTM9Ar; arc=fail smtp.client-ip=52.101.84.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="VctTM9Ar" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cFnyvFx+lFrnqIRV6qk//0oEH4vsyvOATlhm92XaU3ANxRmrDXXATBkCM6/hfuJdpQAyiX4Tj1SFg7KcljxC9sda++MiI+gMwCQe1jxMvIVMK3XO/t7q34s2B98nWkyLdPdyGQM7qaHfZxhC6mLCgYjZ1hqTUE7y7OMoTXgtGFPvxfXS4uoSd0y1b1ZOVOQQs2Sfmu0RKbRpNAu/gIka4TbaMSNjwnpJF7d/dWVx20VSNv/OpWiw//gFhtbsMHiau/I+3l/+QtM0nF/JvD2ogEFcOf7TIQHpLZ3xZzaWggc6uNg3eZ1NOOGAjuNxGupGnY607uTtBRyfuRLhVaIgRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=puL+Fop37MU0VjAvQTbetvUe0xe0cRUTa/Skh3MyxsY=; b=ypgWtCuY7FM3Am01jKrqIT9ECWfz5BmQf6z2fsozmBJQkkuHIEOjRPKeWpxbl92c8n5VgKcKNYEmi6oj8EoZDpmhgalIcwu74kjW9oXkJ+RHrdmHLffWXVZ9GJd0o9zVRCQM36furPiZhEct6nlS0rnAv6phi3BAXehf4aDAeyoNZ6NBjuK5coVHkplsEWrr/95ZGel6KaXxZwOew6xo6FalveVOg1b3vsluyTyLu1OHgjcggmysrZWBGgvaEgOAhDEgXlsyswdjIQdU6Rrn+TX6y1EuHYCArXAIg+zbPFJsJ+dEXK5cX1oc16ZoC8lAcLWlCiNNV2QBE/wAnokpCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=puL+Fop37MU0VjAvQTbetvUe0xe0cRUTa/Skh3MyxsY=; b=VctTM9Ar/aUsMO2Lv0GpqyC+lBhpQIE9xkyCFX83L/leNZROJ8fzzAk3/ISPl2yYITSAbZ3s/zZ27PeMZSCsmDIdLIxBIWxIHe3m4D+e6dVZnxWuHu6y5KPfjNkCUbNKfAeiY7WUR7PHom1TEkBO5oeuz8KP5kLliKI+bbmJfUjDsPE6dejik7njyG6OKGTGkn9fAeS8JJHtkTe3Scmgrj8nWXxeBIRqCot2ypVIFLVbal6xfJMGZIQQLLG/bLkRkdt2Gexfersa2gaHu8gTQTt4hliK5/pDWV9ITZ5TKEeNu/y8qmXb89vvKrxhK/D+zXd4FDUeZOi8acHkyoCXRw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8584.eurprd04.prod.outlook.com (2603:10a6:10:2db::24) by GV1PR04MB9515.eurprd04.prod.outlook.com (2603:10a6:150:24::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9745.20; Fri, 27 Mar 2026 18:49:12 +0000 Received: from DU2PR04MB8584.eurprd04.prod.outlook.com ([fe80::3f9d:4a01:f53c:952d]) by DU2PR04MB8584.eurprd04.prod.outlook.com ([fe80::3f9d:4a01:f53c:952d%5]) with mapi id 15.20.9745.019; Fri, 27 Mar 2026 18:49:12 +0000 From: Vladimir Oltean To: linux-phy@lists.infradead.org Cc: Vinod Koul , Neil Armstrong , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-can@vger.kernel.org, linux-gpio@vger.kernel.org, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-pci@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-scsi@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org, netdev@vger.kernel.org, spacemit@lists.linux.dev, UNGLinuxDriver@microchip.com, Markus Schneider-Pargmann , Andrzej Hajda , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Andy Yan , Marc Kleine-Budde , Vincent Mailhol , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Geert Uytterhoeven , Magnus Damm Subject: [PATCH v6 phy-next 18/28] phy: introduce phy_get_max_link_rate() helper for consumers Date: Fri, 27 Mar 2026 20:46:56 +0200 Message-ID: <20260327184706.1600329-19-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327184706.1600329-1-vladimir.oltean@nxp.com> References: <20260327184706.1600329-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: VI1PR07CA0286.eurprd07.prod.outlook.com (2603:10a6:800:130::14) To DU2PR04MB8584.eurprd04.prod.outlook.com (2603:10a6:10:2db::24) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8584:EE_|GV1PR04MB9515:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e6f0e54-0445-402a-7457-08de8c318966 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|7416014|376014|366016|1800799024|19092799006|56012099003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: RO+IMo6yWlwWMmICiq70CjKljgGqjGpQiqPfcY5cXZ1VvD1t6vpjIHtQpa2zNhimynz4zwoRm07mL7Y4UPL2kex3t/TRBnJlVcEksN/ADG48pha4tKaNXiTrDvT66MUHC8Xga2OQvR8xtkYCxYWAvcrLmbQHe9hnA2VNJFgdTG6E7mb2rlSYEuk+ffl7mZkDF5BcV2em3fWB+W0KiQS7w7z+gibrSru38VhAvfQNQeOO4f1tvJHLkVAZ5Wz57ig27GTWfGVwmew72wtyPII3irhO0zFI82CGgzF2mkesFyexzE6ApoTiKRcm/6sfEoCxiXp9QLlgpP59dm+Wb8FPjZ3vP0sqan6T/w7SdG5EXPnhGq+8PYIxo+yr91JgEOQiFeKjf01gIedqrB8FLSSPQWCYi5V5Fy/2Zpp+tRN6zUnSr0+vFl7oiuHeR8Uxl9osgORFkkRgnyXwzXVbW0/oCbRBvWbj5p+Vdss+WvzLKSK7EF8GkTByp45ugViMefBP3h3jWeyYPyHRm8JuiWCyyTDLwlobvGTG9R4ZkJu65gjoTaEE7DO3pEe3glKKj917ksOSO+ob8ZVDKOpW2WR5ZXd4e3UXathrzVZwQ4SfxG3vzHUg8EufEfP7bS7kr43AozUjVCmiOwnReKoPxg0JSM62jhsOBRAV3fnln+jsSaGMhF9sfAIkaEqvzFtwJt/KP11fJJw30GtFYXBjgxSntMmZPVglYTkTTCoZL1WjAQg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8584.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(10070799003)(7416014)(376014)(366016)(1800799024)(19092799006)(56012099003)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?us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fGbOG/pQPHA6b4cyLeOt/Molh+GvP6FHUnHJeXg2i9G?= X-MS-Exchange-AntiSpam-MessageData-1: k45uxCojwIYPittlq48uUaPcF6qFXnCmSz4= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e6f0e54-0445-402a-7457-08de8c318966 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8584.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Mar 2026 18:49:12.2153 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rQP9/NfU79yOuEeUXQKw241nAlB8H124DWdWl+cugMtZsiEhUxmIZq39DaSSVQZSATuwbNqOuNYZYUORqw3lUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9515 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Markus Schneider-Pargmann # m_can --- Cc: Andrzej Hajda Cc: Neil Armstrong Cc: Robert Foss Cc: Laurent Pinchart Cc: Jonas Karlman Cc: Jernej Skrabec Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Simona Vetter Cc: Andy Yan Cc: Marc Kleine-Budde Cc: Vincent Mailhol Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Claudiu Beznea Cc: Markus Schneider-Pargmann Cc: Geert Uytterhoeven Cc: Magnus Damm v3->v6: none v2->v3: collect tag v1->v2: make phy_get_bus_width() NULL-tolerant to simplify CAN callers --- drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 4 ++-- drivers/gpu/drm/bridge/synopsys/dw-dp.c | 2 +- drivers/net/can/at91_can.c | 3 +-- drivers/net/can/flexcan/flexcan-core.c | 3 +-- drivers/net/can/m_can/m_can_platform.c | 3 +-- drivers/net/can/rcar/rcar_canfd.c | 3 +-- drivers/phy/phy-core.c | 9 +++++++++ include/linux/phy/phy.h | 6 ++++++ 8 files changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c b/drivers/= gpu/drm/bridge/cadence/cdns-mhdp8546-core.c index a8b6ae58cb0a..ed7ed82ddb64 100644 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c @@ -1300,7 +1300,7 @@ static u32 cdns_mhdp_get_training_interval_us(struct = cdns_mhdp_device *mhdp, =20 static void cdns_mhdp_fill_host_caps(struct cdns_mhdp_device *mhdp) { - unsigned int link_rate; + u32 link_rate; =20 /* Get source capabilities based on PHY attributes */ =20 @@ -1308,7 +1308,7 @@ static void cdns_mhdp_fill_host_caps(struct cdns_mhdp= _device *mhdp) if (!mhdp->host.lanes_cnt) mhdp->host.lanes_cnt =3D 4; =20 - link_rate =3D mhdp->phy->attrs.max_link_rate; + link_rate =3D phy_get_max_link_rate(mhdp->phy); if (!link_rate) link_rate =3D drm_dp_bw_code_to_link_rate(DP_LINK_BW_8_1); else diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/brid= ge/synopsys/dw-dp.c index 4ab6922dd79c..79c72ee8e263 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c @@ -536,7 +536,7 @@ static int dw_dp_link_parse(struct dw_dp *dp, struct dr= m_connector *connector) =20 link->revision =3D link->dpcd[DP_DPCD_REV]; link->rate =3D min_t(u32, min(dp->plat_data.max_link_rate, - dp->phy->attrs.max_link_rate * 100), + phy_get_max_link_rate(dp->phy) * 100), drm_dp_max_link_rate(link->dpcd)); link->lanes =3D min_t(u8, phy_get_bus_width(dp->phy), drm_dp_max_lane_count(link->dpcd)); diff --git a/drivers/net/can/at91_can.c b/drivers/net/can/at91_can.c index 58da323f14d7..7749da0a58f6 100644 --- a/drivers/net/can/at91_can.c +++ b/drivers/net/can/at91_can.c @@ -1125,8 +1125,7 @@ static int at91_can_probe(struct platform_device *pde= v) =20 can_rx_offload_add_timestamp(dev, &priv->offload); =20 - if (transceiver) - priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; + priv->can.bitrate_max =3D phy_get_max_link_rate(transceiver); =20 if (at91_is_sam9263(priv)) dev->sysfs_groups[0] =3D &at91_sysfs_attr_group; diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexc= an/flexcan-core.c index f5d22c61503f..093e48b8da58 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -2210,8 +2210,7 @@ static int flexcan_probe(struct platform_device *pdev) priv->reg_xceiver =3D reg_xceiver; priv->transceiver =3D transceiver; =20 - if (transceiver) - priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; + priv->can.bitrate_max =3D phy_get_max_link_rate(transceiver); =20 if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) { priv->irq_boff =3D platform_get_irq(pdev, 1); diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can= /m_can_platform.c index 56da411878af..2a0f163a683a 100644 --- a/drivers/net/can/m_can/m_can_platform.c +++ b/drivers/net/can/m_can/m_can_platform.c @@ -131,8 +131,7 @@ static int m_can_plat_probe(struct platform_device *pde= v) goto probe_fail; } =20 - if (transceiver) - mcan_class->can.bitrate_max =3D transceiver->attrs.max_link_rate; + mcan_class->can.bitrate_max =3D phy_get_max_link_rate(transceiver); =20 priv->base =3D addr; priv->mram_base =3D mram_addr; diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_= canfd.c index eaf8cac78038..9062db48d477 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -1884,8 +1884,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd= _global *gpriv, u32 ch, priv->transceiver =3D transceiver; priv->channel =3D ch; priv->gpriv =3D gpriv; - if (transceiver) - priv->can.bitrate_max =3D transceiver->attrs.max_link_rate; + priv->can.bitrate_max =3D phy_get_max_link_rate(transceiver); priv->can.clock.freq =3D fcan_freq; dev_info(dev, "can_clk rate is %u\n", priv->can.clock.freq); =20 diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 0d0be494cfd7..737a760d97d1 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -647,6 +647,15 @@ void phy_set_bus_width(struct phy *phy, int bus_width) } EXPORT_SYMBOL_GPL(phy_set_bus_width); =20 +u32 phy_get_max_link_rate(struct phy *phy) +{ + if (!phy) + return 0; + + return phy->attrs.max_link_rate; +} +EXPORT_SYMBOL_GPL(phy_get_max_link_rate); + /** * _of_phy_get() - lookup and obtain a reference to a phy by phandle * @np: device_node for which to get the phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index a7e2432ca1ae..34b656084caf 100644 --- 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); #else static inline struct phy *phy_get(struct device *dev, const char *string) { @@ -256,6 +257,11 @@ static inline int phy_get_bus_width(struct phy *phy) static inline void phy_set_bus_width(struct phy *phy, int bus_width) { } + +static inline u32 phy_get_max_link_rate(struct phy *phy) +{ + return 0; +} #endif /* IS_ENABLED(CONFIG_GENERIC_PHY) */ =20 #endif /* __PHY_CONSUMER_H */ --=20 2.43.0