Skip to content

Commit 9a884c3

Browse files
t-8chPaolo Abeni
authored andcommitted
ptp: vmclock: Clean up miscdev and ptp clock through devres
Most resources owned by the vmclock device are managed through devres. Only the miscdev and ptp clock are managed manually. This makes the code slightly harder to understand than necessary. Switch them over to devres and remove the now unnecessary drvdata. 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 39e926c commit 9a884c3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/ptp/ptp_vmclock.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,9 @@ static const struct file_operations vmclock_miscdev_fops = {
421421

422422
/* module operations */
423423

424-
static void vmclock_remove(struct platform_device *pdev)
424+
static void vmclock_remove(void *data)
425425
{
426-
struct device *dev = &pdev->dev;
427-
struct vmclock_state *st = dev_get_drvdata(dev);
426+
struct vmclock_state *st = data;
428427

429428
if (st->ptp_clock)
430429
ptp_clock_unregister(st->ptp_clock);
@@ -525,8 +524,6 @@ static int vmclock_probe(struct platform_device *pdev)
525524
goto out;
526525
}
527526

528-
dev_set_drvdata(dev, st);
529-
530527
if (le32_to_cpu(st->clk->magic) != VMCLOCK_MAGIC ||
531528
le32_to_cpu(st->clk->size) > resource_size(&st->res) ||
532529
le16_to_cpu(st->clk->version) != 1) {
@@ -552,6 +549,10 @@ static int vmclock_probe(struct platform_device *pdev)
552549

553550
st->miscdev.minor = MISC_DYNAMIC_MINOR;
554551

552+
ret = devm_add_action_or_reset(&pdev->dev, vmclock_remove, st);
553+
if (ret)
554+
goto out;
555+
555556
/*
556557
* If the structure is big enough, it can be mapped to userspace.
557558
* Theoretically a guest OS even using larger pages could still
@@ -574,7 +575,6 @@ static int vmclock_probe(struct platform_device *pdev)
574575
if (IS_ERR(st->ptp_clock)) {
575576
ret = PTR_ERR(st->ptp_clock);
576577
st->ptp_clock = NULL;
577-
vmclock_remove(pdev);
578578
goto out;
579579
}
580580
}
@@ -603,7 +603,6 @@ MODULE_DEVICE_TABLE(acpi, vmclock_acpi_ids);
603603

604604
static struct platform_driver vmclock_platform_driver = {
605605
.probe = vmclock_probe,
606-
.remove = vmclock_remove,
607606
.driver = {
608607
.name = "vmclock",
609608
.acpi_match_table = vmclock_acpi_ids,

0 commit comments

Comments
 (0)