From nobody Sun Dec 14 02:00:21 2025 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D4F11B81A8 for ; Wed, 21 Aug 2024 07:38:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724225894; cv=none; b=Issh2jmRslAPqUcZtYTOUMdx0BSZic2NhxCVIiuoZpDHalHjvCWZYGbal4heJ693FNE3JMKVYCK8U+f8WOxTZIHN+vTi4kcnl5UynunS5v9fRuSHvoR+Ew2gw24Iac6/jYQEZUh9cRKSfh8nHY/SHavREdlsnX2Ng7hxQS/12tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724225894; c=relaxed/simple; bh=cPNbpo4xoTZL2kQ8hIYKReFw9js7LB0aHS1cjVBN5SA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Uv7t7CvsGBnSazMOnCortkPu2w1gdD5xCCe9totkucAzo57jdtB9sNGJ2pFWoov2u2MfXwRWvPcZmuyk9Fz6R/PCoCKtlxAQh8jtuvEv3WVNK+A6awwOx4iOoT3LgOdR/CWqJgxrbYPTwSqzWIj81tD6OIphguVTBQU5cxhpBho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=bp1P0FN5; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="bp1P0FN5" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1724225882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RT+xNvS91oUZmgrFm0whaj9pHE06IUbxucr47hS+SAk=; b=bp1P0FN5SUbljLV+qPoyYshQdGr/Ss6zbzGvldDpeAR8Jpt12GZE6QZBne6UW7v0kHgVC6 NbEGsn51h972eBdHe8U7An8hbzoba85u0W/jdAm9GFy8nZ2bHpr7H8trpBg1nlzjDdiUE3 psAMVGJ8kjOCiSXw4N9GjCD00aY8d7yx2u3Yob2/Alp1+tEHxeHZDtuQfAIMsSfgbD14KB LaZuMUy4bV5ZT8Y4XV3WJ2s18NrGGuzsbwUK0XKeZJ3aIl6UnvRQTiutL1l5xzsfMf6wQw Loqs8M+BagMZvzcUg3KAHSCemT0XWOj1qLTuTfGV67hktM9QlC5q9uVQgJUrZQ== To: linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org Cc: vkoul@kernel.org, kishon@kernel.org, heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] phy: phy-rockchip-inno-usb2: Perform trivial code cleanups Date: Wed, 21 Aug 2024 09:37:53 +0200 Message-Id: <14167d6b025e18d2a06ee429feea6551ef6f9c44.1724225528.git.dsimic@manjaro.org> 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 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Content-Type: text/plain; charset="utf-8" Perform a few trivial code cleanups, e.g. to obey the reverse Christmas tree rule, to avoid use of "{ ... }" code blocks where they aren't really needed, or to avoid line wrapping by using the 100-column width better. No intended functional changes are introduced by these code cleanups. Signed-off-by: Dragan Simic --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/ro= ckchip/phy-rockchip-inno-usb2.c index 4f71373ae6e1..113bfc717ff0 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -418,9 +418,9 @@ rockchip_usb2phy_clk480m_register(struct rockchip_usb2p= hy *rphy) =20 static int rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy) { - int ret; struct device_node *node =3D rphy->dev->of_node; struct extcon_dev *edev; + int ret; =20 if (of_property_read_bool(node, "extcon")) { edev =3D extcon_get_edev_by_phandle(rphy->dev, 0); @@ -445,7 +445,6 @@ static int rockchip_usb2phy_extcon_register(struct rock= chip_usb2phy *rphy) } =20 rphy->edev =3D edev; - return 0; } =20 @@ -1327,21 +1326,19 @@ static int rockchip_usb2phy_probe(struct platform_d= evice *pdev) struct rockchip_usb2phy *rphy; const struct rockchip_usb2phy_cfg *phy_cfgs; unsigned int reg; - int index, ret; + int index =3D 0, ret; =20 rphy =3D devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL); if (!rphy) return -ENOMEM; =20 if (!dev->parent || !dev->parent->of_node) { rphy->grf =3D syscon_regmap_lookup_by_phandle(np, "rockchip,usbgrf"); if (IS_ERR(rphy->grf)) { dev_err(dev, "failed to locate usbgrf\n"); return PTR_ERR(rphy->grf); } - } - - else { + } else { rphy->grf =3D syscon_node_to_regmap(dev->parent->of_node); if (IS_ERR(rphy->grf)) return PTR_ERR(rphy->grf); @@ -1358,16 +1355,14 @@ static int rockchip_usb2phy_probe(struct platform_d= evice *pdev) } =20 if (of_property_read_u32_index(np, "reg", 0, ®)) { - dev_err(dev, "the reg property is not assigned in %pOFn node\n", - np); + dev_err(dev, "the reg property is not assigned in %pOFn node\n", np); return -EINVAL; } =20 /* support address_cells=3D2 */ if (of_property_count_u32_elems(np, "reg") > 2 && reg =3D=3D 0) { if (of_property_read_u32_index(np, "reg", 1, ®)) { - dev_err(dev, "the reg property is not assigned in %pOFn node\n", - np); + dev_err(dev, "the reg property is not assigned in %pOFn node\n", np); return -EINVAL; } } @@ -1386,8 +1381,7 @@ static int rockchip_usb2phy_probe(struct platform_dev= ice *pdev) if (ret) return ret; =20 - /* find out a proper config which can be matched with dt. */ - index =3D 0; + /* find a proper config that can be matched with the DT */ do { if (phy_cfgs[index].reg =3D=3D reg) { rphy->phy_cfg =3D &phy_cfgs[index]; @@ -1407,10 +1401,9 @@ static int rockchip_usb2phy_probe(struct platform_de= vice *pdev) return PTR_ERR(rphy->phy_reset); =20 rphy->clk =3D devm_clk_get_optional_enabled(dev, "phyclk"); - if (IS_ERR(rphy->clk)) { + if (IS_ERR(rphy->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(rphy->clk), "failed to get phyclk\n"); - } =20 ret =3D rockchip_usb2phy_clk480m_register(rphy); if (ret) { @@ -1446,13 +1439,11 @@ static int rockchip_usb2phy_probe(struct platform_d= evice *pdev) =20 /* initialize otg/host port separately */ if (of_node_name_eq(child_np, "host-port")) { - ret =3D rockchip_usb2phy_host_port_init(rphy, rport, - child_np); + ret =3D rockchip_usb2phy_host_port_init(rphy, rport, child_np); if (ret) goto put_child; } else { - ret =3D rockchip_usb2phy_otg_port_init(rphy, rport, - child_np); + ret =3D rockchip_usb2phy_otg_port_init(rphy, rport, child_np); if (ret) goto put_child; } From nobody Sun Dec 14 02:00:21 2025 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B13CB1A4B60 for ; Wed, 21 Aug 2024 07:43:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724226255; cv=none; b=X9qrOdbEyG0TG6bsmXz0OOqr1v2NgWPoHoBDHJuyn0ZJLuA17ChxMPsokdtuhTjMCzKSJM7UT+nHvFVl+oFwbdSHM2+X/NSUv6/gD+6Zh0mreA5+sbDctpOlp0yYUgYHR2mVKW+ULnVnKsPSFIaxPRJrSjSKYTrHExnVWOYjKAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724226255; c=relaxed/simple; bh=8QF6q/NGS0VKzzfTif4uf3VxYdjfxKy3ssihu70qbEg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=opMTQnEteIxbETw99Pgw3HtOV5fY21mRUeq2wWTq09mmWkO22Ej5pyvIXTFPGYRe1yYgHsSOxxj2fyUNHaPkh7mzKI0QLB8GjbG+IS+uTrpGq3g6Bdiy3UpyQIu1KcE75KzSiyd9zjBlQupwRHsJvveRoDjGxnjA96zytK+pG1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=MTU/bCDa; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="MTU/bCDa" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1724225883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=if9diTT6JYwENr+1sloMXQnDz1UcYLmsRE38kgYhmSI=; b=MTU/bCDaX3eIb5UE16lyGI6Md+9RwHmHaLnnA2RCQ5wEnQJOBuF6SUe+Cx/ScOenksCtGj SAeOJhftHM72vvoad1dr9PqALtaIBR26OFC/hO8M31c01usSEbumaYF4mag8XY2FRUmpJC 8hcuKRB4zp+hfjVsrwwgz+8kU7tFl4X3mFlmpT9/Y82e9oAznQeLkvywrfCJICqFEzoV0M sl/zdDOw+vcGqWIHjwUZs2cT5nlIFdjg3lM+ReTexELq0clsI5/GJ/HNAZ2jkiCs5zb+fT 6WJAARLzuo5dkTYVtZxCWizOPw1y7W/VOiP039Ou334RBK8TppvXPKxR+PI3xA== To: linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org Cc: vkoul@kernel.org, kishon@kernel.org, heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better Date: Wed, 21 Aug 2024 09:37:54 +0200 Message-Id: <96200baf794a0c451f3bbc3f5530b8cf0e359dfc.1724225528.git.dsimic@manjaro.org> 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 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Content-Type: text/plain; charset="utf-8" Return the actual error code upon failure to allocate extcon device, instead of hardcoding -ENOMEM. Use dev_err_probe() to also log appropriate message= s, which is fine because the containing function is used in the probe path. Helped-by: Heiko Stubner Signed-off-by: Dragan Simic --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/ro= ckchip/phy-rockchip-inno-usb2.c index 113bfc717ff0..05af46dda11d 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -435,7 +435,8 @@ static int rockchip_usb2phy_extcon_register(struct rock= chip_usb2phy *rphy) rockchip_usb2phy_extcon_cable); =20 if (IS_ERR(edev)) - return -ENOMEM; + return dev_err_probe(rphy->dev, PTR_ERR(edev), + "failed to allocate extcon device\n"); =20 ret =3D devm_extcon_dev_register(rphy->dev, edev); if (ret) { From nobody Sun Dec 14 02:00:21 2025 Received: from mail.manjaro.org (mail.manjaro.org [116.203.91.91]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A3D21A7AE9 for ; Wed, 21 Aug 2024 07:38:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=116.203.91.91 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724225983; cv=none; b=mGXU5N38bbn9y6f01FIPkhdOqj8/MhIZMKsmfnJ+qjWsEj4dJoWoRHzsa4m7f/rFo4oZpO4IeZqv/fCbl8f4p33YYut8sdThczUElmzX0oE2X157ZVeUKxHeMM5c78oST03vqx65w3Yi5FjdUXZxu5yrL350jxqVji8BuIKjJmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724225983; c=relaxed/simple; bh=6AOg0TGx7zJyk+vrMsVXsqkYgQ3pqFUnc3aNtU6xKC0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JHlAnUg7aKHnnptKU4MqE6duqjB6I26k8CaWP0sHtBkBUy7YMM2kc6iJGDl3X2l8JGL8emAnKKZxwSzblmI+jPCU8tCz6zNYlZs+nZ9VVzeGLwO599yTuDA7Lxg35DDM4sTVqh7TwvHv9OuakHPt80SXJiVBWCEIrVWNryWq7gc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org; spf=pass smtp.mailfrom=manjaro.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b=VAhqzafl; arc=none smtp.client-ip=116.203.91.91 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=manjaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=manjaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=manjaro.org header.i=@manjaro.org header.b="VAhqzafl" From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1724225884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7mpSgzy1mYsfmRZERxM1qKQwFf2Bvpti+0UrXxT9LS0=; b=VAhqzafl1g0io65W7HyURf3pSL/CuyQtt3tQtsLmL6RP/7/Y5D791BM11qXYjdTOzK1Uxd rUlZZtpStM7cbXzID5nq2aaFkEOusbAipxhnIUIJSvCs68zSJ8dSNkerAHOXN/A3t6uK1r nxx2Abak3LxXCzttOgeF1wkzldIDOQl+uh8B3uEWv66dsOeXBWQQyqLv1AV3AGP7bdbKen BZsZCj/L/ai2OosxqRKfLcuNUskNohqchZeEJbHg7AVSweKIJfNQp3jWdM/95k0IDOd5OR KSjZCjdexqBVPeZphtsQ9KPqX2t1Ki72Crfle9BHveqVOOsraqle0SOMPgwiug== To: linux-rockchip@lists.infradead.org, linux-phy@lists.infradead.org Cc: vkoul@kernel.org, kishon@kernel.org, heiko@sntech.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] phy: phy-rockchip-inno-usb2: Improve error handling while probing Date: Wed, 21 Aug 2024 09:37:55 +0200 Message-Id: <866445027a4f41165c872f494b04c218b6e67b09.1724225528.git.dsimic@manjaro.org> 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 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org Content-Type: text/plain; charset="utf-8" Improve error handling in the probe path by using function dev_err_probe() where appropriate, and by no longer using it rather pointlessly in one place that actually produces a single, hardcoded error code. Signed-off-by: Dragan Simic --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/ro= ckchip/phy-rockchip-inno-usb2.c index 05af46dda11d..30b6134365ec 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -424,25 +424,22 @@ static int rockchip_usb2phy_extcon_register(struct ro= ckchip_usb2phy *rphy) =20 if (of_property_read_bool(node, "extcon")) { edev =3D extcon_get_edev_by_phandle(rphy->dev, 0); - if (IS_ERR(edev)) { - if (PTR_ERR(edev) !=3D -EPROBE_DEFER) - dev_err(rphy->dev, "Invalid or missing extcon\n"); - return PTR_ERR(edev); - } + if (IS_ERR(edev)) + return dev_err_probe(rphy->dev, PTR_ERR(edev), + "invalid or missing extcon\n"); } else { /* Initialize extcon device */ edev =3D devm_extcon_dev_allocate(rphy->dev, rockchip_usb2phy_extcon_cable); =20 if (IS_ERR(edev)) return dev_err_probe(rphy->dev, PTR_ERR(edev), "failed to allocate extcon device\n"); =20 ret =3D devm_extcon_dev_register(rphy->dev, edev); - if (ret) { - dev_err(rphy->dev, "failed to register extcon device\n"); - return ret; - } + if (ret) + return dev_err_probe(rphy->dev, ret, + "failed to register extcon device\n"); } =20 rphy->edev =3D edev; @@ -1375,8 +1372,10 @@ static int rockchip_usb2phy_probe(struct platform_de= vice *pdev) rphy->irq =3D platform_get_irq_optional(pdev, 0); platform_set_drvdata(pdev, rphy); =20 - if (!phy_cfgs) - return dev_err_probe(dev, -EINVAL, "phy configs are not assigned!\n"); + if (!phy_cfgs) { + dev_err(dev, "phy configs are not assigned\n"); + return -EINVAL; + } =20 ret =3D rockchip_usb2phy_extcon_register(rphy); if (ret) @@ -1407,10 +1406,8 @@ static int rockchip_usb2phy_probe(struct platform_de= vice *pdev) "failed to get phyclk\n"); =20 ret =3D rockchip_usb2phy_clk480m_register(rphy); - if (ret) { - dev_err(dev, "failed to register 480m output clock\n"); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "failed to register 480m output clock\n"); =20 if (rphy->phy_cfg->phy_tuning) { ret =3D rphy->phy_cfg->phy_tuning(rphy); @@ -1430,8 +1427,7 @@ static int rockchip_usb2phy_probe(struct platform_dev= ice *pdev) =20 phy =3D devm_phy_create(dev, child_np, &rockchip_usb2phy_ops); if (IS_ERR(phy)) { - dev_err_probe(dev, PTR_ERR(phy), "failed to create phy\n"); - ret =3D PTR_ERR(phy); + ret =3D dev_err_probe(dev, PTR_ERR(phy), "failed to create phy\n"); goto put_child; } =20 @@ -1466,8 +1462,7 @@ static int rockchip_usb2phy_probe(struct platform_dev= ice *pdev) "rockchip_usb2phy", rphy); if (ret) { - dev_err(rphy->dev, - "failed to request usb2phy irq handle\n"); + dev_err_probe(rphy->dev, ret, "failed to request usb2phy irq handle\n"); goto put_child; } }