From patchwork Tue Jan 24 18:37:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114717 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 421A1C25B4E for ; Tue, 24 Jan 2023 19:47:15 +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=HwatXv+sqI0GSVj914J1QVJ1LvLF6ofCaaM8h7AF9KQ=; b=ryL6xUFHND3lqI YSsOEIbJ5bJYMkRA8iWZoguStgF1CADcDhfC7+qjIa5kPmdv5+5kZUbG7Sq4hssvT0efCinGTJscD YTpKgCZlEPPmrsgotr8TkPc/010vPCVhPVdjdVJjzL3tKnXYWJwsWvPaqBU6bEq9kxRJC2B6OcUX8 s+FoOVeBTAWKyyxjmCjHpXL2s9nyJRawCtHgJ4lEOUd6c4qsQFBTEMRblsWznDZ9jgY5j0egEwfTk mRSirw1NCg5DsiRJVTGss5zDYyC0+tgOiv8OyV3D1DOj0z5hvtR+gKYgNQYOQdRR2DIUAkpRfshz+ /ExDF8l9Io53U8ZKAniA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPFZ-0053yU-Ch; Tue, 24 Jan 2023 19:46:33 +0000 Received: from baptiste.telenet-ops.be ([2a02:1800:120:4::f00:13]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBF-004xjQ-8a for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:07 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by baptiste.telenet-ops.be with bizsmtp id CidZ2900756uRqi01idZ8U; Tue, 24 Jan 2023 19:37:55 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCM-Gm; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n0Z-0R; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 1/9] phy: Remove unused phy_optional_get() Date: Tue, 24 Jan 2023 19:37:20 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103801_494381_AC53490B X-CRM114-Status: GOOD ( 20.06 ) 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 There were never any upstream users of this function since its introduction almost 10 years ago. Besides, the dummy for phy_optional_get() should have returned NULL instead of an error code. Signed-off-by: Geert Uytterhoeven --- This is v2 of "phy: Return NULL if the PHY is optional (part two)". --- Documentation/driver-api/phy/phy.rst | 11 +++++------ drivers/phy/phy-core.c | 21 --------------------- include/linux/phy/phy.h | 7 ------- 3 files changed, 5 insertions(+), 34 deletions(-) diff --git a/Documentation/driver-api/phy/phy.rst b/Documentation/driver-api/phy/phy.rst index 8e8b3e8f95238d18..26467dd4f291505e 100644 --- a/Documentation/driver-api/phy/phy.rst +++ b/Documentation/driver-api/phy/phy.rst @@ -103,7 +103,6 @@ it. This framework provides the following APIs to get a reference to the PHY. :: struct phy *phy_get(struct device *dev, const char *string); - struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); @@ -111,15 +110,15 @@ it. This framework provides the following APIs to get a reference to the PHY. struct device_node *np, int index); -phy_get, phy_optional_get, devm_phy_get and devm_phy_optional_get can -be used to get the PHY. In the case of dt boot, the string arguments +phy_get, devm_phy_get and devm_phy_optional_get can be used to get the PHY. +In the case of dt boot, the string arguments should contain the phy name as given in the dt data and in the case of non-dt boot, it should contain the label of the PHY. The two devm_phy_get associates the device with the PHY using devres on successful PHY get. On driver detach, release function is invoked on -the devres data and devres data is freed. phy_optional_get and -devm_phy_optional_get should be used when the phy is optional. These -two functions will never return -ENODEV, but instead returns NULL when +the devres data and devres data is freed. +devm_phy_optional_get should be used when the phy is optional. This +function will never return -ENODEV, but instead returns NULL when the phy cannot be found.Some generic drivers, such as ehci, may use multiple phys and for such drivers referencing phy(s) by name(s) does not make sense. In this case, devm_of_phy_get_by_index can be used to get a phy reference based on diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index d93ddf1262c5178b..672f5c86588609f3 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -766,27 +766,6 @@ struct phy *phy_get(struct device *dev, const char *string) } EXPORT_SYMBOL_GPL(phy_get); -/** - * phy_optional_get() - lookup and obtain a reference to an optional phy. - * @dev: device that requests this phy - * @string: the phy name as given in the dt data or the name of the controller - * port for non-dt case - * - * Returns the phy driver, after getting a refcount to it; or - * NULL if there is no such phy. The caller is responsible for - * calling phy_put() to release that count. - */ -struct phy *phy_optional_get(struct device *dev, const char *string) -{ - struct phy *phy = phy_get(dev, string); - - if (PTR_ERR(phy) == -ENODEV) - phy = NULL; - - return phy; -} -EXPORT_SYMBOL_GPL(phy_optional_get); - /** * devm_phy_get() - lookup and obtain a reference to a phy. * @dev: device that requests this phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index b1413757fcc3b89b..1b4f9be21e01f4c7 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -250,7 +250,6 @@ static inline void phy_set_bus_width(struct phy *phy, int bus_width) phy->attrs.bus_width = bus_width; } struct phy *phy_get(struct device *dev, const char *string); -struct phy *phy_optional_get(struct device *dev, const char *string); struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, @@ -426,12 +425,6 @@ static inline struct phy *phy_get(struct device *dev, const char *string) return ERR_PTR(-ENOSYS); } -static inline struct phy *phy_optional_get(struct device *dev, - const char *string) -{ - return ERR_PTR(-ENOSYS); -} - static inline struct phy *devm_phy_get(struct device *dev, const char *string) { return ERR_PTR(-ENOSYS); From patchwork Tue Jan 24 18:37:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114711 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 C1A91C54EB4 for ; Tue, 24 Jan 2023 19:46:26 +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=X1kgr0/kqMmoZJld8h6bMIZoD5vGMl0+5MFiH9wt+AQ=; b=nBGNRN78wwnQ2O sAzRqfRwzjErZbfclkbpUoWNLbykox5VX1Ttk1pJJ6SDJKOanZ0P5+mexCmb9fQyWH3YwSD9LJxa0 R0sd4FV7wE+uwgQIV6uQH3s+Ab20RjtxVaylZyyI82oCsVwmvKbBaINVabofa3ivqUQTspP7mIAIX hYTDlEEbCvdriDabWaKB6LQ7DL0b9JjgIadQwQU87b1nHM9d8jRJEIbBSQ1WDpKOpOCUCSbJC5Syv AzDO489qgmCQfbHZYDE9779XrUqBFVtq1boMlJOB8Ki8xdxQ4qn56gRio+eoJiPUbLxI8zj0isYQb owi31zD8l/xBBzzQtgQQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPEk-0053hs-0l; Tue, 24 Jan 2023 19:45:42 +0000 Received: from albert.telenet-ops.be ([2a02:1800:110:4::f00:1a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBD-004xj5-LX for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:02 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by albert.telenet-ops.be with bizsmtp id CidZ2900356uRqi06idZVY; Tue, 24 Jan 2023 19:37:55 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCO-Ho; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n0c-1h; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 2/9] doc: phy: Document devm_of_phy_get() Date: Tue, 24 Jan 2023 19:37:21 +0100 Message-Id: <768d5845668f081620098a0b4479d1481e212bac.1674584626.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103759_918147_68BACC02 X-CRM114-Status: GOOD ( 14.54 ) 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 Add the missing documentation for devm_of_phy_get(), which was forgotten when the function was introduced. Signed-off-by: Geert Uytterhoeven --- v2: - New. --- Documentation/driver-api/phy/phy.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/driver-api/phy/phy.rst b/Documentation/driver-api/phy/phy.rst index 26467dd4f291505e..6cadc58f4ce07ce4 100644 --- a/Documentation/driver-api/phy/phy.rst +++ b/Documentation/driver-api/phy/phy.rst @@ -106,6 +106,8 @@ it. This framework provides the following APIs to get a reference to the PHY. struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); + struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, + const char *con_id); struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, int index); @@ -119,10 +121,10 @@ successful PHY get. On driver detach, release function is invoked on the devres data and devres data is freed. devm_phy_optional_get should be used when the phy is optional. This function will never return -ENODEV, but instead returns NULL when -the phy cannot be found.Some generic drivers, such as ehci, may use multiple -phys and for such drivers referencing phy(s) by name(s) does not make sense. In -this case, devm_of_phy_get_by_index can be used to get a phy reference based on -the index. +the phy cannot be found. +Some generic drivers, such as ehci, may use multiple phys. In this case, +devm_of_phy_get or devm_of_phy_get_by_index can be used to get a phy +reference based on name or index. It should be noted that NULL is a valid phy reference. All phy consumer calls on the NULL phy become NOPs. That is the release calls, From patchwork Tue Jan 24 18:37:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114716 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 8660BC25B4E for ; Tue, 24 Jan 2023 19:47:04 +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=joE9aSBSunXyf+y5f9tBrsSrS9yA0KlXdUEhkrT5rnE=; b=MdwgzD4zrcvnEL 1yUQj+z1bLoGFlhdMJMiMzYe9mH1FIvqZ7BDXa7NDIhqmiCa7U+UahKqZ1PhIsCTH6YYNyrW5KO6I h+yJvPVmbdNhKEELzvUZLlCpUTCO+EOGRGaER8T9ukbMx1E96YC+KTsZFpNwxC0/iVVZrcGAyBK9F qk31HzFIJYqDETqBEbOTLsfEXZ5MI4JFGBgR/GrzVYyv4gqhmhw35NwFzAjtZA0NpToWQxWXPsWkD GZvGYiM5eAn30/6JOkFpxSnrNHCsgG6tFdd0osTVFEMXKDJhVAMdcgxx+Ex9IlaZ/ko/ze5488c8y 5kJ+yBQ5XgtgfsQhrR9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPFQ-0053u1-2X; Tue, 24 Jan 2023 19:46:24 +0000 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBE-004xjO-OS for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:06 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by michel.telenet-ops.be with bizsmtp id CidZ2900456uRqi06idZy8; Tue, 24 Jan 2023 19:37:57 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCT-Ig; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n0h-2v; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 3/9] phy: Add devm_of_phy_optional_get() helper Date: Tue, 24 Jan 2023 19:37:22 +0100 Message-Id: <4cd0069bcff424ffc5c3a102397c02370b91985b.1674584626.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103801_081546_C1428FBA X-CRM114-Status: GOOD ( 21.13 ) 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 Add an optional variant of devm_of_phy_get() that also takes care of printing real errors, so drivers no longer have to open-code this operation. Signed-off-by: Geert Uytterhoeven --- v2: - Print an error message in case of failure, as requested by RobH, - Update Documentation. --- Documentation/driver-api/phy/phy.rst | 7 +++++-- drivers/phy/phy-core.c | 30 ++++++++++++++++++++++++++++ include/linux/phy/phy.h | 9 +++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-api/phy/phy.rst b/Documentation/driver-api/phy/phy.rst index 6cadc58f4ce07ce4..81785c084f3ec2dd 100644 --- a/Documentation/driver-api/phy/phy.rst +++ b/Documentation/driver-api/phy/phy.rst @@ -108,6 +108,9 @@ it. This framework provides the following APIs to get a reference to the PHY. const char *string); struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, const char *con_id); + struct phy *devm_of_phy_optional_get(struct device *dev, + struct device_node *np, + const char *con_id); struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, int index); @@ -119,8 +122,8 @@ non-dt boot, it should contain the label of the PHY. The two devm_phy_get associates the device with the PHY using devres on successful PHY get. On driver detach, release function is invoked on the devres data and devres data is freed. -devm_phy_optional_get should be used when the phy is optional. This -function will never return -ENODEV, but instead returns NULL when +The _optional_get variants should be used when the phy is optional. These +functions will never return -ENODEV, but instead return NULL when the phy cannot be found. Some generic drivers, such as ehci, may use multiple phys. In this case, devm_of_phy_get or devm_of_phy_get_by_index can be used to get a phy diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index 672f5c86588609f3..9951efc03eaaf842 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -858,6 +858,36 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, } EXPORT_SYMBOL_GPL(devm_of_phy_get); +/** + * devm_of_phy_optional_get() - lookup and obtain a reference to an optional + * phy. + * @dev: device that requests this phy + * @np: node containing the phy + * @con_id: name of the phy from device's point of view + * + * Gets the phy using of_phy_get(), and associates a device with it using + * devres. On driver detach, release function is invoked on the devres data, + * then, devres data is freed. This differs to devm_of_phy_get() in + * that if the phy does not exist, it is not considered an error and + * -ENODEV will not be returned. Instead the NULL phy is returned, + * which can be passed to all other phy consumer calls. + */ +struct phy *devm_of_phy_optional_get(struct device *dev, struct device_node *np, + const char *con_id) +{ + struct phy *phy = devm_of_phy_get(dev, np, con_id); + + if (PTR_ERR(phy) == -ENODEV) + phy = NULL; + + if (IS_ERR(phy)) + dev_err_probe(dev, PTR_ERR(phy), "failed to get PHY %pOF:%s", + np, con_id); + + return phy; +} +EXPORT_SYMBOL_GPL(devm_of_phy_optional_get); + /** * devm_of_phy_get_by_index() - lookup and obtain a reference to a phy by index. * @dev: device that requests this phy diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 1b4f9be21e01f4c7..3a570bc59fc7f4a1 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -254,6 +254,8 @@ struct phy *devm_phy_get(struct device *dev, const char *string); struct phy *devm_phy_optional_get(struct device *dev, const char *string); struct phy *devm_of_phy_get(struct device *dev, struct device_node *np, const char *con_id); +struct phy *devm_of_phy_optional_get(struct device *dev, struct device_node *np, + const char *con_id); struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, int index); void of_phy_put(struct phy *phy); @@ -443,6 +445,13 @@ static inline struct phy *devm_of_phy_get(struct device *dev, return ERR_PTR(-ENOSYS); } +static inline struct phy *devm_of_phy_optional_get(struct device *dev, + struct device_node *np, + const char *con_id) +{ + return NULL; +} + static inline struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, int index) From patchwork Tue Jan 24 18:37:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114715 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 518D6C25B50 for ; Tue, 24 Jan 2023 19:46:53 +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=0IpyoHWQXoRbcM5red6IqUqV4RvOjesVZs+mySL6hFI=; b=2w337uoNitkEKP T/kt2GZp+rn2SMCfeqrTZbGWjMrExB9r0heXzQ+KzlYEQC2mGrBedGZhhr3XSgkr9L/IPHf6UeEE5 PQ+c0VRaOtPtGB+MVrlOxFoUqK7pdaESFhyfp8fH/2CQ5F7kLE06p+8VWgUDukcZLG+cEi4jbXd3N s7TSLtJJyRLzcg03esljQY4rs59naOSoh2iSmUctF5He5bomVj9+pFY9HTELzEZOsm4T2zeSoI3MV 7ZUviHOrbZoq9Q6xOqZd9CV8tKeWHl6y9Fss/Y29EVVfv1k1SJu/A5mtkJQX7Zw+3svy1imfeuX8n stJKMYIi1X32WXyOk8HQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPFF-0053pR-5g; Tue, 24 Jan 2023 19:46:13 +0000 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBE-004xjU-OO for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:05 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by michel.telenet-ops.be with bizsmtp id CidZ2900556uRqi06idZyA; Tue, 24 Jan 2023 19:37:58 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCY-JX; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n0l-3x; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven , Sean Anderson Subject: [PATCH v2 4/9] net: fman: memac: Convert to devm_of_phy_optional_get() Date: Tue, 24 Jan 2023 19:37:23 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103801_064403_C42DE6AA X-CRM114-Status: GOOD ( 14.03 ) 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 Use the new devm_of_phy_optional_get() helper instead of open-coding the same operation. As devm_of_phy_optional_get() returns NULL if either the PHY cannot be found, or if support for the PHY framework is not enabled, it is no longer needed to check for -ENODEV or -ENOSYS. Signed-off-by: Geert Uytterhoeven Reviewed-by: Sean Anderson --- v2: - Add Reviewed-by, - Clarify removed checks for -ENODEV and -ENOSYS, - Remove error printing in case of real failures. --- drivers/net/ethernet/freescale/fman/fman_memac.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c b/drivers/net/ethernet/freescale/fman/fman_memac.c index 9349f841bd0645a0..ddd9d13f1166e120 100644 --- a/drivers/net/ethernet/freescale/fman/fman_memac.c +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c @@ -1152,13 +1152,12 @@ int memac_initialization(struct mac_device *mac_dev, else memac->sgmii_pcs = pcs; - memac->serdes = devm_of_phy_get(mac_dev->dev, mac_node, "serdes"); - err = PTR_ERR(memac->serdes); - if (err == -ENODEV || err == -ENOSYS) { + memac->serdes = devm_of_phy_optional_get(mac_dev->dev, mac_node, + "serdes"); + if (!memac->serdes) { dev_dbg(mac_dev->dev, "could not get (optional) serdes\n"); - memac->serdes = NULL; } else if (IS_ERR(memac->serdes)) { - dev_err_probe(mac_dev->dev, err, "could not get serdes\n"); + err = PTR_ERR(memac->serdes); goto _return_fm_mac_free; } From patchwork Tue Jan 24 18:37:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114714 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 653C4C54EB4 for ; Tue, 24 Jan 2023 19:46:40 +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=lRR/ki/d3g7eNl2n6aGSAMjyF8ttvbB6eIvTXuRqq+o=; b=279YtahnPaq4u4 PbGhNLRn/AHjDLUDA2Ak+hMB9tzG7hGz3GGQIHzROBq+2l0WcRF0wVj49cdrPweJ6nV5jT7e1QMC2 aHHT7L25FuRKbRaUlyTGwkc0LljyfQKwuOS4E+bDNqjcTC6mFasDVzuUXW52ohDTUy89xhCqyyHXz pO6UNTXiN0Rj2UR0iLa+nr3CTPK2TuRBjKL90bYvG0b6vRGx8qprNbYygcMecR4AHBuY7Gr/hh9RC IDYcGZuwUugiKr7ODH7mEKHHnlAK2dn9s8N+sIXNPnqagX9o2MYeoNVVl8RfxoRkGvFoEtR33dH/Y RHNltYPXpkRbU9XmmBCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPF7-0053nF-4t; Tue, 24 Jan 2023 19:46:05 +0000 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBE-004xjW-OS for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:05 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by michel.telenet-ops.be with bizsmtp id CidZ2900756uRqi06idZyB; Tue, 24 Jan 2023 19:37:58 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCd-KC; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n0o-4q; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven , Steen Hegelund Subject: [PATCH v2 5/9] net: lan966x: Convert to devm_of_phy_optional_get() Date: Tue, 24 Jan 2023 19:37:24 +0100 Message-Id: <993b0f4ac5b84b2b72223011614d2e821f9e7302.1674584626.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103801_060969_C3276EB8 X-CRM114-Status: GOOD ( 12.33 ) 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 Use the new devm_of_phy_optional_get() helper instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven Reviewed-by: Steen Hegelund --- v2: - Add Reviewed-by. --- drivers/net/ethernet/microchip/lan966x/lan966x_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c index 580c91d24a5284e7..f2670d6d84d7893a 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c @@ -1147,9 +1147,8 @@ static int lan966x_probe(struct platform_device *pdev) lan966x->ports[p]->config.portmode = phy_mode; lan966x->ports[p]->fwnode = fwnode_handle_get(portnp); - serdes = devm_of_phy_get(lan966x->dev, to_of_node(portnp), NULL); - if (PTR_ERR(serdes) == -ENODEV) - serdes = NULL; + serdes = devm_of_phy_optional_get(lan966x->dev, + to_of_node(portnp), NULL); if (IS_ERR(serdes)) { err = PTR_ERR(serdes); goto cleanup_ports; From patchwork Tue Jan 24 18:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114712 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 E831FC54EED for ; Tue, 24 Jan 2023 19:46:26 +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=7awVwuamgz6oTc3x2mn3D+XJxkjfUGjkIrdyLR3Tugo=; b=tB7asqxG9bZiLO btvFpr2p5plnjpjbKOBbj3D6eePKhC4oZEk8UgRXizkcMHOVyFwpOE5IMVt62D0ldkl9//sEUGXyB ROAPZZBNvtimc868kNzzNXwBxXm0Xf3C00icdUMFKYOdjEiLDvd0CpOp8ypu1Is1l/Is1rAvZzT4X g6YeukdyIyARNaNh+DXlgHy4aXaEllpUcJQuAqV5l224SdneULHRPrrfz5bolAtcv9oi4JGjRNnnR vC8qT4jMRYe2d36ECKMN/YUrBIu8MvTWSNc8hKNI/ArGmr6gSJT2qL6kh//XDU2heOu4mOqWLX8aM v5DnzPjvrYnlIfGTjoIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPEr-0053jH-Hf; Tue, 24 Jan 2023 19:45:49 +0000 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBE-004xjB-ON for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:02 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by michel.telenet-ops.be with bizsmtp id CidZ2900956uRqi06idZyD; Tue, 24 Jan 2023 19:37:57 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCh-L0; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n0t-5c; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 6/9] net: ethernet: ti: am65-cpsw: Convert to devm_of_phy_optional_get() Date: Tue, 24 Jan 2023 19:37:25 +0100 Message-Id: <3d612c95031cf5c6d5af4ec35f40121288a2c1c6.1674584626.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103801_044426_70298A2E X-CRM114-Status: GOOD ( 12.64 ) 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 Use the new devm_of_phy_optional_get() helper instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven Reviewed-by: Siddharth Vadapalli --- v2: - Rebase on top of commit 854617f52ab42418 ("net: ethernet: ti: am65-cpsw: Handle -EPROBE_DEFER for Serdes PHY") in net-next (next-20230123 and later). --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index c696da89962f1ae3..794f228c8d632f7a 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -1460,11 +1460,9 @@ static int am65_cpsw_init_serdes_phy(struct device *dev, struct device_node *por struct phy *phy; int ret; - phy = devm_of_phy_get(dev, port_np, name); - if (PTR_ERR(phy) == -ENODEV) - return 0; - if (IS_ERR(phy)) - return PTR_ERR(phy); + phy = devm_of_phy_optional_get(dev, port_np, name); + if (IS_ERR_OR_NULL(phy)) + return PTR_ERR_OR_ZERO(phy); /* Serdes PHY exists. Store it. */ port->slave.serdes_phy = phy; From patchwork Tue Jan 24 18:37:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114719 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 061E3C25B4E for ; Tue, 24 Jan 2023 19:47:51 +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=DWcjK9BJ3n7+sbXvK1Joxx5DEOA8oN//zOl9AEGoXgc=; b=ttMAoQT42piUmF u8AaWSgr8y+MaRsyDwnsQlTJ0PQzkdxjKlKNP5zKRJB73rfyCnEf7KrVrT5BgwUjcXxBfNZfbIsRy zrGkuvYuseZZwAQluC66lnqqlVjEH43ZcRm1ipBImHXn32IJKPmSM22kYd8REfFAbjtkWnR3AbIFT mQHFCR/AuisJPJSn67RFAyoIqz+UB0ahMB1uuCcqng1v6hSz/sBdsgs7fmZ3/bdCe2/W9uiOaYqoe 1s+HRc69DYjMlltRKcemSpCOncmqEKGmMXCZMJ7enljzho2NR3C9+NvoC4b8erUR4HfYm6klEJ8PD PEEz5ugfz6aAUqZbgrEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPGC-0054MO-0C; Tue, 24 Jan 2023 19:47:12 +0000 Received: from andre.telenet-ops.be ([2a02:1800:120:4::f00:15]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBF-004xjZ-OO for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:07 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by andre.telenet-ops.be with bizsmtp id CidZ2900756uRqi01idZWC; Tue, 24 Jan 2023 19:37:58 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCm-ME; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n0z-6H; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 7/9] PCI: tegra: Convert to devm_of_phy_optional_get() Date: Tue, 24 Jan 2023 19:37:26 +0100 Message-Id: <56508eeadf7fa8692877e872871f10294d48c49d.1674584626.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103801_952625_229CB2AF X-CRM114-Status: GOOD ( 11.50 ) 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 Use the new devm_of_phy_optional_get() helper instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven Acked-by: Bjorn Helgaas --- v2: - Add Acked-by. --- drivers/pci/controller/pci-tegra.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pci/controller/pci-tegra.c b/drivers/pci/controller/pci-tegra.c index 929f9363e94bec71..5b8907c663e516ad 100644 --- a/drivers/pci/controller/pci-tegra.c +++ b/drivers/pci/controller/pci-tegra.c @@ -1330,12 +1330,9 @@ static struct phy *devm_of_phy_optional_get_index(struct device *dev, if (!name) return ERR_PTR(-ENOMEM); - phy = devm_of_phy_get(dev, np, name); + phy = devm_of_phy_optional_get(dev, np, name); kfree(name); - if (PTR_ERR(phy) == -ENODEV) - phy = NULL; - return phy; } From patchwork Tue Jan 24 18:37:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114713 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 1E50AC25B50 for ; Tue, 24 Jan 2023 19:46: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=t6dvdDmtgaAVfyOELVL+CWqLbdU4L7Ko/KUA2+GTA/Q=; b=Y5Lcuvo6BbHojW KMzyE3eIFQ1dsWWeAdj/Hak6gD/Cwspu4HaNeZXTawm1+UrjpQVadduTPZuQfG+r1qPGGFnFVAM+a war0Xmv1NOTXrvYQcb0c0MVKDoHTkIzBOhCP50HyrQi7vLyBLpGd3vkboRxl9KrZkc3UvBp8wUJRR CuG4aSBAqb4hsFApTjPc8glVRXROqd6R03VDf0fOwnpzUyaLQQZ94z8uXy3NoExXbhTt7Az4/juuh 6LFhQS0HvFI58GJrlRBULJRlPbglCAL0SiLFdvAN54ujh2ZVt/Z3QgT0w53mMLyZcWx9ifX2LGDER qpYyOakmSUPwo7gKIklg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPEz-0053kw-Aa; Tue, 24 Jan 2023 19:45:57 +0000 Received: from michel.telenet-ops.be ([2a02:1800:110:4::f00:18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBE-004xjF-OL for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:04 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by michel.telenet-ops.be with bizsmtp id CidZ2900A56uRqi06idZyG; Tue, 24 Jan 2023 19:37:57 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCq-N7; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n13-6z; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 8/9] usb: host: ehci-exynos: Convert to devm_of_phy_optional_get() Date: Tue, 24 Jan 2023 19:37:27 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103801_076198_2C7AE98A X-CRM114-Status: GOOD ( 15.63 ) 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 Use the new devm_of_phy_optional_get() helper instead of open-coding the same operation. As devm_of_phy_optional_get() returns NULL if either the PHY cannot be found, or if support for the PHY framework is not enabled, it is no longer needed to check for -ENODEV or -ENOSYS. This lets us drop several checks for IS_ERR(), as phy_power_{on,off}() handle NULL parameters fine. Signed-off-by: Geert Uytterhoeven Reviewed-by: Greg Kroah-Hartman Acked-by: Greg Kroah-Hartman --- v2: - Add Reviewed-by, - Clarify removed checks for -ENODEV and -ENOSYS, - Remove error printing in case of real failures. --- drivers/usb/host/ehci-exynos.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c index a333231616f437b8..47c9f06c3d843db3 100644 --- a/drivers/usb/host/ehci-exynos.c +++ b/drivers/usb/host/ehci-exynos.c @@ -80,19 +80,11 @@ static int exynos_ehci_get_phy(struct device *dev, return -EINVAL; } - phy = devm_of_phy_get(dev, child, NULL); + phy = devm_of_phy_optional_get(dev, child, NULL); exynos_ehci->phy[phy_number] = phy; if (IS_ERR(phy)) { - ret = PTR_ERR(phy); - if (ret == -EPROBE_DEFER) { - of_node_put(child); - return ret; - } else if (ret != -ENOSYS && ret != -ENODEV) { - dev_err(dev, - "Error retrieving usb2 phy: %d\n", ret); - of_node_put(child); - return ret; - } + of_node_put(child); + return PTR_ERR(phy); } } @@ -108,12 +100,10 @@ static int exynos_ehci_phy_enable(struct device *dev) int ret = 0; for (i = 0; ret == 0 && i < PHY_NUMBER; i++) - if (!IS_ERR(exynos_ehci->phy[i])) - ret = phy_power_on(exynos_ehci->phy[i]); + ret = phy_power_on(exynos_ehci->phy[i]); if (ret) for (i--; i >= 0; i--) - if (!IS_ERR(exynos_ehci->phy[i])) - phy_power_off(exynos_ehci->phy[i]); + phy_power_off(exynos_ehci->phy[i]); return ret; } @@ -125,8 +115,7 @@ static void exynos_ehci_phy_disable(struct device *dev) int i; for (i = 0; i < PHY_NUMBER; i++) - if (!IS_ERR(exynos_ehci->phy[i])) - phy_power_off(exynos_ehci->phy[i]); + phy_power_off(exynos_ehci->phy[i]); } static void exynos_setup_vbus_gpio(struct device *dev) From patchwork Tue Jan 24 18:37:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13114710 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 51957C25B4E for ; Tue, 24 Jan 2023 19:46:26 +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=y67Ctm0oJJgDdrQE6ufTybWuJFpfeloy3u1T4bunE84=; b=j81zG5tKHiChTx 2k4qMNK9ERBEAFTx1Zo0QzZl7yLTOKjTWDivXWW8n5QHoWSsGnh58AkTs/O4ysLDwlkQLID4J+ZcZ qArEtdyAGfnGrXJF6nUwg9EWqAMv3iT4V6xzyOJVFrJzyM4DJ+MmEluNbjnmHTpTHd9OQjb0HAN9g mMaE6GoPTxdTsAl/dfPDnhSSOHpM/nEbn8W1eYPjFWa91ETugWzyQNAPkZdLZB0VoyrGPS2gZxbVm IPG4C5xzQyvCaRKCyKddbdglkAJstqtQViw24HiNVdDuBf/k5cBu4YicIg4XQIxCbu7FD4HiRCRaV lpUWMfbpHdJPOdQuTgkg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKPEc-0053h0-9b; Tue, 24 Jan 2023 19:45:34 +0000 Received: from laurent.telenet-ops.be ([2a02:1800:110:4::f00:19]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pKOBD-004xj2-Ih for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2023 18:38:01 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed50:2f4a:8573:c294:b2ce]) by laurent.telenet-ops.be with bizsmtp id CidZ2900K56uRqi01idZ2h; Tue, 24 Jan 2023 19:37:55 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1pKOAe-007HCs-OB; Tue, 24 Jan 2023 19:37:33 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1pKOAn-002n1A-8j; Tue, 24 Jan 2023 19:37:33 +0100 From: Geert Uytterhoeven To: Vinod Koul , Jonathan Corbet , Madalin Bucur , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Horatiu Vultur , UNGLinuxDriver@microchip.com, Thierry Reding , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , Jonathan Hunter , Kishon Vijay Abraham I , Alan Stern , Greg Kroah-Hartman , Krzysztof Kozlowski , Alim Akhtar , Siddharth Vadapalli , Russell King Cc: linux-phy@lists.infradead.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-tegra@vger.kernel.org, linux-pci@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 9/9] usb: host: ohci-exynos: Convert to devm_of_phy_optional_get() Date: Tue, 24 Jan 2023 19:37:28 +0100 Message-Id: <3adc5dd1149a17ea7daf4463549feab886c6b145.1674584626.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230124_103759_784021_246C03E4 X-CRM114-Status: GOOD ( 16.21 ) 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 Use the new devm_of_phy_optional_get() helper instead of open-coding the same operation. As devm_of_phy_optional_get() returns NULL if either the PHY cannot be found, or if support for the PHY framework is not enabled, it is no longer needed to check for -ENODEV or -ENOSYS. This lets us drop several checks for IS_ERR(), as phy_power_{on,off}() handle NULL parameters fine. Signed-off-by: Geert Uytterhoeven Acked-by: Alan Stern Acked-by: Greg Kroah-Hartman --- v2: - Add Acked-by, - Clarify removed checks for -ENODEV and -ENOSYS, - Remove error printing in case of real failures. --- drivers/usb/host/ohci-exynos.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c index 8d7977fd5d3bd502..8af17c1ee5cc8f1e 100644 --- a/drivers/usb/host/ohci-exynos.c +++ b/drivers/usb/host/ohci-exynos.c @@ -69,19 +69,11 @@ static int exynos_ohci_get_phy(struct device *dev, return -EINVAL; } - phy = devm_of_phy_get(dev, child, NULL); + phy = devm_of_phy_optional_get(dev, child, NULL); exynos_ohci->phy[phy_number] = phy; if (IS_ERR(phy)) { - ret = PTR_ERR(phy); - if (ret == -EPROBE_DEFER) { - of_node_put(child); - return ret; - } else if (ret != -ENOSYS && ret != -ENODEV) { - dev_err(dev, - "Error retrieving usb2 phy: %d\n", ret); - of_node_put(child); - return ret; - } + of_node_put(child); + return PTR_ERR(phy); } } @@ -97,12 +89,10 @@ static int exynos_ohci_phy_enable(struct device *dev) int ret = 0; for (i = 0; ret == 0 && i < PHY_NUMBER; i++) - if (!IS_ERR(exynos_ohci->phy[i])) - ret = phy_power_on(exynos_ohci->phy[i]); + ret = phy_power_on(exynos_ohci->phy[i]); if (ret) for (i--; i >= 0; i--) - if (!IS_ERR(exynos_ohci->phy[i])) - phy_power_off(exynos_ohci->phy[i]); + phy_power_off(exynos_ohci->phy[i]); return ret; } @@ -114,8 +104,7 @@ static void exynos_ohci_phy_disable(struct device *dev) int i; for (i = 0; i < PHY_NUMBER; i++) - if (!IS_ERR(exynos_ohci->phy[i])) - phy_power_off(exynos_ohci->phy[i]); + phy_power_off(exynos_ohci->phy[i]); } static int exynos_ohci_probe(struct platform_device *pdev)