diff options
Diffstat (limited to 'drivers/char/ipmi/ipmi_si_intf.c')
-rw-r--r-- | drivers/char/ipmi/ipmi_si_intf.c | 84 |
1 files changed, 34 insertions, 50 deletions
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 7855f9f45b8e..cc6c9b2546a3 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; |
@@ -351,7 +339,7 @@ static void return_hosed_msg(struct smi_info *smi_info, int cCode) | |||
351 | cCode = IPMI_ERR_UNSPECIFIED; | 339 | cCode = IPMI_ERR_UNSPECIFIED; |
352 | /* else use it as is */ | 340 | /* else use it as is */ |
353 | 341 | ||
354 | /* Make it a reponse */ | 342 | /* Make it a response */ |
355 | msg->rsp[0] = msg->data[0] | 4; | 343 | msg->rsp[0] = msg->data[0] | 4; |
356 | msg->rsp[1] = msg->data[1]; | 344 | msg->rsp[1] = msg->data[1]; |
357 | msg->rsp[2] = cCode; | 345 | msg->rsp[2] = cCode; |
@@ -900,6 +888,14 @@ static void sender(void *send_info, | |||
900 | printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec); | 888 | printk("**Enqueue: %d.%9.9d\n", t.tv_sec, t.tv_usec); |
901 | #endif | 889 | #endif |
902 | 890 | ||
891 | /* | ||
892 | * last_timeout_jiffies is updated here to avoid | ||
893 | * smi_timeout() handler passing very large time_diff | ||
894 | * value to smi_event_handler() that causes | ||
895 | * the send command to abort. | ||
896 | */ | ||
897 | smi_info->last_timeout_jiffies = jiffies; | ||
898 | |||
903 | mod_timer(&smi_info->si_timer, jiffies + SI_TIMEOUT_JIFFIES); | 899 | mod_timer(&smi_info->si_timer, jiffies + SI_TIMEOUT_JIFFIES); |
904 | 900 | ||
905 | if (smi_info->thread) | 901 | if (smi_info->thread) |
@@ -1860,8 +1856,9 @@ static int hotmod_handler(const char *val, struct kernel_param *kp) | |||
1860 | return rv; | 1856 | return rv; |
1861 | } | 1857 | } |
1862 | 1858 | ||
1863 | static void __devinit hardcode_find_bmc(void) | 1859 | static int __devinit hardcode_find_bmc(void) |
1864 | { | 1860 | { |
1861 | int ret = -ENODEV; | ||
1865 | int i; | 1862 | int i; |
1866 | struct smi_info *info; | 1863 | struct smi_info *info; |
1867 | 1864 | ||
@@ -1871,7 +1868,7 @@ static void __devinit hardcode_find_bmc(void) | |||
1871 | 1868 | ||
1872 | info = smi_info_alloc(); | 1869 | info = smi_info_alloc(); |
1873 | if (!info) | 1870 | if (!info) |
1874 | return; | 1871 | return -ENOMEM; |
1875 | 1872 | ||
1876 | info->addr_source = SI_HARDCODED; | 1873 | info->addr_source = SI_HARDCODED; |
1877 | printk(KERN_INFO PFX "probing via hardcoded address\n"); | 1874 | printk(KERN_INFO PFX "probing via hardcoded address\n"); |
@@ -1924,10 +1921,12 @@ static void __devinit hardcode_find_bmc(void) | |||
1924 | if (!add_smi(info)) { | 1921 | if (!add_smi(info)) { |
1925 | if (try_smi_init(info)) | 1922 | if (try_smi_init(info)) |
1926 | cleanup_one_si(info); | 1923 | cleanup_one_si(info); |
1924 | ret = 0; | ||
1927 | } else { | 1925 | } else { |
1928 | kfree(info); | 1926 | kfree(info); |
1929 | } | 1927 | } |
1930 | } | 1928 | } |
1929 | return ret; | ||
1931 | } | 1930 | } |
1932 | 1931 | ||
1933 | #ifdef CONFIG_ACPI | 1932 | #ifdef CONFIG_ACPI |
@@ -2555,11 +2554,9 @@ static struct pci_driver ipmi_pci_driver = { | |||
2555 | }; | 2554 | }; |
2556 | #endif /* CONFIG_PCI */ | 2555 | #endif /* CONFIG_PCI */ |
2557 | 2556 | ||
2558 | 2557 | 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 | { | 2558 | { |
2559 | #ifdef CONFIG_OF | ||
2563 | struct smi_info *info; | 2560 | struct smi_info *info; |
2564 | struct resource resource; | 2561 | struct resource resource; |
2565 | const __be32 *regsize, *regspacing, *regshift; | 2562 | const __be32 *regsize, *regspacing, *regshift; |
@@ -2569,6 +2566,9 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, | |||
2569 | 2566 | ||
2570 | dev_info(&dev->dev, "probing via device tree\n"); | 2567 | dev_info(&dev->dev, "probing via device tree\n"); |
2571 | 2568 | ||
2569 | if (!dev->dev.of_match) | ||
2570 | return -EINVAL; | ||
2571 | |||
2572 | ret = of_address_to_resource(np, 0, &resource); | 2572 | ret = of_address_to_resource(np, 0, &resource); |
2573 | if (ret) { | 2573 | if (ret) { |
2574 | dev_warn(&dev->dev, PFX "invalid address from OF\n"); | 2574 | dev_warn(&dev->dev, PFX "invalid address from OF\n"); |
@@ -2601,7 +2601,7 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, | |||
2601 | return -ENOMEM; | 2601 | return -ENOMEM; |
2602 | } | 2602 | } |
2603 | 2603 | ||
2604 | info->si_type = (enum si_type) match->data; | 2604 | info->si_type = (enum si_type) dev->dev.of_match->data; |
2605 | info->addr_source = SI_DEVICETREE; | 2605 | info->addr_source = SI_DEVICETREE; |
2606 | info->irq_setup = std_irq_setup; | 2606 | info->irq_setup = std_irq_setup; |
2607 | 2607 | ||
@@ -2632,13 +2632,15 @@ static int __devinit ipmi_of_probe(struct platform_device *dev, | |||
2632 | kfree(info); | 2632 | kfree(info); |
2633 | return -EBUSY; | 2633 | return -EBUSY; |
2634 | } | 2634 | } |
2635 | 2635 | #endif | |
2636 | return 0; | 2636 | return 0; |
2637 | } | 2637 | } |
2638 | 2638 | ||
2639 | static int __devexit ipmi_of_remove(struct platform_device *dev) | 2639 | static int __devexit ipmi_remove(struct platform_device *dev) |
2640 | { | 2640 | { |
2641 | #ifdef CONFIG_OF | ||
2641 | cleanup_one_si(dev_get_drvdata(&dev->dev)); | 2642 | cleanup_one_si(dev_get_drvdata(&dev->dev)); |
2643 | #endif | ||
2642 | return 0; | 2644 | return 0; |
2643 | } | 2645 | } |
2644 | 2646 | ||
@@ -2653,16 +2655,15 @@ static struct of_device_id ipmi_match[] = | |||
2653 | {}, | 2655 | {}, |
2654 | }; | 2656 | }; |
2655 | 2657 | ||
2656 | static struct of_platform_driver ipmi_of_platform_driver = { | 2658 | static struct platform_driver ipmi_driver = { |
2657 | .driver = { | 2659 | .driver = { |
2658 | .name = "ipmi", | 2660 | .name = DEVICE_NAME, |
2659 | .owner = THIS_MODULE, | 2661 | .owner = THIS_MODULE, |
2660 | .of_match_table = ipmi_match, | 2662 | .of_match_table = ipmi_match, |
2661 | }, | 2663 | }, |
2662 | .probe = ipmi_of_probe, | 2664 | .probe = ipmi_probe, |
2663 | .remove = __devexit_p(ipmi_of_remove), | 2665 | .remove = __devexit_p(ipmi_remove), |
2664 | }; | 2666 | }; |
2665 | #endif /* CONFIG_PPC_OF */ | ||
2666 | 2667 | ||
2667 | static int wait_for_msg_done(struct smi_info *smi_info) | 2668 | static int wait_for_msg_done(struct smi_info *smi_info) |
2668 | { | 2669 | { |
@@ -2926,7 +2927,7 @@ static void return_hosed_msg_badsize(struct smi_info *smi_info) | |||
2926 | { | 2927 | { |
2927 | struct ipmi_smi_msg *msg = smi_info->curr_msg; | 2928 | struct ipmi_smi_msg *msg = smi_info->curr_msg; |
2928 | 2929 | ||
2929 | /* Make it a reponse */ | 2930 | /* Make it a response */ |
2930 | msg->rsp[0] = msg->data[0] | 4; | 2931 | msg->rsp[0] = msg->data[0] | 4; |
2931 | msg->rsp[1] = msg->data[1]; | 2932 | msg->rsp[1] = msg->data[1]; |
2932 | msg->rsp[2] = CANNOT_RETURN_REQUESTED_LENGTH; | 2933 | msg->rsp[2] = CANNOT_RETURN_REQUESTED_LENGTH; |
@@ -3340,8 +3341,7 @@ static int __devinit init_ipmi_si(void) | |||
3340 | return 0; | 3341 | return 0; |
3341 | initialized = 1; | 3342 | initialized = 1; |
3342 | 3343 | ||
3343 | /* Register the device drivers. */ | 3344 | rv = platform_driver_register(&ipmi_driver); |
3344 | rv = driver_register(&ipmi_driver.driver); | ||
3345 | if (rv) { | 3345 | if (rv) { |
3346 | printk(KERN_ERR PFX "Unable to register driver: %d\n", rv); | 3346 | printk(KERN_ERR PFX "Unable to register driver: %d\n", rv); |
3347 | return rv; | 3347 | return rv; |
@@ -3365,15 +3365,9 @@ static int __devinit init_ipmi_si(void) | |||
3365 | 3365 | ||
3366 | printk(KERN_INFO "IPMI System Interface driver.\n"); | 3366 | printk(KERN_INFO "IPMI System Interface driver.\n"); |
3367 | 3367 | ||
3368 | hardcode_find_bmc(); | ||
3369 | |||
3370 | /* If the user gave us a device, they presumably want us to use it */ | 3368 | /* If the user gave us a device, they presumably want us to use it */ |
3371 | mutex_lock(&smi_infos_lock); | 3369 | if (!hardcode_find_bmc()) |
3372 | if (!list_empty(&smi_infos)) { | ||
3373 | mutex_unlock(&smi_infos_lock); | ||
3374 | return 0; | 3370 | return 0; |
3375 | } | ||
3376 | mutex_unlock(&smi_infos_lock); | ||
3377 | 3371 | ||
3378 | #ifdef CONFIG_PCI | 3372 | #ifdef CONFIG_PCI |
3379 | rv = pci_register_driver(&ipmi_pci_driver); | 3373 | rv = pci_register_driver(&ipmi_pci_driver); |
@@ -3396,11 +3390,6 @@ static int __devinit init_ipmi_si(void) | |||
3396 | spmi_find_bmc(); | 3390 | spmi_find_bmc(); |
3397 | #endif | 3391 | #endif |
3398 | 3392 | ||
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 | 3393 | /* We prefer devices with interrupts, but in the case of a machine |
3405 | with multiple BMCs we assume that there will be several instances | 3394 | 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 | 3395 | of a given type so if we succeed in registering a type then also |
@@ -3532,7 +3521,7 @@ static void cleanup_one_si(struct smi_info *to_clean) | |||
3532 | kfree(to_clean); | 3521 | kfree(to_clean); |
3533 | } | 3522 | } |
3534 | 3523 | ||
3535 | static void __exit cleanup_ipmi_si(void) | 3524 | static void cleanup_ipmi_si(void) |
3536 | { | 3525 | { |
3537 | struct smi_info *e, *tmp_e; | 3526 | struct smi_info *e, *tmp_e; |
3538 | 3527 | ||
@@ -3548,17 +3537,12 @@ static void __exit cleanup_ipmi_si(void) | |||
3548 | pnp_unregister_driver(&ipmi_pnp_driver); | 3537 | pnp_unregister_driver(&ipmi_pnp_driver); |
3549 | #endif | 3538 | #endif |
3550 | 3539 | ||
3551 | #ifdef CONFIG_PPC_OF | 3540 | platform_driver_unregister(&ipmi_driver); |
3552 | if (of_registered) | ||
3553 | of_unregister_platform_driver(&ipmi_of_platform_driver); | ||
3554 | #endif | ||
3555 | 3541 | ||
3556 | mutex_lock(&smi_infos_lock); | 3542 | mutex_lock(&smi_infos_lock); |
3557 | list_for_each_entry_safe(e, tmp_e, &smi_infos, link) | 3543 | list_for_each_entry_safe(e, tmp_e, &smi_infos, link) |
3558 | cleanup_one_si(e); | 3544 | cleanup_one_si(e); |
3559 | mutex_unlock(&smi_infos_lock); | 3545 | mutex_unlock(&smi_infos_lock); |
3560 | |||
3561 | driver_unregister(&ipmi_driver.driver); | ||
3562 | } | 3546 | } |
3563 | module_exit(cleanup_ipmi_si); | 3547 | module_exit(cleanup_ipmi_si); |
3564 | 3548 | ||