From: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
To: David Woodhouse <dwmw2@infradead.org>,
Richard Cochran <richardcochran@gmail.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: "David Woodhouse" <dwmw@amazon.co.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Subject: [PATCH net-next 4/4] ptp: vmclock: Remove goto-based cleanup logic
Date: Thu, 06 Feb 2025 18:45:04 +0100 [thread overview]
Message-ID: <20250206-vmclock-probe-v1-4-17a3ea07be34@linutronix.de> (raw)
In-Reply-To: <20250206-vmclock-probe-v1-0-17a3ea07be34@linutronix.de>
vmclock_probe() uses an "out:" label to return from the function on
error. This indicates that some cleanup operation is necessary.
However the label does not do anything as all resources are managed
through devres, making the code slightly harder to read.
Remove the label and just return directly.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
drivers/ptp/ptp_vmclock.c | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/drivers/ptp/ptp_vmclock.c b/drivers/ptp/ptp_vmclock.c
index b7fa196975229cec6d27b34f7bb235c53b5b5732..26fcc1185ee72999a43842a59164498657799b1f 100644
--- a/drivers/ptp/ptp_vmclock.c
+++ b/drivers/ptp/ptp_vmclock.c
@@ -505,14 +505,13 @@ static int vmclock_probe(struct platform_device *pdev)
if (ret) {
dev_info(dev, "Failed to obtain physical address: %d\n", ret);
- goto out;
+ return ret;
}
if (resource_size(&st->res) < VMCLOCK_MIN_SIZE) {
dev_info(dev, "Region too small (0x%llx)\n",
resource_size(&st->res));
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
st->clk = devm_memremap(dev, st->res.start, resource_size(&st->res),
MEMREMAP_WB | MEMREMAP_DEC);
@@ -520,37 +519,34 @@ static int vmclock_probe(struct platform_device *pdev)
ret = PTR_ERR(st->clk);
dev_info(dev, "failed to map shared memory\n");
st->clk = NULL;
- goto out;
+ return ret;
}
if (le32_to_cpu(st->clk->magic) != VMCLOCK_MAGIC ||
le32_to_cpu(st->clk->size) > resource_size(&st->res) ||
le16_to_cpu(st->clk->version) != 1) {
dev_info(dev, "vmclock magic fields invalid\n");
- ret = -EINVAL;
- goto out;
+ return -EINVAL;
}
ret = ida_alloc(&vmclock_ida, GFP_KERNEL);
if (ret < 0)
- goto out;
+ return ret;
st->index = ret;
ret = devm_add_action_or_reset(&pdev->dev, vmclock_put_idx, st);
if (ret)
- goto out;
+ return ret;
st->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "vmclock%d", st->index);
- if (!st->name) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!st->name)
+ return -ENOMEM;
st->miscdev.minor = MISC_DYNAMIC_MINOR;
ret = devm_add_action_or_reset(&pdev->dev, vmclock_remove, st);
if (ret)
- goto out;
+ return ret;
/*
* If the structure is big enough, it can be mapped to userspace.
@@ -564,7 +560,7 @@ static int vmclock_probe(struct platform_device *pdev)
ret = misc_register(&st->miscdev);
if (ret)
- goto out;
+ return ret;
}
/* If there is valid clock information, register a PTP clock */
@@ -574,15 +570,14 @@ static int vmclock_probe(struct platform_device *pdev)
if (IS_ERR(st->ptp_clock)) {
ret = PTR_ERR(st->ptp_clock);
st->ptp_clock = NULL;
- goto out;
+ return ret;
}
}
if (!st->miscdev.minor && !st->ptp_clock) {
/* Neither miscdev nor PTP registered */
dev_info(dev, "vmclock: Neither miscdev nor PTP available; not registering\n");
- ret = -ENODEV;
- goto out;
+ return -ENODEV;
}
dev_info(dev, "%s: registered %s%s%s\n", st->name,
@@ -590,8 +585,7 @@ static int vmclock_probe(struct platform_device *pdev)
(st->miscdev.minor && st->ptp_clock) ? ", " : "",
st->ptp_clock ? "PTP" : "");
- out:
- return ret;
+ return 0;
}
static const struct acpi_device_id vmclock_acpi_ids[] = {
--
2.48.1
next prev parent reply other threads:[~2025-02-06 17:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 17:45 [PATCH net-next 0/4] ptp: vmclock: bugfixes and cleanups for error handling Thomas Weißschuh
2025-02-06 17:45 ` [PATCH net-next 1/4] ptp: vmclock: Set driver data before its usage Thomas Weißschuh
2025-02-07 7:07 ` Mateusz Polchlopek
2025-02-06 17:45 ` [PATCH net-next 2/4] ptp: vmclock: Don't unregister misc device if it was not registered Thomas Weißschuh
2025-02-06 17:45 ` [PATCH net-next 3/4] ptp: vmclock: Clean up miscdev and ptp clock through devres Thomas Weißschuh
2025-02-06 17:45 ` Thomas Weißschuh [this message]
2025-02-07 5:43 ` [PATCH net-next 0/4] ptp: vmclock: bugfixes and cleanups for error handling Richard Cochran
2025-02-07 7:13 ` Mateusz Polchlopek
2025-02-07 9:10 ` David Woodhouse
2025-02-07 9:25 ` Thomas Weißschuh
2025-02-07 9:29 ` David Woodhouse
2025-02-07 9:13 ` [PATCH net-next 5/4] ptp: vmclock: Add .owner to vmclock_miscdev_fops David Woodhouse
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=20250206-vmclock-probe-v1-4-17a3ea07be34@linutronix.de \
--to=thomas.weissschuh@linutronix.de \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=dwmw2@infradead.org \
--cc=dwmw@amazon.co.uk \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®