Skip to content

Commit b4c1fde

Browse files
t-8chPaolo Abeni
authored andcommitted
ptp: vmclock: Remove goto-based cleanup logic
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> Acked-by: Richard Cochran <richardcochran@gmail.com> Reviewed-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 9a884c3 commit b4c1fde

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

drivers/ptp/ptp_vmclock.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -506,52 +506,48 @@ static int vmclock_probe(struct platform_device *pdev)
506506

507507
if (ret) {
508508
dev_info(dev, "Failed to obtain physical address: %d\n", ret);
509-
goto out;
509+
return ret;
510510
}
511511

512512
if (resource_size(&st->res) < VMCLOCK_MIN_SIZE) {
513513
dev_info(dev, "Region too small (0x%llx)\n",
514514
resource_size(&st->res));
515-
ret = -EINVAL;
516-
goto out;
515+
return -EINVAL;
517516
}
518517
st->clk = devm_memremap(dev, st->res.start, resource_size(&st->res),
519518
MEMREMAP_WB | MEMREMAP_DEC);
520519
if (IS_ERR(st->clk)) {
521520
ret = PTR_ERR(st->clk);
522521
dev_info(dev, "failed to map shared memory\n");
523522
st->clk = NULL;
524-
goto out;
523+
return ret;
525524
}
526525

527526
if (le32_to_cpu(st->clk->magic) != VMCLOCK_MAGIC ||
528527
le32_to_cpu(st->clk->size) > resource_size(&st->res) ||
529528
le16_to_cpu(st->clk->version) != 1) {
530529
dev_info(dev, "vmclock magic fields invalid\n");
531-
ret = -EINVAL;
532-
goto out;
530+
return -EINVAL;
533531
}
534532

535533
ret = ida_alloc(&vmclock_ida, GFP_KERNEL);
536534
if (ret < 0)
537-
goto out;
535+
return ret;
538536

539537
st->index = ret;
540538
ret = devm_add_action_or_reset(&pdev->dev, vmclock_put_idx, st);
541539
if (ret)
542-
goto out;
540+
return ret;
543541

544542
st->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "vmclock%d", st->index);
545-
if (!st->name) {
546-
ret = -ENOMEM;
547-
goto out;
548-
}
543+
if (!st->name)
544+
return -ENOMEM;
549545

550546
st->miscdev.minor = MISC_DYNAMIC_MINOR;
551547

552548
ret = devm_add_action_or_reset(&pdev->dev, vmclock_remove, st);
553549
if (ret)
554-
goto out;
550+
return ret;
555551

556552
/*
557553
* If the structure is big enough, it can be mapped to userspace.
@@ -565,7 +561,7 @@ static int vmclock_probe(struct platform_device *pdev)
565561

566562
ret = misc_register(&st->miscdev);
567563
if (ret)
568-
goto out;
564+
return ret;
569565
}
570566

571567
/* If there is valid clock information, register a PTP clock */
@@ -575,24 +571,22 @@ static int vmclock_probe(struct platform_device *pdev)
575571
if (IS_ERR(st->ptp_clock)) {
576572
ret = PTR_ERR(st->ptp_clock);
577573
st->ptp_clock = NULL;
578-
goto out;
574+
return ret;
579575
}
580576
}
581577

582578
if (!st->miscdev.minor && !st->ptp_clock) {
583579
/* Neither miscdev nor PTP registered */
584580
dev_info(dev, "vmclock: Neither miscdev nor PTP available; not registering\n");
585-
ret = -ENODEV;
586-
goto out;
581+
return -ENODEV;
587582
}
588583

589584
dev_info(dev, "%s: registered %s%s%s\n", st->name,
590585
st->miscdev.minor ? "miscdev" : "",
591586
(st->miscdev.minor && st->ptp_clock) ? ", " : "",
592587
st->ptp_clock ? "PTP" : "");
593588

594-
out:
595-
return ret;
589+
return 0;
596590
}
597591

598592
static const struct acpi_device_id vmclock_acpi_ids[] = {

0 commit comments

Comments
 (0)