* [PATCH] ata: libahci_platform: Use common error handling code in ahci_platform_get_resources()
@ 2019-09-22 13:55 Markus Elfring
2019-09-23 9:07 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2019-09-22 13:55 UTC (permalink / raw)
To: linux-ide, Hans de Goede, Jens Axboe, Nishka Dasgupta
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Sep 2019 15:42:46 +0200
Convert the call of the function “of_node_put” to another jump target
so that it can be better reused at three places in this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/ata/libahci_platform.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
index e742780950de..7b2e364f3bd5 100644
--- a/drivers/ata/libahci_platform.c
+++ b/drivers/ata/libahci_platform.c
@@ -497,8 +497,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
if (of_property_read_u32(child, "reg", &port)) {
rc = -EINVAL;
- of_node_put(child);
- goto err_out;
+ goto err_put_node;
}
if (port >= hpriv->nports) {
@@ -515,18 +514,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
if (port_dev) {
rc = ahci_platform_get_regulator(hpriv, port,
&port_dev->dev);
- if (rc == -EPROBE_DEFER) {
- of_node_put(child);
- goto err_out;
- }
+ if (rc == -EPROBE_DEFER)
+ goto err_put_node;
}
#endif
rc = ahci_platform_get_phy(hpriv, port, dev, child);
- if (rc) {
- of_node_put(child);
- goto err_out;
- }
+ if (rc)
+ goto err_put_node;
enabled_ports++;
}
@@ -558,6 +553,8 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
devres_remove_group(dev, NULL);
return hpriv;
+err_put_node:
+ of_node_put(child);
err_out:
devres_release_group(dev, NULL);
return ERR_PTR(rc);
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ata: libahci_platform: Use common error handling code in ahci_platform_get_resources()
2019-09-22 13:55 [PATCH] ata: libahci_platform: Use common error handling code in ahci_platform_get_resources() Markus Elfring
@ 2019-09-23 9:07 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2019-09-23 9:07 UTC (permalink / raw)
To: Markus Elfring, linux-ide, Jens Axboe, Nishka Dasgupta
Cc: LKML, kernel-janitors
Hi,
On 22-09-2019 15:55, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Sep 2019 15:42:46 +0200
>
> Convert the call of the function “of_node_put” to another jump target
> so that it can be better reused at three places in this function.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Patch looks good to me:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Regards,
Hans
> ---
> drivers/ata/libahci_platform.c | 17 +++++++----------
> 1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
> index e742780950de..7b2e364f3bd5 100644
> --- a/drivers/ata/libahci_platform.c
> +++ b/drivers/ata/libahci_platform.c
> @@ -497,8 +497,7 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
>
> if (of_property_read_u32(child, "reg", &port)) {
> rc = -EINVAL;
> - of_node_put(child);
> - goto err_out;
> + goto err_put_node;
> }
>
> if (port >= hpriv->nports) {
> @@ -515,18 +514,14 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
> if (port_dev) {
> rc = ahci_platform_get_regulator(hpriv, port,
> &port_dev->dev);
> - if (rc == -EPROBE_DEFER) {
> - of_node_put(child);
> - goto err_out;
> - }
> + if (rc == -EPROBE_DEFER)
> + goto err_put_node;
> }
> #endif
>
> rc = ahci_platform_get_phy(hpriv, port, dev, child);
> - if (rc) {
> - of_node_put(child);
> - goto err_out;
> - }
> + if (rc)
> + goto err_put_node;
>
> enabled_ports++;
> }
> @@ -558,6 +553,8 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev,
> devres_remove_group(dev, NULL);
> return hpriv;
>
> +err_put_node:
> + of_node_put(child);
> err_out:
> devres_release_group(dev, NULL);
> return ERR_PTR(rc);
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-23 9:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-22 13:55 [PATCH] ata: libahci_platform: Use common error handling code in ahci_platform_get_resources() Markus Elfring
2019-09-23 9:07 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).