From patchwork Thu Sep 5 08:28:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13791955 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 0BE6CCD4F5E for ; Thu, 5 Sep 2024 08:30:35 +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=z95UGf7B9wDS1GrasfLxXKMU57OfQOtf2Mt7NqNL0AY=; b=iyl3AWWb7+Lx28 2kHTveIytwxfo49uXGjZOKFa0GxfaJZYVj8ld7u1sBW//9wO2nIMJgEc56UK+XHSuPLluv1vQPgPZ ojbk0hxyZfhwqSJDC2e5SeX6rv6MguzwYybLWjbTWLsGvuXo14oxXujApG+6tqydumD71xEH4HyJc KmxAeYbuz8acesgr0XG7GXMh3hN4/96fwda9xLPfMAFEHSKFbAW1MqegEW73BzXexTgQ8cS/GmYHq n/hA5wfGoWCDu6nRawNGONf+VdwRtQlDz3lvAeArmY3KFx+oJgJy/UXBtWhaedjkfM/NL/RBi8Fbs dlSI8EY/2Hkiiv3gwmOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7sw-00000007add-37X3; Thu, 05 Sep 2024 08:30:34 +0000 Received: from mail.manjaro.org ([2a01:4f8:c0c:51f3::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7r0-00000007a5E-26X3; Thu, 05 Sep 2024 08:28:36 +0000 From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1725524909; 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=SILV1WrR3UJ7DyuEqQANwCR/2kJL6kyxGoyeN1ndk4g=; b=X+qiO3OLfCIFoKIoel6usk08EArFCMOuddZShsWxJUk7v+khYMXEclo1qkt8vvHN9uxpLP FMGLh93KIdh6xCTzDfTBfkXhDaYXNDZqqgyCaKf6Y3noqzZf0sFC9q4vj7TbAB/d7sc7nA 2jP4OXEl7Oa2Osr7RsrnI4zMwc0LoM8jxhtLgDlS5NuFlvC5WvmoChil4Ibq+ZRpCaUccp 92R+hrUAEvZIMTEv/pWNljked/yE1jsxaC9OXvJlL44ytAMtZBDWXRV2775ex/+0WlvueX w2jTnLjClKfYDT7FecqV/u1DBPheIHSbLWe3CHZc7cJz6ZWrDl6Mo11EJRCMvQ== 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 v3 1/3] phy: phy-rockchip-inno-usb2: Perform trivial code cleanups Date: Thu, 5 Sep 2024 10:28:22 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_012835_083635_0671DA9E X-CRM114-Status: GOOD ( 12.97 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org 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. Reviewed-by: Heiko Stuebner Signed-off-by: Dragan Simic --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 4f71373ae6e1..03b772200fed 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_usb2phy *rphy) static int rockchip_usb2phy_extcon_register(struct rockchip_usb2phy *rphy) { - int ret; struct device_node *node = rphy->dev->of_node; struct extcon_dev *edev; + int ret; if (of_property_read_bool(node, "extcon")) { edev = extcon_get_edev_by_phandle(rphy->dev, 0); @@ -1327,21 +1327,19 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) struct rockchip_usb2phy *rphy; const struct rockchip_usb2phy_cfg *phy_cfgs; unsigned int reg; - int index, ret; + int index = 0, ret; rphy = devm_kzalloc(dev, sizeof(*rphy), GFP_KERNEL); if (!rphy) return -ENOMEM; if (!dev->parent || !dev->parent->of_node) { rphy->grf = 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 = syscon_node_to_regmap(dev->parent->of_node); if (IS_ERR(rphy->grf)) return PTR_ERR(rphy->grf); @@ -1358,16 +1356,14 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) } 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; } /* support address_cells=2 */ if (of_property_count_u32_elems(np, "reg") > 2 && reg == 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 +1382,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) if (ret) return ret; - /* find out a proper config which can be matched with dt. */ - index = 0; + /* find a proper config that can be matched with the DT */ do { if (phy_cfgs[index].reg == reg) { rphy->phy_cfg = &phy_cfgs[index]; @@ -1407,10 +1402,9 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) return PTR_ERR(rphy->phy_reset); rphy->clk = 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"); - } ret = rockchip_usb2phy_clk480m_register(rphy); if (ret) { @@ -1446,13 +1440,11 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) /* initialize otg/host port separately */ if (of_node_name_eq(child_np, "host-port")) { - ret = rockchip_usb2phy_host_port_init(rphy, rport, - child_np); + ret = rockchip_usb2phy_host_port_init(rphy, rport, child_np); if (ret) goto put_child; } else { - ret = rockchip_usb2phy_otg_port_init(rphy, rport, - child_np); + ret = rockchip_usb2phy_otg_port_init(rphy, rport, child_np); if (ret) goto put_child; } From patchwork Thu Sep 5 08:28:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13791961 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 1BE9ECD4F59 for ; Thu, 5 Sep 2024 08:31:34 +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=lnr6lsqzqJbd6Qvql/gbFkmp+TgF0kcuDWjBKDj3+sM=; b=TfyV54HAMH4uzu Y8r04ppHGgcXnzjSTQheLkdyH0BFTt5Keo//6Aq54RSdHDGY0Rgp62ffClF+Lhnogw0+katCI9nLO yvlFMqiiCn8ttGbriyvEqlRf2x4+d+O/bAXsBpFmWyUFs5N/tkpnf148Ca/wYZmexSri6MYVIrMi+ JvAeZNj/HRBRDEx+pjPLvhfgrdJ/a0iOaWXCfKu4BcfNt3RqApEz5yyYBc2kB2LJrAvRlhJ7dOoX/ 3L54zkPd2mLXEMgGIZiY/D2vXRHkU06K8qHIqeczAkHPTBrGo15y/K3HgnA88KW+a7ujL/1wkTKUD DmzPDV7SYWQdmcbYTmRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7tt-00000007auJ-3Rl5; Thu, 05 Sep 2024 08:31:33 +0000 Received: from mail.manjaro.org ([116.203.91.91]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7r0-00000007a5G-3dqO; Thu, 05 Sep 2024 08:28:37 +0000 From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1725524910; 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=tpYdzE01L46nA5/EJhfGrNXTWtdCl00jDOzayRDNeNg=; b=J0Cp1CRZG9yqPrytIFQpnCjSn8GsFFzRHLcsySbAZiW9fJqUBCwCUNFCBt0kkDZn1Vt1Xt F4VAImTs5Q3F2PQkIFXzBxI7iKdwwO5TZM0zsPkpiEh9dlFqwnexOM3tqMEzTcqPJglFCg 5NUYcyghzYademVp/JQ+cSGGa4NCG6NZv+TAJjXpPFRWEjMMmT4LiFYhiSY1Yqz5IZhnCr vft9lk2ZDFUNO0KiwQOlfu9R/CQDNpnxtfDhZcFoXusl2T54XSSZPiot7VxcMYU7+1tzql UFel88WIQAPD5PiG1Sj4+6Ivg8Q9YzkAWZgPU/maurgGEsQhHN2ztQ0cDNaZ4w== 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 v3 2/3] phy: phy-rockchip-inno-usb2: Handle failed extcon allocation better Date: Thu, 5 Sep 2024 10:28:23 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_012835_087580_1DACD2B8 X-CRM114-Status: UNSURE ( 8.96 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Return the actual error code upon failure to allocate extcon device, instead of hardcoding -ENOMEM. Use dev_err_probe() to also log appropriate messages, which is fine because the containing function is used in the probe path. Helped-by: Heiko Stubner Reviewed-by: Heiko Stuebner 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/rockchip/phy-rockchip-inno-usb2.c index 03b772200fed..cf6b67dd9f10 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 rockchip_usb2phy *rphy) rockchip_usb2phy_extcon_cable); if (IS_ERR(edev)) - return -ENOMEM; + return dev_err_probe(rphy->dev, PTR_ERR(edev), + "failed to allocate extcon device\n"); ret = devm_extcon_dev_register(rphy->dev, edev); if (ret) { From patchwork Thu Sep 5 08:28:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragan Simic X-Patchwork-Id: 13791962 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 6BCBACD4F59 for ; Thu, 5 Sep 2024 08:32:31 +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=vHVi9oXT0t+lNnxdadvKWC7YiDkvM0zj6cDKgMzK00U=; b=APcIyJkD7qtiNz 28cpllRQC5Cp+CKUehSFumfq6lK9GdkQA7G/CkhL/SqGB+dLtgH6ibuZ7CAVcrBaEDgSVK4YhEtVa AsNr5YzY86mPrWyxRiioKxmPU7ZAwqfW/exS0p2bj+pzVEX+J0t1o3xVJShZhXBTB6KzbOPO9mYxp SrHEhKiu9m23GGFDS2Hxd5Zgs/vS7t9gZh6dKFzEndypOHQ1/62nE9vj3LMyOt7iBw4+XDOiAZYG1 ahgUAVVPr+E1jydbEiMwnYg+ivc0CaibOEPHai+66x6LlyT5cFC87TVAcuXfJkDhPwlH+MD6iBmq3 3DZJjhc9md4q7cBNFpFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7up-00000007b5Y-0emB; Thu, 05 Sep 2024 08:32:31 +0000 Received: from mail.manjaro.org ([116.203.91.91]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sm7r0-00000007a5J-3eFG; Thu, 05 Sep 2024 08:28:38 +0000 From: Dragan Simic DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=manjaro.org; s=2021; t=1725524911; 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=LKQyp3YpQxjcuqGPlEIjyuaJl+vnUPygQPPMGal7PhU=; b=rlAgLGN98UKkJke94KHptuvM3DTMh0X4zZ3vpJvME5OUjBlFDXcF+jDysU7SvWXs1AOyme iRwbgVUjc/AGCJuqBUUg6VPk1c/tGMta84iwhcL3b2pnfubYJXAE2VbVboBDmBONB7i2Ih JrZUDuH1srVoh1L2ewfBBli9LNNy3TThoHu9z6lFnvOl521pMgylNcP8Zdfl5Ex6ZzrOkm qsiupyP8lZI/fDblJOU7OajAeIrANB6/fx5awvcxBuwnDfsSg4fUWSbiISxkH4b6d2fr23 K6N8TKJU9nm9JDilSbSVjVxZgzPUTgQKHC7xStQ+ZoDeu9UCcDc+UbbdupPfFA== 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 v3 3/3] phy: phy-rockchip-inno-usb2: Use dev_err_probe() in the probe path Date: Thu, 5 Sep 2024 10:28:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: ORIGINATING; auth=pass smtp.auth=dsimic@manjaro.org smtp.mailfrom=dsimic@manjaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_012835_249602_7584B3EE X-CRM114-Status: GOOD ( 10.31 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Improve error handling in the probe path by using function dev_err_probe() instead of function dev_err(), where appropriate. Signed-off-by: Dragan Simic Reviewed-by: Heiko Stuebner --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index cf6b67dd9f10..6e5214862b8a 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 rockchip_usb2phy *rphy) if (of_property_read_bool(node, "extcon")) { edev = extcon_get_edev_by_phandle(rphy->dev, 0); - if (IS_ERR(edev)) { - if (PTR_ERR(edev) != -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 = devm_extcon_dev_allocate(rphy->dev, rockchip_usb2phy_extcon_cable); if (IS_ERR(edev)) return dev_err_probe(rphy->dev, PTR_ERR(edev), "failed to allocate extcon device\n"); ret = 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"); } rphy->edev = edev; @@ -1408,10 +1405,8 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) "failed to get phyclk\n"); ret = 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"); if (rphy->phy_cfg->phy_tuning) { ret = rphy->phy_cfg->phy_tuning(rphy); @@ -1431,8 +1426,7 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) phy = 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 = PTR_ERR(phy); + ret = dev_err_probe(dev, PTR_ERR(phy), "failed to create phy\n"); goto put_child; } @@ -1467,8 +1461,7 @@ static int rockchip_usb2phy_probe(struct platform_device *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; } }