From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F6AACD342F for ; Tue, 5 May 2026 10:07:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R5sRDgO8/76/s9f9by6DOCDUOB2Ib1AVjGCXp6EGedg=; b=D37sLU4e+DVNgPnywuCmW1eaUo +iIcOziwWTs2rp2Hr81y3FRCDgDDQDqgB/o5mPax3DrekpMtoycZng/JrS+QxLcn3g+pKVt7hV8WV G/bihDfTarc+XbLezeEHi/TPDiiwqJyeEhyuFaMFyBTkNyfVgX12v26cEYaUnwnNiuJdcpoyjQ2hr ifWiGivEC/jWorqah0B4r1gy1wnbnnzQXdEI5olOR6A02hGrUSwk71BZCP8DKIesOT9Xm+B2Cceva 2arhDXy5CU6BWfnoq4MOH6+V6cs2A4LNb8B5ReONOPAgL+Hwyeeuihq11imrGCGPWGZ70ByC14Fkd b1lYDR6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKCgx-0000000FnZx-28K7; Tue, 05 May 2026 10:07:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKCfl-0000000Flll-3iiR; Tue, 05 May 2026 10:06:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=MIME-Version:Content-Type: Content-Transfer-Encoding:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=R5sRDgO8/76/s9f9by6DOCDUOB2Ib1AVjGCXp6EGedg=; b=NXyZ8yUFIsqUFL9Wmknx5mp8ke 8m4WzrJUo/gqc3Bd9SFU7u6OZZIprpk9k8FASe+aa4TvmM92n9YtyTglpG3H2HoHm98fVBD7C/5FB /9cGH0vvOqwUZs4mVbx5ZE8pqFy7FMBbD1+q30D7DxVxDD5X3oi/kfKvi35WkgEeleycwMoRl3jc1 fIFdlfDuY7n6BsqJnReVOTe4J3kS30EpiqmZqZbXYYoJMB1s1gtRwhc6UEwb/buBqkxgsUlGzLIdx BxS09LaZ5yyHInTRJzNE904J2Rjr3pwgdC1PwT9UpdW5+NbwEWEcYh6WOYr6CaLC50D6Jw6PgTtkr VjODZEEQ==; Received: from mail-norwayeastazon11013038.outbound.protection.outlook.com ([40.107.159.38] helo=OSPPR02CU001.outbound.protection.outlook.com) by desiato.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wKCfh-0000000D7jp-0IxG; Tue, 05 May 2026 10:06:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RiqI4KQQqL2Up1v6PwzVqifqZVX0zjLonSbONAgKowxjKsvWwYjAElQw7qUkQ1x/6RR8C+9qtLbdfoT1Oi+y1wA9sg5Zlxs2KAMonz0HFqdcsfscftBkq+iS65Eo5Jb71gyP5MVGHx9tcEwAFfOJUG9b7auERNbCqUTPfTZKLJ7HHmQGsJoPfBN8TS28SfbAiz3GW5C+oUXEF7NOfi4g7Qb+HfVdeq0Gy9nN4MUi9fqybdGHDk9xh1nUR/ZeRC3NU2pw23w0/34+YS8M77Vo7HANEJ1YoIPF9PbH/2J//DJ9pBQhQ+g7iKE50/ML87YVHF2+HHtRPclKLRClZZFRjw== 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=R5sRDgO8/76/s9f9by6DOCDUOB2Ib1AVjGCXp6EGedg=; b=HT29hBh95S+l52xf7tTnDpocPpmRAQNtGXtIVHXeGj/hOm9rAHGFPYYmePHCf65xEmw3knbgcDp6ewJPlwAsILFIOEFj58FgvAUuJRMO78fNxYVLhliNpVbhjNy97F6LzDm5qJxkujGS3q6qLGUb+LnUJXimoUcL+oupdkT5CGQLMYXG5XR1ZYNfN5hZzezkXo3rK630kxwdAAeARQcyCBKsXbQ4VhykfEGXPV8h/CyZdpehsEBO6xWu3B7eemYv+LCe1Y/dfBhIeH/3swmmeB2ZUuUeSRtFHxZlyUJbXU39LQYHPHhBtNtTnm0kCr+NvdMXjqF9W/VujoAtdUqE6A== 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=R5sRDgO8/76/s9f9by6DOCDUOB2Ib1AVjGCXp6EGedg=; b=IKPL9rrg7Da9qOLxBykiXKAqnpsStY34RG9pqVopsJ4S8EvWOB5oaRxCPlx1Ap+o/TQiUebQeqPbfPG//J/3LAbnukIww+CK7+uKrapJC4a1no8GFGz3f1J+J3G5tBWOHtCSqo4bh6l88GCQIc/fsErBYflaOzlIQnoOEV7tThn9xCCvlI5Xeib9SI/yFTEqEtpL+4cyO9irGvonV0REIlKjTEIx+AfLGGOOHh49G9dodswqkvOzGD5ZBhw+wIHk4pQTs3BULl48p/EU/bGIh78iZrlqbGkvtlb8tcGkShT7pYgTyO77Xfehzjisg6CGEgXs/uYXAzXZXoNY5qlDDA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM9PR04MB8585.eurprd04.prod.outlook.com (2603:10a6:20b:438::13) by DB9PR04MB8363.eurprd04.prod.outlook.com (2603:10a6:10:24b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Tue, 5 May 2026 10:06:22 +0000 Received: from AM9PR04MB8585.eurprd04.prod.outlook.com ([fe80::f010:fca8:7ef:62f4]) by AM9PR04MB8585.eurprd04.prod.outlook.com ([fe80::f010:fca8:7ef:62f4%4]) with mapi id 15.20.9870.023; Tue, 5 May 2026 10:06:20 +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 , Geert Uytterhoeven , 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 , Magnus Damm Subject: [PATCH v8 phy-next 20/31] phy: introduce phy_get_max_link_rate() helper for consumers Date: Tue, 5 May 2026 13:05:12 +0300 Message-Id: <20260505100523.1922388-21-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260505100523.1922388-1-vladimir.oltean@nxp.com> References: <20260505100523.1922388-1-vladimir.oltean@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: FR2P281CA0049.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:92::9) To AM9PR04MB8585.eurprd04.prod.outlook.com (2603:10a6:20b:438::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8585:EE_|DB9PR04MB8363:EE_ X-MS-Office365-Filtering-Correlation-Id: 34320779-b733-4992-3422-08deaa8df4c7 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|376014|1800799024|19092799006|7416014|366016|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: PkXF2EQTzA1R7BkWyOAdNdkouP2SKDUJ9Eg2lSmw1pFJI3HWyJvN/zitXAgRpSUSwGnYkExo3mdvuOeeDmGjfbGuyZ7elqeiX0+Ox3A7QCSx0Zo9RIK707YeI5hS/8vlrrbr421AdAklytiP/KFxnNU2lPLsSIwt5DQznFVDLulTUplRxIU4KnsxzrG0tjrVk1mhrpCebnrhuXaUeDx5jFqfkYzUEJRW5I0Jcyb+VoSPKGhRXITioEaKNzvhQK3nBMISA2VXYXi3aWucRCJQPwe2AhlB2q+jr5mOXn9I4B9NoeBOkb2DkQp3o4a1eb8fgvizgPor+zvlQ/a5zO8V3mcxK6Zlc2srDEw0PZl/oaTIYstlid0EP1bWS4fAs9ceiU4d399V2Ibv/i5j1Nsl8JSUwP2RUXv6u8C+itXXIHeaO65dVBI0yc+6Y46FDjx4itNmb7Sjj6VlhXTEO3qGQY4I1/NyD0C6HozHkkVcYB+qoJ3DovqkrsgP4484n2gQ9mY5jLQ/MiMMJrgB1eMvg1OGRbkgt8idsat+GpfbQgAJcIHDHradtQRK5Iyx+z0R6YKRMvq3l3V3rCJ0/za7XMa7+/KZ8cl6lBG1QBtkwZNERqum4Kk2+bAy/59wBP6hvo+OtWEFIloF2HIDV/JnYYxxMWkRUpwSzp/GWyV8KYQNpk6GQDDhx20kjaLggJv5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR04MB8585.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(19092799006)(7416014)(366016)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?heKNdp91rcxSmoOzFldFXT16Y2C1VgElaqNvGb+cJ6+61JzGKujrTm94k8hP?= =?us-ascii?Q?PqWVQj0rL2Koxs6PMDiM5opCtiiI22ukeJ89KU2CNyFpU/9R/0QkxCTASdnG?= =?us-ascii?Q?3wDhzkdTBkljMRFlxoyVUlybN/VAe5utNPBFbhnheqY2wqvEdMHk7JronA24?= =?us-ascii?Q?hU07m3eJ8/9m/FvOR6jNWqjZTKQ2k/J+SRMA/+FAWY1ITzDmQ9UfoAqPy/Hp?= =?us-ascii?Q?cpTfjU3mEBNGoxwYWGAZ7nn54Ji5wTqygz8vmG4KZxogfOjgQDlPbFUTPfrV?= =?us-ascii?Q?iZJnLN/HetsZT0uujaU1JvCCYw1n3f4dBBM4cWACLhgNOXv/2bgFXsYBfen2?= =?us-ascii?Q?TrWJA/3a0jFi2BfSGeHC5+tW+PuBno9PRYeOH1O5Azm4BkXqFstA0D9yhVtR?= =?us-ascii?Q?OQhje37Y47YMxFvoJIfwjKEXDizS1EeDo26in/zOl2ZxOa4TrrhIOxiTVwa1?= =?us-ascii?Q?0JBIbAHRIISX1yeC0xNW11PqBz5h2zLagHw/iy7hQVopsjIsLD0UAeNWH3aT?= =?us-ascii?Q?HZxCVKgRU1IxVIGU+5lUn5FUlZtlow0i2v1pz7OLte1QojiPg6DPFMZsDA4O?= =?us-ascii?Q?pc6jaucDXazAhnhDwHfKTZcKG24LK5C5yFrSygPPj3zt1O3NiJEjYmwwDbn8?= =?us-ascii?Q?l5Dlef39CB+ChPsFNUIB4EXRKMioS5c3kIYL9q4BbDgdvoAWHx2eOtR9tBo2?= =?us-ascii?Q?6oL8+ctMwkzEbwMb9N7HBO2GTtNVSPtBAI/SdFTc8b0l2SXqHHndZoyecEmx?= =?us-ascii?Q?KMc643p9D85/nHfG/OYdLq2fr4NeX6qZuKTr+ufd7cFMAqasNJK9XXnaCrbu?= =?us-ascii?Q?HCPd8eF2tenS6n0AjLg6NYXnIqlmRlcIq0Bh/YwG5cwOIMf+Uo2h9z6bzEVj?= =?us-ascii?Q?hP0x7pXP/Cb4ta1jxkrl+oJd51DE9DTfqbOziBaAeLk1LI0AYk/j1dHPwMlt?= =?us-ascii?Q?nzpLzTj3GDVLD20Pp+iMtrj9JsmPDKSg0n21WT43wxhqSAm0qtMSsX7ssc2b?= =?us-ascii?Q?nsOE+epXRzFG09Y9ydvmQ7G0x37NQEyDPfIneMy4BKmmplf+wUBD7imRErY5?= =?us-ascii?Q?gIHjanlhO1NRJcGXokWt+TEO5ykpNaQ2SzWu+UODYA3F+DOZ9hzRJq7T0sPG?= =?us-ascii?Q?h44lB/q5jpNt5CXLbHr0c4vRIcao7yBml8tq3rc9AQ+QzxHGZPbq4UcbXeTT?= =?us-ascii?Q?I/1kc+YOUPRnKvsOQwdTlGC+mmYDl7RLEyYNELDWtuThqCcmRQMIhwkAugl/?= =?us-ascii?Q?O0GuR7EsJSlpijZOEnBJc8K8jH1hJMFQI/AD6nV44G6zV4mVLrdYgATZYA7p?= =?us-ascii?Q?B/u+dS+MJsNDRM6SGgsqzXpQqhPQPsvAS/zyrHNCk0MsUkNts/lEqv1UVc5y?= =?us-ascii?Q?rZ6ZxQNTGmUHWDK7Rhfz4sq6szMNdS6AvTtDZ1iC6JBSY2mPXi15gBNOZ++D?= =?us-ascii?Q?Gs49N4lGZReP/BHtiaiIha/HMDBrrGk9iCMR/uNJdu/Dne3JLaKqSTKGv7zR?= =?us-ascii?Q?xRjDR+sR+YVTcBsdPQf4lpHiJNxHcTvOXC1fH6B1CBzJdqbg5vqNqJuJiYIq?= =?us-ascii?Q?Bgx6g+nx9yXUl7zs/mZ4tcE5LpMeODs4IQuj8UFCUg6wY+DyYhVWAPiZk2zr?= =?us-ascii?Q?PTeuNXw6Qt6N1adexKB6eHHfp0E7G6OjEK1NaHv+S4/6Z+D1uDtYDQEH5K5r?= =?us-ascii?Q?rMhioTDZZqueK4NGn+0PJw8UBK/tpeEutBD1pRsMcKumRVmriHLDtl2a3+ZR?= =?us-ascii?Q?KQPBL47Vag=3D=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34320779-b733-4992-3422-08deaa8df4c7 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8585.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2026 10:06:20.9360 (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: Lj6mTfmaJwTZD/kK1BNfcHCNpUjwzlz0/LaBzbDi5okPmGBjN9f1ruV1nezAPtokgaDRycUyE0Xv3YSEUPmuTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8363 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260505_110633_404626_07257C79 X-CRM114-Status: GOOD ( 15.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Acked-by: Geert Uytterhoeven # rcar_canfd --- 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 v7->v8: make "struct phy *" argument const v3->v7: 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 d20c0f8ad04c..87847978c1fb 100644 --- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c +++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c @@ -1296,7 +1296,7 @@ static u32 cdns_mhdp_get_training_interval_us(struct cdns_mhdp_device *mhdp, static void cdns_mhdp_fill_host_caps(struct cdns_mhdp_device *mhdp) { - unsigned int link_rate; + u32 link_rate; /* Get source capabilities based on PHY attributes */ @@ -1304,7 +1304,7 @@ static void cdns_mhdp_fill_host_caps(struct cdns_mhdp_device *mhdp) if (!mhdp->host.lanes_cnt) mhdp->host.lanes_cnt = 4; - link_rate = mhdp->phy->attrs.max_link_rate; + link_rate = phy_get_max_link_rate(mhdp->phy); if (!link_rate) link_rate = 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/bridge/synopsys/dw-dp.c index 45b37885d719..137ea6679732 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c @@ -530,7 +530,7 @@ static int dw_dp_link_parse(struct dw_dp *dp, struct drm_connector *connector) link->revision = link->dpcd[DP_DPCD_REV]; link->rate = 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 = 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 *pdev) can_rx_offload_add_timestamp(dev, &priv->offload); - if (transceiver) - priv->can.bitrate_max = transceiver->attrs.max_link_rate; + priv->can.bitrate_max = phy_get_max_link_rate(transceiver); if (at91_is_sam9263(priv)) dev->sysfs_groups[0] = &at91_sysfs_attr_group; diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/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 = reg_xceiver; priv->transceiver = transceiver; - if (transceiver) - priv->can.bitrate_max = transceiver->attrs.max_link_rate; + priv->can.bitrate_max = phy_get_max_link_rate(transceiver); if (priv->devtype_data.quirks & FLEXCAN_QUIRK_NR_IRQ_3) { priv->irq_boff = 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 *pdev) goto probe_fail; } - if (transceiver) - mcan_class->can.bitrate_max = transceiver->attrs.max_link_rate; + mcan_class->can.bitrate_max = phy_get_max_link_rate(transceiver); priv->base = addr; priv->mram_base = 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 = transceiver; priv->channel = ch; priv->gpriv = gpriv; - if (transceiver) - priv->can.bitrate_max = transceiver->attrs.max_link_rate; + priv->can.bitrate_max = phy_get_max_link_rate(transceiver); priv->can.clock.freq = fcan_freq; dev_info(dev, "can_clk rate is %u\n", priv->can.clock.freq); diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 6cd33204d2ff..8707111c4666 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -675,6 +675,15 @@ int phy_request_bus_width(struct phy *phy, int bus_width) } EXPORT_SYMBOL_GPL(phy_request_bus_width); +u32 phy_get_max_link_rate(const 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 99d3d65da614..e65865b4acfe 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); int phy_request_bus_width(struct phy *phy, int bus_width); +u32 phy_get_max_link_rate(const struct phy *phy); #else static inline struct phy *phy_get(struct device *dev, const char *string) { @@ -260,6 +261,11 @@ static inline int phy_request_bus_width(struct phy *phy, int bus_width) return -ENOSYS; } + +static inline u32 phy_get_max_link_rate(const struct phy *phy) +{ + return 0; +} #endif /* IS_ENABLED(CONFIG_GENERIC_PHY) */ #endif /* __PHY_CONSUMER_H */ -- 2.34.1