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

[PATCH] vr41xx: convert to the new platform device interface

The patch does the following for v441xx seris drivers:

- stop using platform_device_register_simple() as it is going away
- mark ->probe() and ->remove() methods as __devinit and __devexit
respectively
- initialize "owner" field in driver structure so there is a link
from /sys/modules to the driver
- mark *_init() and *_exit() functions as __init and __exit

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Dmitry Torokhov and committed by
Linus Torvalds
d39b6cfe f4a641d6

+48 -25
+13 -6
drivers/char/vr41xx_giu.c
··· 613 613 .release = gpio_release, 614 614 }; 615 615 616 - static int giu_probe(struct platform_device *dev) 616 + static int __devinit giu_probe(struct platform_device *dev) 617 617 { 618 618 unsigned long start, size, flags = 0; 619 619 unsigned int nr_pins = 0; ··· 697 697 return cascade_irq(GIUINT_IRQ, giu_get_irq); 698 698 } 699 699 700 - static int giu_remove(struct platform_device *dev) 700 + static int __devexit giu_remove(struct platform_device *dev) 701 701 { 702 702 iounmap(giu_base); 703 703 ··· 712 712 713 713 static struct platform_driver giu_device_driver = { 714 714 .probe = giu_probe, 715 - .remove = giu_remove, 715 + .remove = __devexit_p(giu_remove), 716 716 .driver = { 717 717 .name = "GIU", 718 + .owner = THIS_MODULE, 718 719 }, 719 720 }; 720 721 ··· 723 722 { 724 723 int retval; 725 724 726 - giu_platform_device = platform_device_register_simple("GIU", -1, NULL, 0); 727 - if (IS_ERR(giu_platform_device)) 728 - return PTR_ERR(giu_platform_device); 725 + giu_platform_device = platform_device_alloc("GIU", -1); 726 + if (!giu_platform_device) 727 + return -ENOMEM; 728 + 729 + retval = platform_device_add(giu_platform_device); 730 + if (retval < 0) { 731 + platform_device_put(giu_platform_device); 732 + return retval; 733 + } 729 734 730 735 retval = platform_driver_register(&giu_device_driver); 731 736 if (retval < 0)
+20 -10
drivers/char/vr41xx_rtc.c
··· 558 558 .fops = &rtc_fops, 559 559 }; 560 560 561 - static int rtc_probe(struct platform_device *pdev) 561 + static int __devinit rtc_probe(struct platform_device *pdev) 562 562 { 563 563 unsigned int irq; 564 564 int retval; ··· 631 631 return 0; 632 632 } 633 633 634 - static int rtc_remove(struct platform_device *dev) 634 + static int __devexit rtc_remove(struct platform_device *dev) 635 635 { 636 636 int retval; 637 637 ··· 653 653 654 654 static struct platform_driver rtc_device_driver = { 655 655 .probe = rtc_probe, 656 - .remove = rtc_remove, 656 + .remove = __devexit_p(rtc_remove), 657 657 .driver = { 658 658 .name = rtc_name, 659 + .owner = THIS_MODULE, 659 660 }, 660 661 }; 661 662 662 - static int __devinit vr41xx_rtc_init(void) 663 + static int __init vr41xx_rtc_init(void) 663 664 { 664 665 int retval; 665 666 ··· 685 684 break; 686 685 } 687 686 688 - rtc_platform_device = platform_device_register_simple("RTC", -1, 689 - rtc_resource, ARRAY_SIZE(rtc_resource)); 690 - if (IS_ERR(rtc_platform_device)) 691 - return PTR_ERR(rtc_platform_device); 687 + rtc_platform_device = platform_device_alloc("RTC", -1); 688 + if (!rtc_platform_device) 689 + return -ENOMEM; 690 + 691 + retval = platform_device_add_resources(rtc_platform_device, 692 + rtc_resource, ARRAY_SIZE(rtc_resource)); 693 + 694 + if (retval == 0) 695 + retval = platform_device_add(rtc_platform_device); 696 + 697 + if (retval < 0) { 698 + platform_device_put(rtc_platform_device); 699 + return retval; 700 + } 692 701 693 702 retval = platform_driver_register(&rtc_device_driver); 694 703 if (retval < 0) ··· 707 696 return retval; 708 697 } 709 698 710 - static void __devexit vr41xx_rtc_exit(void) 699 + static void __exit vr41xx_rtc_exit(void) 711 700 { 712 701 platform_driver_unregister(&rtc_device_driver); 713 - 714 702 platform_device_unregister(rtc_platform_device); 715 703 } 716 704
+15 -9
drivers/serial/vr41xx_siu.c
··· 919 919 .cons = SERIAL_VR41XX_CONSOLE, 920 920 }; 921 921 922 - static int siu_probe(struct platform_device *dev) 922 + static int __devinit siu_probe(struct platform_device *dev) 923 923 { 924 924 struct uart_port *port; 925 925 int num, i, retval; ··· 953 953 return 0; 954 954 } 955 955 956 - static int siu_remove(struct platform_device *dev) 956 + static int __devexit siu_remove(struct platform_device *dev) 957 957 { 958 958 struct uart_port *port; 959 959 int i; ··· 1006 1006 1007 1007 static struct platform_driver siu_device_driver = { 1008 1008 .probe = siu_probe, 1009 - .remove = siu_remove, 1009 + .remove = __devexit_p(siu_remove), 1010 1010 .suspend = siu_suspend, 1011 1011 .resume = siu_resume, 1012 1012 .driver = { 1013 1013 .name = "SIU", 1014 + .owner = THIS_MODULE, 1014 1015 }, 1015 1016 }; 1016 1017 1017 - static int __devinit vr41xx_siu_init(void) 1018 + static int __init vr41xx_siu_init(void) 1018 1019 { 1019 1020 int retval; 1020 1021 1021 - siu_platform_device = platform_device_register_simple("SIU", -1, NULL, 0); 1022 - if (IS_ERR(siu_platform_device)) 1023 - return PTR_ERR(siu_platform_device); 1022 + siu_platform_device = platform_device_alloc("SIU", -1); 1023 + if (!siu_platform_device) 1024 + return -ENOMEM; 1025 + 1026 + retval = platform_device_add(siu_platform_device); 1027 + if (retval < 0) { 1028 + platform_device_put(siu_platform_device); 1029 + return retval; 1030 + } 1024 1031 1025 1032 retval = platform_driver_register(&siu_device_driver); 1026 1033 if (retval < 0) ··· 1036 1029 return retval; 1037 1030 } 1038 1031 1039 - static void __devexit vr41xx_siu_exit(void) 1032 + static void __exit vr41xx_siu_exit(void) 1040 1033 { 1041 1034 platform_driver_unregister(&siu_device_driver); 1042 - 1043 1035 platform_device_unregister(siu_platform_device); 1044 1036 } 1045 1037