All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: "Vinod Koul" <vkoul@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Madalin Bucur" <madalin.bucur@nxp.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	UNGLinuxDriver@microchip.com,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	"Siddharth Vadapalli" <s-vadapalli@ti.com>,
	"Russell King" <linux@armlinux.org.uk>
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 <geert+renesas@glider.be>
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	[thread overview]
Message-ID: <3adc5dd1149a17ea7daf4463549feab886c6b145.1674584626.git.geert+renesas@glider.be> (raw)
In-Reply-To: <cover.1674584626.git.geert+renesas@glider.be>

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 <geert+renesas@glider.be>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
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)
-- 
2.34.1


WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: "Vinod Koul" <vkoul@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Madalin Bucur" <madalin.bucur@nxp.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	UNGLinuxDriver@microchip.com,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	"Siddharth Vadapalli" <s-vadapalli@ti.com>,
	"Russell King" <linux@armlinux.org.uk>
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 <geert+renesas@glider.be>
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	[thread overview]
Message-ID: <3adc5dd1149a17ea7daf4463549feab886c6b145.1674584626.git.geert+renesas@glider.be> (raw)
In-Reply-To: <cover.1674584626.git.geert+renesas@glider.be>

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 <geert+renesas@glider.be>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
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)
-- 
2.34.1


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert+renesas@glider.be>
To: "Vinod Koul" <vkoul@kernel.org>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Madalin Bucur" <madalin.bucur@nxp.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Horatiu Vultur" <horatiu.vultur@microchip.com>,
	UNGLinuxDriver@microchip.com,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	"Kishon Vijay Abraham I" <kishon@kernel.org>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
	"Alim Akhtar" <alim.akhtar@samsung.com>,
	"Siddharth Vadapalli" <s-vadapalli@ti.com>,
	"Russell King" <linux@armlinux.org.uk>
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 <geert+renesas@glider.be>
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	[thread overview]
Message-ID: <3adc5dd1149a17ea7daf4463549feab886c6b145.1674584626.git.geert+renesas@glider.be> (raw)
In-Reply-To: <cover.1674584626.git.geert+renesas@glider.be>

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 <geert+renesas@glider.be>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
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)
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-01-24 18:38 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-24 18:37 [PATCH treewide v2 0/9] phy: Add devm_of_phy_optional_get() helper Geert Uytterhoeven
2023-01-24 18:37 ` Geert Uytterhoeven
2023-01-24 18:37 ` Geert Uytterhoeven
2023-01-24 18:37 ` [PATCH v2 1/9] phy: Remove unused phy_optional_get() Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37 ` [PATCH v2 2/9] doc: phy: Document devm_of_phy_get() Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37 ` [PATCH v2 3/9] phy: Add devm_of_phy_optional_get() helper Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37 ` [PATCH v2 4/9] net: fman: memac: Convert to devm_of_phy_optional_get() Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37 ` [PATCH v2 5/9] net: lan966x: " Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37 ` [PATCH v2 6/9] net: ethernet: ti: am65-cpsw: " Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-25  5:13   ` Siddharth Vadapalli
2023-01-25  5:13     ` Siddharth Vadapalli
2023-01-25  5:13     ` Siddharth Vadapalli
2023-02-03  5:27   ` Vinod Koul
2023-02-03  5:27     ` Vinod Koul
2023-02-03  5:27     ` Vinod Koul
2023-02-03  8:04     ` Geert Uytterhoeven
2023-02-03  8:04       ` Geert Uytterhoeven
2023-02-03  8:04       ` Geert Uytterhoeven
2023-02-03  9:58       ` Vinod Koul
2023-02-03  9:58         ` Vinod Koul
2023-02-03  9:58         ` Vinod Koul
2023-01-24 18:37 ` [PATCH v2 7/9] PCI: tegra: " Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37 ` [PATCH v2 8/9] usb: host: ehci-exynos: " Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-25 14:38   ` Greg Kroah-Hartman
2023-01-25 14:38     ` Greg Kroah-Hartman
2023-01-25 14:38     ` Greg Kroah-Hartman
2023-01-24 18:37 ` Geert Uytterhoeven [this message]
2023-01-24 18:37   ` [PATCH v2 9/9] usb: host: ohci-exynos: " Geert Uytterhoeven
2023-01-24 18:37   ` Geert Uytterhoeven
2023-01-25 14:38   ` Greg Kroah-Hartman
2023-01-25 14:38     ` Greg Kroah-Hartman
2023-01-25 14:38     ` Greg Kroah-Hartman
2023-02-02 14:57 ` [PATCH treewide v2 0/9] phy: Add devm_of_phy_optional_get() helper Geert Uytterhoeven
2023-02-02 14:57   ` Geert Uytterhoeven
2023-02-02 14:57   ` Geert Uytterhoeven
2023-02-03  9:58 ` Vinod Koul
2023-02-03  9:58   ` Vinod Koul
2023-02-03  9:58   ` Vinod Koul

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3adc5dd1149a17ea7daf4463549feab886c6b145.1674584626.git.geert+renesas@glider.be \
    --to=geert+renesas@glider.be \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alim.akhtar@samsung.com \
    --cc=bhelgaas@google.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=horatiu.vultur@microchip.com \
    --cc=jonathanh@nvidia.com \
    --cc=kishon@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=kuba@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=lpieralisi@kernel.org \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=stern@rowland.harvard.edu \
    --cc=thierry.reding@gmail.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.