From nobody Sat Feb 7 15:40:14 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2887C481648; Wed, 21 Jan 2026 14:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004694; cv=none; b=As3/dl2R8FnH1ykrqoBt/Q5LuWblwiDA9GVYE1HvAZhYxeGe6RGwpCA4S4M7ej39koqAIaNUiVwJ4RH4sexdQPWVxO/2HoVQizem5FxQoxIkiaE83Bt80mI3s6XJOykcONf29QOndIg3Ss3KORs3pJ0X0ikIgoemXHoVnp/BTxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004694; c=relaxed/simple; bh=bTMo10SlkojFeqNM7uZ/l/Lwpv6fap2MUX1NzsAplUE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KJZCV8Ch0CSHtXYDvMyUnOBqkuC6eubJi9CRl36q470vnxXLzCBPKvNuVaWNJiEI4uJ7I6qwZZRn7WmatQ9NdZGR8E1mxoQIGGXVvLNey/ycErHNt2S4rkOEMGrQ39n2d1d0BMmdvtZ/dIEFbM1aPF499xFRhYAtCMMnvvKiDMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95B05C116D0; Wed, 21 Jan 2026 14:11:31 +0000 (UTC) From: Geert Uytterhoeven To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/4] usb: phy: generic: Always use dev in usb_phy_generic_probe() Date: Wed, 21 Jan 2026 15:11:20 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" usb_phy_generic_probe() already has a "dev" variable that serves as a shorthand for "&pdev->dev". Use it where appropriate, to shorten the code. Signed-off-by: Geert Uytterhoeven --- drivers/usb/phy/phy-generic.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 8423be59ec0ffbe8..13bd16668932dc90 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c @@ -294,13 +294,13 @@ static int usb_phy_generic_probe(struct platform_devi= ce *pdev) if (err) return err; if (nop->gpiod_vbus) { - err =3D devm_request_threaded_irq(&pdev->dev, + err =3D devm_request_threaded_irq(dev, gpiod_to_irq(nop->gpiod_vbus), NULL, nop_gpio_vbus_thread, VBUS_IRQ_FLAGS, "vbus_detect", nop); if (err) { - dev_err(&pdev->dev, "can't request irq %i, err: %d\n", + dev_err(dev, "can't request irq %i, err: %d\n", gpiod_to_irq(nop->gpiod_vbus), err); return err; } @@ -313,14 +313,13 @@ static int usb_phy_generic_probe(struct platform_devi= ce *pdev) =20 err =3D usb_add_phy_dev(&nop->phy); if (err) { - dev_err(&pdev->dev, "can't register transceiver, err: %d\n", - err); + dev_err(dev, "can't register transceiver, err: %d\n", err); return err; } =20 platform_set_drvdata(pdev, nop); =20 - device_set_wakeup_capable(&pdev->dev, + device_set_wakeup_capable(dev, of_property_read_bool(dn, "wakeup-source")); =20 return 0; --=20 2.43.0 From nobody Sat Feb 7 15:40:14 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C4C9A48AE32; Wed, 21 Jan 2026 14:11:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004694; cv=none; b=EpFy+Ge5tb9zDy6Xlh7V/pq7E5UvtP/JfPQ8Gycz7g8GrGnpcJ+1aBSQSqMSNZq3tLJ/42A2oHlxJhieZ1j0GECwWKXAL6BHrBHYu7VYd/MZLMLljbuQNYGHMG2hYnAKOlOEhJs54d8OxuabRoxr8uEni7DZhs35mbbYsaGXGWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004694; c=relaxed/simple; bh=r9WccWp0ajtLu0rLDpt+6kp79yZiT+r3M0SVKJZ6gXE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gppux/tYtwsdUXO2yEefaRkRvJ0gB7gGyum6bXPwdEcc5zis89vm/WQXqq5rKbuqe91zWtGneKOK8HnvZQJipK6ifmIXRPF+K+DbR+fKOHLSqcTgtHAVQwbYjyDHIhGOM7Sv/g3Qp0C/PkZlhTTEGE/MjVZg57uCA8dU8b3zffA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AF20C4CEF1; Wed, 21 Jan 2026 14:11:33 +0000 (UTC) From: Geert Uytterhoeven To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/4] usb: phy: generic: Convert to devm_clk_get_optional() Date: Wed, 21 Jan 2026 15:11:21 +0100 Message-ID: <5cc21d821edf5d40f56a74cd251bb1b982876b72.1769004444.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The generic USB PHY driver uses the existence of the "clocks" property to see if a clock is optional or not. Use devm_clk_get_optional() instead, which exists for this purpose. As usb_phy_generic.clk is now either a valid clock pointer or NULL, and all clock operations handle NULL pointers gracefully, several IS_ERR() checks can be removed, simplifying the code. Signed-off-by: Geert Uytterhoeven ... --- drivers/usb/phy/phy-generic.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 13bd16668932dc90..53b0262e6e306ada 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c @@ -49,15 +49,13 @@ static int nop_set_suspend(struct usb_phy *x, int suspe= nd) int ret =3D 0; =20 if (suspend) { - if (!IS_ERR(nop->clk)) - clk_disable_unprepare(nop->clk); + clk_disable_unprepare(nop->clk); if (!IS_ERR(nop->vcc) && !device_may_wakeup(x->dev)) ret =3D regulator_disable(nop->vcc); } else { if (!IS_ERR(nop->vcc) && !device_may_wakeup(x->dev)) ret =3D regulator_enable(nop->vcc); - if (!IS_ERR(nop->clk)) - clk_prepare_enable(nop->clk); + clk_prepare_enable(nop->clk); } =20 return ret; @@ -137,11 +135,9 @@ int usb_gen_phy_init(struct usb_phy *phy) dev_err(phy->dev, "Failed to enable power\n"); } =20 - if (!IS_ERR(nop->clk)) { - ret =3D clk_prepare_enable(nop->clk); - if (ret) - return ret; - } + ret =3D clk_prepare_enable(nop->clk); + if (ret) + return ret; =20 nop_reset(nop); =20 @@ -155,8 +151,7 @@ void usb_gen_phy_shutdown(struct usb_phy *phy) =20 gpiod_set_value_cansleep(nop->gpiod_reset, 1); =20 - if (!IS_ERR(nop->clk)) - clk_disable_unprepare(nop->clk); + clk_disable_unprepare(nop->clk); =20 if (!IS_ERR(nop->vcc)) { if (regulator_disable(nop->vcc)) @@ -202,17 +197,13 @@ int usb_phy_gen_create_phy(struct device *dev, struct= usb_phy_generic *nop) { enum usb_phy_type type =3D USB_PHY_TYPE_USB2; int err =3D 0; - u32 clk_rate =3D 0; - bool needs_clk =3D false; =20 if (dev->of_node) { struct device_node *node =3D dev->of_node; =20 if (of_property_read_u32(node, "clock-frequency", &clk_rate)) clk_rate =3D 0; - - needs_clk =3D of_property_present(node, "clocks"); } nop->gpiod_reset =3D devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS); @@ -235,15 +226,14 @@ int usb_phy_gen_create_phy(struct device *dev, struct= usb_phy_generic *nop) if (!nop->phy.otg) return -ENOMEM; =20 - nop->clk =3D devm_clk_get(dev, "main_clk"); + nop->clk =3D devm_clk_get_optional(dev, "main_clk"); if (IS_ERR(nop->clk)) { dev_dbg(dev, "Can't get phy clock: %ld\n", PTR_ERR(nop->clk)); - if (needs_clk) - return PTR_ERR(nop->clk); + return PTR_ERR(nop->clk); } =20 - if (!IS_ERR(nop->clk) && clk_rate) { + if (clk_rate) { err =3D clk_set_rate(nop->clk, clk_rate); if (err) { dev_err(dev, "Error setting clock rate\n"); --=20 2.43.0 From nobody Sat Feb 7 15:40:14 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 44FA148C3FF; Wed, 21 Jan 2026 14:11:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004696; cv=none; b=GpQil0POn58Mj6dY362GhVoekfTDf2gaKgoMC/aU2MIE0dztzx8wN4kJQoqoBJTB5/hQuq4sZjMpva5i128vgH8yg/mTfl/Hsbjn6583iKItRSI6tdX7LSeyihlIbCBVg4T0a0PjdInXE60O12JT7NewvUo/yW/Zylt7s3C8ZOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004696; c=relaxed/simple; bh=vaLFZ4d9a2vOXPbplXYpViMr1qmGtkCweSDpn09S8Rs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bZu0yjwiOMuAR4+YH/x6Hk+qcXhGXRcHGbG1ISvDhc+pQdVP3yejdbDAex2i+ciP2ofzPiG8YYncqJZ1Dt7qXVHnvnTJ3BAyfmv5Zg/DYlSA8fIZPWWgGWMA3eeVMBSOC3KO356+0nCrH+gXuZjV+84CiGmfagzYJLkbCZF9zUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B35E6C116D0; Wed, 21 Jan 2026 14:11:34 +0000 (UTC) From: Geert Uytterhoeven To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 3/4] usb: phy: generic: Convert to dev_err_probe() Date: Wed, 21 Jan 2026 15:11:22 +0100 Message-ID: <68739eb048a394fe9198080e4e57503bb2fb9b64.1769004444.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert the remaining error handling in the probe path to use the dev_err_probe() helper, to make sure error messages and codes are not missed, and recorded properly. Signed-off-by: Geert Uytterhoeven --- drivers/usb/phy/phy-generic.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 53b0262e6e306ada..9f3a38b93f2649a8 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c @@ -227,18 +227,15 @@ int usb_phy_gen_create_phy(struct device *dev, struct= usb_phy_generic *nop) return -ENOMEM; =20 nop->clk =3D devm_clk_get_optional(dev, "main_clk"); - if (IS_ERR(nop->clk)) { - dev_dbg(dev, "Can't get phy clock: %ld\n", - PTR_ERR(nop->clk)); - return PTR_ERR(nop->clk); - } + if (IS_ERR(nop->clk)) + return dev_err_probe(dev, PTR_ERR(nop->clk), + "Can't get phy clock\n"); =20 if (clk_rate) { err =3D clk_set_rate(nop->clk, clk_rate); - if (err) { - dev_err(dev, "Error setting clock rate\n"); - return err; - } + if (err) + return dev_err_probe(dev, err, + "Error setting clock rate\n"); } =20 nop->vcc =3D devm_regulator_get_optional(dev, "vcc"); @@ -283,17 +280,17 @@ static int usb_phy_generic_probe(struct platform_devi= ce *pdev) err =3D usb_phy_gen_create_phy(dev, nop); if (err) return err; + if (nop->gpiod_vbus) { err =3D devm_request_threaded_irq(dev, gpiod_to_irq(nop->gpiod_vbus), NULL, nop_gpio_vbus_thread, VBUS_IRQ_FLAGS, "vbus_detect", nop); - if (err) { - dev_err(dev, "can't request irq %i, err: %d\n", - gpiod_to_irq(nop->gpiod_vbus), err); - return err; - } + if (err) + return dev_err_probe(dev, err, "can't request irq %i\n", + gpiod_to_irq(nop->gpiod_vbus)); + nop->phy.otg->state =3D gpiod_get_value(nop->gpiod_vbus) ? OTG_STATE_B_PERIPHERAL : OTG_STATE_B_IDLE; } @@ -302,10 +299,8 @@ static int usb_phy_generic_probe(struct platform_devic= e *pdev) nop->phy.shutdown =3D usb_gen_phy_shutdown; =20 err =3D usb_add_phy_dev(&nop->phy); - if (err) { - dev_err(dev, "can't register transceiver, err: %d\n", err); - return err; - } + if (err) + return dev_err_probe(dev, err, "can't register transceiver\n"); =20 platform_set_drvdata(pdev, nop); =20 --=20 2.43.0 From nobody Sat Feb 7 15:40:14 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 8BFB448C8B9; Wed, 21 Jan 2026 14:11:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004697; cv=none; b=oZ5o1R3nWEn9hxpfuLqsMqYqJ8vZJT6gJVANvleUMOqqFYt7oyDR9au7pvXEhks5L24f7vseIfUIrqJSDxAH/dq5qUH7Q2vLM1uY7HSIhQ20X93h65IOtB3BVZ46Wt79Ada5hoVHwwc6y7B+DnSzw0tipdK8cUhOV1vhKN+GKzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769004697; c=relaxed/simple; bh=AniItZ42tKauvjfP/x2WMTbXkdm/ea1F8M05YC6oMHc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gh30Hmxin9YZpkvrO3hPI52o3mvA3plZa8usxz0dkUhdtAxxEcDUU6ywNuuAKKLHtL+3HJWod5p8TorjktQH9te2/hIF5pO0zPNTwrFVCVVmf0UN2z1hmf61PtsOzZ+46X41O2RQHYccYbh99STGWYxDU+mNjU3eeM2D9f6PNTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C3CFC4CEF1; Wed, 21 Jan 2026 14:11:36 +0000 (UTC) From: Geert Uytterhoeven To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 4/4] usb: phy: generic: Convert to device property API Date: Wed, 21 Jan 2026 15:11:23 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert from OF properties to device properties, to make the driver more generic and simpler. Signed-off-by: Geert Uytterhoeven --- drivers/usb/phy/phy-generic.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c index 9f3a38b93f2649a8..de26b302334de974 100644 --- a/drivers/usb/phy/phy-generic.c +++ b/drivers/usb/phy/phy-generic.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include =20 @@ -199,12 +199,7 @@ int usb_phy_gen_create_phy(struct device *dev, struct = usb_phy_generic *nop) int err =3D 0; u32 clk_rate =3D 0; =20 - if (dev->of_node) { - struct device_node *node =3D dev->of_node; - - if (of_property_read_u32(node, "clock-frequency", &clk_rate)) - clk_rate =3D 0; - } + device_property_read_u32(dev, "clock-frequency", &clk_rate); nop->gpiod_reset =3D devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS); err =3D PTR_ERR_OR_ZERO(nop->gpiod_reset); @@ -269,7 +264,6 @@ EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy); static int usb_phy_generic_probe(struct platform_device *pdev) { struct device *dev =3D &pdev->dev; - struct device_node *dn =3D dev->of_node; struct usb_phy_generic *nop; int err; =20 @@ -305,7 +299,7 @@ static int usb_phy_generic_probe(struct platform_device= *pdev) platform_set_drvdata(pdev, nop); =20 device_set_wakeup_capable(dev, - of_property_read_bool(dn, "wakeup-source")); + device_property_read_bool(dev, "wakeup-source")); =20 return 0; } --=20 2.43.0