@@ -414,16 +414,16 @@ static ssize_t vmclock_miscdev_read(struct file *fp, char __user *buf,
414414}
415415
416416static const struct file_operations vmclock_miscdev_fops = {
417+ .owner = THIS_MODULE ,
417418 .mmap = vmclock_miscdev_mmap ,
418419 .read = vmclock_miscdev_read ,
419420};
420421
421422/* module operations */
422423
423- static void vmclock_remove (struct platform_device * pdev )
424+ static void vmclock_remove (void * data )
424425{
425- struct device * dev = & pdev -> dev ;
426- struct vmclock_state * st = dev_get_drvdata (dev );
426+ struct vmclock_state * st = data ;
427427
428428 if (st -> ptp_clock )
429429 ptp_clock_unregister (st -> ptp_clock );
@@ -506,46 +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 ;
545+
546+ st -> miscdev .minor = MISC_DYNAMIC_MINOR ;
547+
548+ ret = devm_add_action_or_reset (& pdev -> dev , vmclock_remove , st );
549+ if (ret )
550+ return ret ;
549551
550552 /*
551553 * If the structure is big enough, it can be mapped to userspace.
@@ -554,13 +556,12 @@ static int vmclock_probe(struct platform_device *pdev)
554556 * cross that bridge if/when we come to it.
555557 */
556558 if (le32_to_cpu (st -> clk -> size ) >= PAGE_SIZE ) {
557- st -> miscdev .minor = MISC_DYNAMIC_MINOR ;
558559 st -> miscdev .fops = & vmclock_miscdev_fops ;
559560 st -> miscdev .name = st -> name ;
560561
561562 ret = misc_register (& st -> miscdev );
562563 if (ret )
563- goto out ;
564+ return ret ;
564565 }
565566
566567 /* If there is valid clock information, register a PTP clock */
@@ -570,27 +571,22 @@ static int vmclock_probe(struct platform_device *pdev)
570571 if (IS_ERR (st -> ptp_clock )) {
571572 ret = PTR_ERR (st -> ptp_clock );
572573 st -> ptp_clock = NULL ;
573- vmclock_remove (pdev );
574- goto out ;
574+ return ret ;
575575 }
576576 }
577577
578578 if (!st -> miscdev .minor && !st -> ptp_clock ) {
579579 /* Neither miscdev nor PTP registered */
580580 dev_info (dev , "vmclock: Neither miscdev nor PTP available; not registering\n" );
581- ret = - ENODEV ;
582- goto out ;
581+ return - ENODEV ;
583582 }
584583
585584 dev_info (dev , "%s: registered %s%s%s\n" , st -> name ,
586585 st -> miscdev .minor ? "miscdev" : "" ,
587586 (st -> miscdev .minor && st -> ptp_clock ) ? ", " : "" ,
588587 st -> ptp_clock ? "PTP" : "" );
589588
590- dev_set_drvdata (dev , st );
591-
592- out :
593- return ret ;
589+ return 0 ;
594590}
595591
596592static const struct acpi_device_id vmclock_acpi_ids [] = {
@@ -601,7 +597,6 @@ MODULE_DEVICE_TABLE(acpi, vmclock_acpi_ids);
601597
602598static struct platform_driver vmclock_platform_driver = {
603599 .probe = vmclock_probe ,
604- .remove = vmclock_remove ,
605600 .driver = {
606601 .name = "vmclock" ,
607602 .acpi_match_table = vmclock_acpi_ids ,
0 commit comments