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

ARM: ixp4xx: Turn the NPE into a platform device

Instead of registering everything related to the NPE
unconditionally in the module_init() call (which will
never work with multiplatform) create a platform device
and probe the NPE like any other device.

Put the device first in the list of devices added for
the platform so it is there when the dependent network
and crypto drivers probe later on.

This probe() path will not be taken unconditionally on
device tree boots, so remove the DT guard.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+19 -10
+6
arch/arm/mach-ixp4xx/common.c
··· 150 150 }, 151 151 }; 152 152 153 + static struct platform_device ixp4xx_npe_device = { 154 + .name = "ixp4xx-npe", 155 + .id = -1, 156 + }; 157 + 153 158 static struct platform_device *ixp4xx_devices[] __initdata = { 159 + &ixp4xx_npe_device, 154 160 &ixp4xx_gpio_device, 155 161 &ixp4xx_udc_device, 156 162 };
+13 -10
drivers/soc/ixp4xx/ixp4xx-npe.c
··· 21 21 #include <linux/kernel.h> 22 22 #include <linux/module.h> 23 23 #include <linux/of.h> 24 + #include <linux/platform_device.h> 24 25 #include <linux/soc/ixp4xx/npe.h> 25 26 26 27 #define DEBUG_MSG 0 ··· 684 683 module_put(THIS_MODULE); 685 684 } 686 685 687 - 688 - static int __init npe_init_module(void) 686 + static int ixp4xx_npe_probe(struct platform_device *pdev) 689 687 { 690 - 691 688 int i, found = 0; 692 - 693 - /* This driver does not work with device tree */ 694 - if (of_have_populated_dt()) 695 - return -ENODEV; 696 689 697 690 for (i = 0; i < NPE_COUNT; i++) { 698 691 struct npe *npe = &npe_tab[i]; ··· 712 717 return 0; 713 718 } 714 719 715 - static void __exit npe_cleanup_module(void) 720 + static int ixp4xx_npe_remove(struct platform_device *pdev) 716 721 { 717 722 int i; 718 723 ··· 721 726 npe_reset(&npe_tab[i]); 722 727 release_resource(npe_tab[i].mem_res); 723 728 } 729 + 730 + return 0; 724 731 } 725 732 726 - module_init(npe_init_module); 727 - module_exit(npe_cleanup_module); 733 + static struct platform_driver ixp4xx_npe_driver = { 734 + .driver = { 735 + .name = "ixp4xx-npe", 736 + }, 737 + .probe = ixp4xx_npe_probe, 738 + .remove = ixp4xx_npe_remove, 739 + }; 740 + module_platform_driver(ixp4xx_npe_driver); 728 741 729 742 MODULE_AUTHOR("Krzysztof Halasa"); 730 743 MODULE_LICENSE("GPL v2");