Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thomas Weißschuh and committed by
Paolo Abeni
b4c1fde5 9a884c38

+13 -19
+13 -19
drivers/ptp/ptp_vmclock.c
··· 506 506 507 507 if (ret) { 508 508 dev_info(dev, "Failed to obtain physical address: %d\n", ret); 509 - goto out; 509 + return ret; 510 510 } 511 511 512 512 if (resource_size(&st->res) < VMCLOCK_MIN_SIZE) { 513 513 dev_info(dev, "Region too small (0x%llx)\n", 514 514 resource_size(&st->res)); 515 - ret = -EINVAL; 516 - goto out; 515 + return -EINVAL; 517 516 } 518 517 st->clk = devm_memremap(dev, st->res.start, resource_size(&st->res), 519 518 MEMREMAP_WB | MEMREMAP_DEC); ··· 520 521 ret = PTR_ERR(st->clk); 521 522 dev_info(dev, "failed to map shared memory\n"); 522 523 st->clk = NULL; 523 - goto out; 524 + return ret; 524 525 } 525 526 526 527 if (le32_to_cpu(st->clk->magic) != VMCLOCK_MAGIC || 527 528 le32_to_cpu(st->clk->size) > resource_size(&st->res) || 528 529 le16_to_cpu(st->clk->version) != 1) { 529 530 dev_info(dev, "vmclock magic fields invalid\n"); 530 - ret = -EINVAL; 531 - goto out; 531 + return -EINVAL; 532 532 } 533 533 534 534 ret = ida_alloc(&vmclock_ida, GFP_KERNEL); 535 535 if (ret < 0) 536 - goto out; 536 + return ret; 537 537 538 538 st->index = ret; 539 539 ret = devm_add_action_or_reset(&pdev->dev, vmclock_put_idx, st); 540 540 if (ret) 541 - goto out; 541 + return ret; 542 542 543 543 st->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "vmclock%d", st->index); 544 - if (!st->name) { 545 - ret = -ENOMEM; 546 - goto out; 547 - } 544 + if (!st->name) 545 + return -ENOMEM; 548 546 549 547 st->miscdev.minor = MISC_DYNAMIC_MINOR; 550 548 551 549 ret = devm_add_action_or_reset(&pdev->dev, vmclock_remove, st); 552 550 if (ret) 553 - goto out; 551 + return ret; 554 552 555 553 /* 556 554 * If the structure is big enough, it can be mapped to userspace. ··· 561 565 562 566 ret = misc_register(&st->miscdev); 563 567 if (ret) 564 - goto out; 568 + return ret; 565 569 } 566 570 567 571 /* If there is valid clock information, register a PTP clock */ ··· 571 575 if (IS_ERR(st->ptp_clock)) { 572 576 ret = PTR_ERR(st->ptp_clock); 573 577 st->ptp_clock = NULL; 574 - goto out; 578 + return ret; 575 579 } 576 580 } 577 581 578 582 if (!st->miscdev.minor && !st->ptp_clock) { 579 583 /* Neither miscdev nor PTP registered */ 580 584 dev_info(dev, "vmclock: Neither miscdev nor PTP available; not registering\n"); 581 - ret = -ENODEV; 582 - goto out; 585 + return -ENODEV; 583 586 } 584 587 585 588 dev_info(dev, "%s: registered %s%s%s\n", st->name, ··· 586 591 (st->miscdev.minor && st->ptp_clock) ? ", " : "", 587 592 st->ptp_clock ? "PTP" : ""); 588 593 589 - out: 590 - return ret; 594 + return 0; 591 595 } 592 596 593 597 static const struct acpi_device_id vmclock_acpi_ids[] = {