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

ARM: ixp4xx: Turn the QMGR into a platform device

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

Put the device second 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 -8
+6
arch/arm/mach-ixp4xx/common.c
··· 155 155 .id = -1, 156 156 }; 157 157 158 + static struct platform_device ixp4xx_qmgr_device = { 159 + .name = "ixp4xx-qmgr", 160 + .id = -1, 161 + }; 162 + 158 163 static struct platform_device *ixp4xx_devices[] __initdata = { 159 164 &ixp4xx_npe_device, 165 + &ixp4xx_qmgr_device, 160 166 &ixp4xx_gpio_device, 161 167 &ixp4xx_udc_device, 162 168 };
+13 -8
drivers/soc/ixp4xx/ixp4xx-qmgr.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/module.h> 15 15 #include <linux/of.h> 16 + #include <linux/platform_device.h> 16 17 #include <linux/soc/ixp4xx/qmgr.h> 17 18 18 19 /* FIXME: get rid of these static assigments */ ··· 289 288 module_put(THIS_MODULE); 290 289 } 291 290 292 - static int qmgr_init(void) 291 + static int ixp4xx_qmgr_probe(struct platform_device *pdev) 293 292 { 294 293 int i, err; 295 294 irq_handler_t handler1, handler2; 296 - 297 - /* This driver does not work with device tree */ 298 - if (of_have_populated_dt()) 299 - return -ENODEV; 300 295 301 296 mem_res = request_mem_region(IXP4XX_QMGR_BASE_PHYS, 302 297 IXP4XX_QMGR_REGION_SIZE, ··· 352 355 return err; 353 356 } 354 357 355 - static void qmgr_remove(void) 358 + static int ixp4xx_qmgr_remove(struct platform_device *pdev) 356 359 { 357 360 free_irq(IRQ_IXP4XX_QM1, NULL); 358 361 free_irq(IRQ_IXP4XX_QM2, NULL); 359 362 synchronize_irq(IRQ_IXP4XX_QM1); 360 363 synchronize_irq(IRQ_IXP4XX_QM2); 361 364 release_mem_region(IXP4XX_QMGR_BASE_PHYS, IXP4XX_QMGR_REGION_SIZE); 365 + 366 + return 0; 362 367 } 363 368 364 - module_init(qmgr_init); 365 - module_exit(qmgr_remove); 369 + static struct platform_driver ixp4xx_qmgr_driver = { 370 + .driver = { 371 + .name = "ixp4xx-qmgr", 372 + }, 373 + .probe = ixp4xx_qmgr_probe, 374 + .remove = ixp4xx_qmgr_remove, 375 + }; 376 + module_platform_driver(ixp4xx_qmgr_driver); 366 377 367 378 MODULE_LICENSE("GPL v2"); 368 379 MODULE_AUTHOR("Krzysztof Halasa");