diff options
author | Rob Herring <rob.herring@calxeda.com> | 2011-02-23 16:37:59 -0500 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-02-28 15:22:42 -0500 |
commit | a1e9c9dd3383e6a1a762464ad604b1081774dbda (patch) | |
tree | 7b5cc2e6f33934880b4463bcc1a58c3e0b5b399a /drivers/char | |
parent | a314c5c0040aab51ebb1ecfd37a9198a91962243 (diff) |
ipmi: convert OF driver to platform driver
of_bus is deprecated in favor of the plain platform bus. This patch
merges the ipmi OF driver with the existing platform driver.
CONFIG_PPC_OF occurrances are removed or replaced with CONFIG_OF.
Compile tested with and without CONFIG_OF. Tested OF probe and
default probe cases.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 70 |
1 files changed, 23 insertions, 47 deletions
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 7855f9f45b8e..dcfc39ca753e 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -66,13 +66,10 @@ | |||
66 | #include <linux/string.h> | 66 | #include <linux/string.h> |
67 | #include <linux/ctype.h> | 67 | #include <linux/ctype.h> |
68 | #include <linux/pnp.h> | 68 | #include <linux/pnp.h> |
69 | |||
70 | #ifdef CONFIG_PPC_OF | ||
71 | #include <linux/of_device.h> | 69 | #include <linux/of_device.h> |
72 | #include <linux/of_platform.h> | 70 | #include <linux/of_platform.h> |
73 | #include <linux/of_address.h> | 71 | #include <linux/of_address.h> |
74 | #include <linux/of_irq.h> | 72 | #include <linux/of_irq.h> |
75 | #endif | ||
76 | 73 | ||
77 | #define PFX "ipmi_si: " | 74 | #define PFX "ipmi_si: " |
78 | 75 | ||
@@ -116,13 +113,7 @@ static char *ipmi_addr_src_to_str[] = { NULL, "hotmod", "hardcoded", "SPMI", | |||
116 | 113 | ||
117 | #define DEVICE_NAME "ipmi_si" | 114 | #define DEVICE_NAME "ipmi_si" |
118 | 115 | ||
119 | static struct platform_driver ipmi_driver = { | 116 | static struct platform_driver ipmi_driver; |
120 | .driver = { | ||
121 | .name = DEVICE_NAME, | ||
122 | .bus = &platform_bus_type | ||
123 | } | ||
124 | }; | ||
125 | |||
126 | 117 | ||
127 | /* | 118 | /* |
128 | * Indexes into stats[] in smi_info below. | 119 | * Indexes into stats[] in smi_info below. |
@@ -308,9 +299,6 @@ static int pci_registered; | |||
308 | #ifdef CONFIG_ACPI | 299 | #ifdef CONFIG_ACPI |
309 | static int pnp_registered; | 300 | static int pnp_registered; |
310 | #endif | 301 | #endif |
311 | #ifdef CONFIG_PPC_OF | ||
312 | static int of_registered; | ||
313 | #endif | ||
314 | 302 | ||
315 | static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; | 303 | static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; |
316 | static int num_max_busy_us; | 304 | static int num_max_busy_us; |
@@ -1860,8 +1848,9 @@ static int hotmod_handler(const char *val, struct kernel_param *kp) | |||
1860 | return rv; | 1848 | return rv; |
1861 | } | 1849 | } |
1862 | 1850 | ||
1863 | static void __devinit hardcode_find_bmc(void) | 1851 | static int __devinit hardcode_find_bmc(void) |
1864 | { | 1852 | { |
1853 | int ret = -ENODEV; | ||
1865 | int i; | 1854 | int i; |
1866 | struct smi_info *info; | 1855 | struct smi_info *info; |
1867 | 1856 | ||
@@ -1871,7 +1860,7 @@ static void __devinit hardcode_find_bmc(void) | |||
1871 | 1860 | ||
1872 | info = smi_info_alloc(); | 1861 | info = smi_info_alloc(); |
1873 | if (!info) | 1862 | if (!info) |
1874 | return; | 1863 | return -ENOMEM; |
1875 | 1864 | ||
1876 | info->addr_source = SI_HARDCODED; | 1865 | info->addr_source = SI_HARDCODED; |
1877 | printk(KERN_INFO PFX "probing via hardcoded address\n"); | 1866 | printk(KERN_INFO PFX "probing via hardcoded address\n"); |
@@ -1924,10 +1913,12 @@ static void __devinit hardcode_find_bmc(void) | |||
1924 | if (!add_smi(info)) { | 1913 | if (!add_smi(info)) { |
1925 | if (try_smi_init(info)) | 1914 | if (try_smi_init(info)) |
1926 | cleanup_one_si(info); | 1915 | cleanup_one_si(info); |
1916 | ret = 0; | ||
1927 | } else { | 1917 | } else { |
1928 | kfree(info); | 1918 | kfree(info); |
1929 | } | 1919 | } |
1930 | } | 1920 | } |
1921 | return ret; | ||
1931 | } | 1922 | } |
1932 | 1923 | ||
1933 | #ifdef CONFIG_ACPI | 1924 | #ifdef CONFIG_ACPI |
@@ -2555,11 +2546,9 @@ static struct pci_driver ipmi_pci_driver = { | |||
2555 | }; | 2546 | }; |
2556 | #endif /* CONFIG_PCI */ | 2547 | #endif /* CONFIG_PCI */ |
2557 | 2548 | ||
2558 | 2549 | static int __devinit ipmi_probe(struct platform_device *dev) | |
2559 | #ifdef CONFIG_PPC_OF | ||
2560 | static int __devinit ipmi_of_probe(struct platform_device *dev, | ||
2561 | const struct of_device_id *match) | ||
2562 | { | 2550 | { |
2551 | #ifdef CONFIG_OF | ||
2563 | struct smi_info *info; | 2552 | struct smi_info *info; |
2564 | struct resource resource; | 2553 | struct resource resource; |
2565 | const __be32 *regsize, *regspacing, *regshift; | 2554 | const __be32 *regsize, *regspacing, *regshift; |
@@ -2569,6 +2558,9 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, | |||
2569 | 2558 | ||
2570 | dev_info(&dev->dev, "probing via device tree\n"); | 2559 | dev_info(&dev->dev, "probing via device tree\n"); |
2571 | 2560 | ||
2561 | if (!dev->dev.of_match) | ||
2562 | return -EINVAL; | ||
2563 | |||
2572 | ret = of_address_to_resource(np, 0, &resource); | 2564 | ret = of_address_to_resource(np, 0, &resource); |
2573 | if (ret) { | 2565 | if (ret) { |
2574 | dev_warn(&dev->dev, PFX "invalid address from OF\n"); | 2566 | dev_warn(&dev->dev, PFX "invalid address from OF\n"); |
@@ -2601,7 +2593,7 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, | |||
2601 | return -ENOMEM; | 2593 | return -ENOMEM; |
2602 | } | 2594 | } |
2603 | 2595 | ||
2604 | info->si_type = (enum si_type) match->data; | 2596 | info->si_type = (enum si_type) dev->dev.of_match->data; |
2605 | info->addr_source = SI_DEVICETREE; | 2597 | info->addr_source = SI_DEVICETREE; |
2606 | info->irq_setup = std_irq_setup; | 2598 | info->irq_setup = std_irq_setup; |
2607 | 2599 | ||
@@ -2632,13 +2624,15 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, | |||
2632 | kfree(info); | 2624 | kfree(info); |
2633 | return -EBUSY; | 2625 | return -EBUSY; |
2634 | } | 2626 | } |
2635 | 2627 | #endif | |
2636 | return 0; | 2628 | return 0; |
2637 | } | 2629 | } |
2638 | 2630 | ||
2639 | static int __devexit ipmi_of_remove(struct platform_device *dev) | 2631 | static int __devexit ipmi_remove(struct platform_device *dev) |
2640 | { | 2632 | { |
2633 | #ifdef CONFIG_OF | ||
2641 | cleanup_one_si(dev_get_drvdata(&dev->dev)); | 2634 | cleanup_one_si(dev_get_drvdata(&dev->dev)); |
2635 | #endif | ||
2642 | return 0; | 2636 | return 0; |
2643 | } | 2637 | } |
2644 | 2638 | ||
@@ -2653,16 +2647,15 @@ static struct of_device_id ipmi_match[] = | |||
2653 | {}, | 2647 | {}, |
2654 | }; | 2648 | }; |
2655 | 2649 | ||
2656 | static struct of_platform_driver ipmi_of_platform_driver = { | 2650 | static struct platform_driver ipmi_driver = { |
2657 | .driver = { | 2651 | .driver = { |
2658 | .name = "ipmi", | 2652 | .name = DEVICE_NAME, |
2659 | .owner = THIS_MODULE, | 2653 | .owner = THIS_MODULE, |
2660 | .of_match_table = ipmi_match, | 2654 | .of_match_table = ipmi_match, |
2661 | }, | 2655 | }, |
2662 | .probe = ipmi_of_probe, | 2656 | .probe = ipmi_probe, |
2663 | .remove = __devexit_p(ipmi_of_remove), | 2657 | .remove = __devexit_p(ipmi_remove), |
2664 | }; | 2658 | }; |
2665 | #endif /* CONFIG_PPC_OF */ | ||
2666 | 2659 | ||
2667 | static int wait_for_msg_done(struct smi_info *smi_info) | 2660 | static int wait_for_msg_done(struct smi_info *smi_info) |
2668 | { | 2661 | { |
@@ -3340,8 +3333,7 @@ static int __devinit init_ipmi_si(void) | |||
3340 | return 0; | 3333 | return 0; |
3341 | initialized = 1; | 3334 | initialized = 1; |
3342 | 3335 | ||
3343 | /* Register the device drivers. */ | 3336 | rv = platform_driver_register(&ipmi_driver); |
3344 | rv = driver_register(&ipmi_driver.driver); | ||
3345 | if (rv) { | 3337 | if (rv) { |
3346 | printk(KERN_ERR PFX "Unable to register driver: %d\n", rv); | 3338 | printk(KERN_ERR PFX "Unable to register driver: %d\n", rv); |
3347 | return rv; | 3339 | return rv; |
@@ -3365,15 +3357,9 @@ static int __devinit init_ipmi_si(void) | |||
3365 | 3357 | ||
3366 | printk(KERN_INFO "IPMI System Interface driver.\n"); | 3358 | printk(KERN_INFO "IPMI System Interface driver.\n"); |
3367 | 3359 | ||
3368 | hardcode_find_bmc(); | ||
3369 | |||
3370 | /* If the user gave us a device, they presumably want us to use it */ | 3360 | /* If the user gave us a device, they presumably want us to use it */ |
3371 | mutex_lock(&smi_infos_lock); | 3361 | if (!hardcode_find_bmc()) |
3372 | if (!list_empty(&smi_infos)) { | ||
3373 | mutex_unlock(&smi_infos_lock); | ||
3374 | return 0; | 3362 | return 0; |
3375 | } | ||
3376 | mutex_unlock(&smi_infos_lock); | ||
3377 | 3363 | ||
3378 | #ifdef CONFIG_PCI | 3364 | #ifdef CONFIG_PCI |
3379 | rv = pci_register_driver(&ipmi_pci_driver); | 3365 | rv = pci_register_driver(&ipmi_pci_driver); |
@@ -3396,11 +3382,6 @@ static int __devinit init_ipmi_si(void) | |||
3396 | spmi_find_bmc(); | 3382 | spmi_find_bmc(); |
3397 | #endif | 3383 | #endif |
3398 | 3384 | ||
3399 | #ifdef CONFIG_PPC_OF | ||
3400 | of_register_platform_driver(&ipmi_of_platform_driver); | ||
3401 | of_registered = 1; | ||
3402 | #endif | ||
3403 | |||
3404 | /* We prefer devices with interrupts, but in the case of a machine | 3385 | /* We prefer devices with interrupts, but in the case of a machine |
3405 | with multiple BMCs we assume that there will be several instances | 3386 | with multiple BMCs we assume that there will be several instances |
3406 | of a given type so if we succeed in registering a type then also | 3387 | of a given type so if we succeed in registering a type then also |
@@ -3548,17 +3529,12 @@ static void __exit cleanup_ipmi_si(void) | |||
3548 | pnp_unregister_driver(&ipmi_pnp_driver); | 3529 | pnp_unregister_driver(&ipmi_pnp_driver); |
3549 | #endif | 3530 | #endif |
3550 | 3531 | ||
3551 | #ifdef CONFIG_PPC_OF | 3532 | platform_driver_unregister(&ipmi_driver); |
3552 | if (of_registered) | ||
3553 | of_unregister_platform_driver(&ipmi_of_platform_driver); | ||
3554 | #endif | ||
3555 | 3533 | ||
3556 | mutex_lock(&smi_infos_lock); | 3534 | mutex_lock(&smi_infos_lock); |
3557 | list_for_each_entry_safe(e, tmp_e, &smi_infos, link) | 3535 | list_for_each_entry_safe(e, tmp_e, &smi_infos, link) |
3558 | cleanup_one_si(e); | 3536 | cleanup_one_si(e); |
3559 | mutex_unlock(&smi_infos_lock); | 3537 | mutex_unlock(&smi_infos_lock); |
3560 | |||
3561 | driver_unregister(&ipmi_driver.driver); | ||
3562 | } | 3538 | } |
3563 | module_exit(cleanup_ipmi_si); | 3539 | module_exit(cleanup_ipmi_si); |
3564 | 3540 | ||