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 3FB3FCD13D2 for ; Thu, 30 Apr 2026 11:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=b7CKXwd+gjhDTM2zCCuC9ulHgs52mXsh8DTLPR5JOKE=; b=lDn7wwPop2lO8W F6u6nqRxamjjFeyCixxhh0tHvtKqplUgQtA4g9M73uGCRj11WPmI25QCIaOu2HJ81tg+SfZuIdRaU 9TFQ4pX2tpAGZrFdNe0cxXfUmjuBxfewbJaZX6/RFsfoUXTq3Lt1TupgkT1H5HMO4gJ/z22F4oWui RWaostPltLAZHfmPFnNdkn7LXKX8fZ7rUetoHGB2fMaqtKVMoYjQKOrWfZsbDcYCQvIUO5jnSe540 Q3XPo+8JcaKu02jkwvXEzJV2vZigaaHjfWLkKAYEAv0my1P7bfzqxvi4XOdNGEQR5RX4TPHeR7qHL JFaYq6R7BwHlRkgsGDCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wIPFz-00000005HMJ-1yFJ; Thu, 30 Apr 2026 11:08:35 +0000 Received: from mail-westeuropeazon11013037.outbound.protection.outlook.com ([52.101.72.37] helo=AM0PR02CU008.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wIPF0-00000005G2z-2Weu; Thu, 30 Apr 2026 11:07:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O3BKgWGHAHAbStytQpD473qHz9JsCtp3LgHcdFFPWgIfLUruFhAbBFa/gOU5eFsKM0hQSvc8IXFLRvZ/7HTSIiz3nSp/UUhw3cac2Lf9KEEfur3Db07w92FJ07ojwsYnI5YeqDYMlRjWx+Y+7brDOP3QYFLlDTI46/5ol0IOMSWDT0kk63EnYZL5ETk91qv1e9+HjkWnjw4q057wOmD/2W4g0Py7QAlqG257zX1JTfV0+77EPFQvaiihQMP6ni/CJHqBQuW/umWmvlrRqoFSRxpWV54LdCGcWbGeVlPNZ0qWzUybW5LeIyYEPzCd6MH4Rt0cjc83G/io496lhe+qVQ== 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=G5FCjmEG1XDGz3sCPq9VXRXcsutJAgvtv8mVJdpgqgo=; b=tQg2osPf6RWRe7vuaKRvc6QOMphBhilDAqEnzWzCyXPIYcEb6nhxSQAOgj1vK8Ir0yTM+l1vZsXww/mnilPnJLkovXEZaU1pTN0JBOw4Cyhbb9LzKckos/IK5qXhXwGOF7eIxEfDVgWFMNsITtW1HlZHB4m1gsfY1BVVKdXaLGqhqYpoI0Gveap2hmqHO+gWTvkOQWSMvwvmhL4LEdilono11RMEg+Xp6hbjrdbp7g3IQrjh5Xci3TZbWBD6ho2Cs2ksG2WTQPQH+QLAK5F7fIwTcdaUUrYY1vHgH+CrNuN/MywPVGOEXpi1I8ejYKDc5PrdEQ1oadstaVhHVK9Qng== 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=G5FCjmEG1XDGz3sCPq9VXRXcsutJAgvtv8mVJdpgqgo=; b=UMBFweKFxaHFLRqnCq42ai/dLrol9kBw8noQVypRevSjvZ53U5fMdcExa+J9z4Yl+9yiTlrUtTZRbsCDU99bmSO+d9y/hVwMI1AJGlx/Ou51j4dRbeV37+3itK7iWGx9yKpjlp/TNEL12ryRU2OVNAYvOy/2U7Unp+kJxYE9S7GJhp4GOMNH9rY3K9oVX3D2OE3gzSGNJa4rhiuJB0aKoWMrgGeAe0yPNxj+VeCC5WYJCa+8aqnxpYO3pUXn6aKMJpL5WTmgsK5M7vG7Zpq0s1TN5op4VbFxhmv9vo4LGfWGH+HCf5DJ5x2ltgMH6pTecXOiR+AyZwi2a0NAEtXdNA== 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 VI1PR04MB7182.eurprd04.prod.outlook.com (2603:10a6:800:121::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.20; Thu, 30 Apr 2026 11:07:21 +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.9846.025; Thu, 30 Apr 2026 11:07:21 +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, Greg Kroah-Hartman , JC Kuo , Johan Hovold , Jonathan Hunter , Mathias Nyman , Thierry Reding Subject: [PATCH v7 phy-next 14/27] usb: gadget: tegra-xudc: avoid direct dereference of phy->dev.of_node Date: Thu, 30 Apr 2026 14:06:39 +0300 Message-Id: <20260430110652.558622-15-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260430110652.558622-1-vladimir.oltean@nxp.com> References: <20260430110652.558622-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AM0PR10CA0004.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:17c::14) To AM9PR04MB8585.eurprd04.prod.outlook.com (2603:10a6:20b:438::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR04MB8585:EE_|VI1PR04MB7182:EE_ X-MS-Office365-Filtering-Correlation-Id: e5e892bb-aad7-4e75-7375-08dea6a8a650 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|10070799003|7416014|376014|366016|19092799006|1800799024|18002099003|56012099003|22082099003; X-Microsoft-Antispam-Message-Info: Vjxm4dT4YyrAAns68Zk2tH54RuyQO39C91uPBT8f0gJz7f95Yzt1H6bSZNDv7S3jrD64N/liAlRMnr7uqw3MZ0/COe0b2WYOp9i90bRAKOmsTG/KLPHJLZ/7M8BLp0vITL2MtwHExZEeY2Ho7ramZ4fYFNotfW/nMU55bbQP8NZLhoz624hOtsdXFZfgLwYjOEU1zfcNssoXnzfL+r92LOKoPQyJ89iRstr+Ky9reM1s6Z+gerU166pZCirWYw5j+/iMWIYKyxAfmPjPhBm0T6NYju+wqJOnvH05JTkadM+rAB2zlsBIYQ0k2//7Q1jkgpdW5CCskUNOZ3LBm1D9rUXlr2nXLf9OsIgr4I0pAUTzTCY+/SM3GSYcy9TUGmi/ZzlJxFO6eOZo+6gWzoyaWrBfCg3NLZmJI5NjrBOgz3lprgjrvxu69xl174+NeSJ07zo3EL7lldE3dWyF19eDcKy500c2QPH9G3B8u6GYYpKfZoZ3D569Phh3/KtONs17WOmzkZp6lZ4x8x3GMRwzf4IuWnfvkIkv1JekjvMSTGDoSkL3BlwhBN+3MnumZCmZ+BUKysVDg6z5qZPjAaAPTqV8tA7nCYcRws0u5xpcTn9p03wnRWnCXRgaLZ5VvsAJVqRAZ5TzMUBWOIB3SNUGu6MbHMlgzEPwvN3gQ18BGP0NQ41lnWbLCmPLQoLwOhqA4r5foqI5UyQTVqcW1A9xFnQO76dm9cEXGaNqtx8sBn4= 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)(10070799003)(7416014)(376014)(366016)(19092799006)(1800799024)(18002099003)(56012099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?GOSUmq02vXVyKIg667nUdJkomAM/j9xzmmGgg8x27Ib0TX/e/NZZwFpRGKaD?= =?us-ascii?Q?LnGpoEx0dx/Rjj1R7/nl5/L5cKm//bCGBdGpLX2jmYW/pGN/pj0pND+PjiIX?= =?us-ascii?Q?EZ5iE+oS6cmiFApOfQOEbIDLL+FFMABMGSxOUx7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YgaNpB6/J/m5xrIW2TXYWaAE/jCgNjhZAWMSKTR?= =?us-ascii?Q?dH/y5wWjTf36uP4bKYHA+XBeM/6CmoXQpPg15kJe99OZnmdMPsZ2KnRt6jST?= =?us-ascii?Q?S3hU7pHGsnRQXD9l8g5pdVuU5NqKKiEJQ8B2seRcIBDyLpPSQ4bXPrdTRhBP?= =?us-ascii?Q?lAlRlZMKwFdkvyyav2StpSd6T7jdYJbtxuvT8IFiHEls1fwOwTArYEtsdCn/?= =?us-ascii?Q?jF2E8W8Mc48K289K4J3kGEwMkM1xIhhcjAhVdayMoIyxRpsXfiPZcFZjxvzf?= =?us-ascii?Q?I1Kj5BoQs3osUdp7tMjRLgVYdJjyPYUW3yV3AhaCU+RJ7rGDjBlTLbyQvxgi?= =?us-ascii?Q?RHnfaxynMnUKQXnkkRZKXHE7cjff5HbXHff8wptB9l0nSIbjJpaxCy5R9dbs?= =?us-ascii?Q?8qkRst8PKUtxj340aI2SZpm88NP8xqxCTZpMXwKRg+jonSZmfIqVVhscInv0?= =?us-ascii?Q?+XEb+RWp9k0Yz+hgiAvWqDt0Nyy4dcJ+LvOGjZyF2S1/VNC/PnQJW2kgk0gh?= =?us-ascii?Q?HaeljTyDUgv09qOKXoBo5uF65FjY9AvaAb5If/6il5ziARCXlgIxiKGCHf2J?= =?us-ascii?Q?QKqXnGxTjrgaqbD/ii7VG4noq/sf4CAVqDJIalnPO1S434AjYIOTGFVzRKV4?= =?us-ascii?Q?G8MbzT0VanE/QZ9MoJ7SCTg/5R3iIk+iMKcLpiypTi1oFBHlOWpTx04bjVNx?= =?us-ascii?Q?gr8/hd9eiMwV/G2TrFjjJ/AVvHp0IKrSvBiwalYjIEGcknozCUiX?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5e892bb-aad7-4e75-7375-08dea6a8a650 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8585.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2026 11:07:20.9807 (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: x8EGf2P8v4K0XOZvRQI+9IBdZ+H+sDVngmOBs60CmjT9R1w/swBSVhiNG+zSanxsx5FpWwSMaByuhI+6CXtAOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7182 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260430_040734_674432_63FD2911 X-CRM114-Status: GOOD ( 19.95 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org In a somewhat similar situation as the Tegra USB host controller driver, the Tegra XUDC driver for USB gadget mode needs to get to a struct usb_phy that sits behind the same OF node as the Generic PHY. It does that directly, which will no longer be possible. The PHY provider is also the xusb padctl driver. The rework here is also to implement a parallel OF node lookup path based on the "phys" phandle and the #phy-cells of the padctl provider. Some further notes: - create a local "usbphy" variable to hold the devm_usb_get_phy_by_node() output. This makes the error checks more obvious (avoids keeping an error-encoded pointer in xudc->usbphy[i] even temporarily). - the "if (IS_ERR(utmi_phy)) .. else if (utmi_phy) .. else if (!utmi_phy)" pattern can be simplified, considering that neither the IS_ERR() nor the NULL case continue execution in the current block. Therefore, we can move the case where the "utmi_phy" is a valid pointer outside the "if" checks, and this reduces the code indentation level. Signed-off-by: Vladimir Oltean --- Cc: Greg Kroah-Hartman Cc: JC Kuo Cc: Johan Hovold Cc: Jonathan Hunter Cc: Mathias Nyman Cc: Thierry Reding v5->v7: none v4->v5: patch is new --- drivers/usb/gadget/udc/tegra-xudc.c | 35 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c index e9d33be02866..cf4e6c87e44d 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -3494,6 +3494,7 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc) static int tegra_xudc_phy_get(struct tegra_xudc *xudc) { + struct device_node *np = dev_of_node(xudc->dev); int err = 0, usb3_companion_port; unsigned int i, j; @@ -3515,7 +3516,10 @@ static int tegra_xudc_phy_get(struct tegra_xudc *xudc) xudc->vbus_nb.notifier_call = tegra_xudc_vbus_notify; for (i = 0; i < xudc->soc->num_phys; i++) { + struct of_phandle_args args; char phy_name[] = "usb.-."; + struct usb_phy *usbphy; + int index, err; /* Get USB2 phy */ snprintf(phy_name, sizeof(phy_name), "usb2-%d", i); @@ -3525,22 +3529,31 @@ static int tegra_xudc_phy_get(struct tegra_xudc *xudc) dev_err_probe(xudc->dev, err, "failed to get PHY for phy-name usb2-%d\n", i); goto clean_up; - } else if (xudc->utmi_phy[i]) { - /* Get usb-phy, if utmi phy is available */ - xudc->usbphy[i] = devm_usb_get_phy_by_node(xudc->dev, - xudc->utmi_phy[i]->dev.of_node, - NULL); - if (IS_ERR(xudc->usbphy[i])) { - err = PTR_ERR(xudc->usbphy[i]); - dev_err_probe(xudc->dev, err, - "failed to get usbphy-%d\n", i); - goto clean_up; - } } else if (!xudc->utmi_phy[i]) { /* if utmi phy is not available, ignore USB3 phy get */ continue; } + index = of_property_match_string(np, "phy-names", phy_name); + if (index < 0) + continue; + + err = of_parse_phandle_with_args(np, "phys", "#phy-cells", + index, &args); + if (err) + continue; + + /* Get usb-phy, if utmi phy is available */ + usbphy = devm_usb_get_phy_by_node(xudc->dev, args.np, NULL); + of_node_put(args.np); + if (IS_ERR(usbphy)) { + err = PTR_ERR(usbphy); + dev_err_probe(xudc->dev, err, + "failed to get usbphy-%d\n", i); + goto clean_up; + } + xudc->usbphy[i] = usbphy; + /* Get USB3 phy */ usb3_companion_port = tegra_xusb_padctl_get_usb3_companion(xudc->padctl, i); if (usb3_companion_port < 0) -- 2.34.1 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip