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>
This commit is contained in:
Rob Herring 2011-02-23 15:37:59 -06:00 коммит произвёл Grant Likely
Родитель a314c5c004
Коммит a1e9c9dd33
1 изменённых файлов: 23 добавлений и 47 удалений

Просмотреть файл

@ -66,13 +66,10 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/pnp.h> #include <linux/pnp.h>
#ifdef CONFIG_PPC_OF
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/of_address.h> #include <linux/of_address.h>
#include <linux/of_irq.h> #include <linux/of_irq.h>
#endif
#define PFX "ipmi_si: " #define PFX "ipmi_si: "
@ -116,13 +113,7 @@ static char *ipmi_addr_src_to_str[] = { NULL, "hotmod", "hardcoded", "SPMI",
#define DEVICE_NAME "ipmi_si" #define DEVICE_NAME "ipmi_si"
static struct platform_driver ipmi_driver = { static struct platform_driver ipmi_driver;
.driver = {
.name = DEVICE_NAME,
.bus = &platform_bus_type
}
};
/* /*
* Indexes into stats[] in smi_info below. * Indexes into stats[] in smi_info below.
@ -308,9 +299,6 @@ static int pci_registered;
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
static int pnp_registered; static int pnp_registered;
#endif #endif
#ifdef CONFIG_PPC_OF
static int of_registered;
#endif
static unsigned int kipmid_max_busy_us[SI_MAX_PARMS]; static unsigned int kipmid_max_busy_us[SI_MAX_PARMS];
static int num_max_busy_us; static int num_max_busy_us;
@ -1860,8 +1848,9 @@ static int hotmod_handler(const char *val, struct kernel_param *kp)
return rv; return rv;
} }
static void __devinit hardcode_find_bmc(void) static int __devinit hardcode_find_bmc(void)
{ {
int ret = -ENODEV;
int i; int i;
struct smi_info *info; struct smi_info *info;
@ -1871,7 +1860,7 @@ static void __devinit hardcode_find_bmc(void)
info = smi_info_alloc(); info = smi_info_alloc();
if (!info) if (!info)
return; return -ENOMEM;
info->addr_source = SI_HARDCODED; info->addr_source = SI_HARDCODED;
printk(KERN_INFO PFX "probing via hardcoded address\n"); printk(KERN_INFO PFX "probing via hardcoded address\n");
@ -1924,10 +1913,12 @@ static void __devinit hardcode_find_bmc(void)
if (!add_smi(info)) { if (!add_smi(info)) {
if (try_smi_init(info)) if (try_smi_init(info))
cleanup_one_si(info); cleanup_one_si(info);
ret = 0;
} else { } else {
kfree(info); kfree(info);
} }
} }
return ret;
} }
#ifdef CONFIG_ACPI #ifdef CONFIG_ACPI
@ -2555,11 +2546,9 @@ static struct pci_driver ipmi_pci_driver = {
}; };
#endif /* CONFIG_PCI */ #endif /* CONFIG_PCI */
static int __devinit ipmi_probe(struct platform_device *dev)
#ifdef CONFIG_PPC_OF
static int __devinit ipmi_of_probe(struct platform_device *dev,
const struct of_device_id *match)
{ {
#ifdef CONFIG_OF
struct smi_info *info; struct smi_info *info;
struct resource resource; struct resource resource;
const __be32 *regsize, *regspacing, *regshift; const __be32 *regsize, *regspacing, *regshift;
@ -2569,6 +2558,9 @@ static int __devinit ipmi_of_probe(struct platform_device *dev,
dev_info(&dev->dev, "probing via device tree\n"); dev_info(&dev->dev, "probing via device tree\n");
if (!dev->dev.of_match)
return -EINVAL;
ret = of_address_to_resource(np, 0, &resource); ret = of_address_to_resource(np, 0, &resource);
if (ret) { if (ret) {
dev_warn(&dev->dev, PFX "invalid address from OF\n"); dev_warn(&dev->dev, PFX "invalid address from OF\n");
@ -2601,7 +2593,7 @@ static int __devinit ipmi_of_probe(struct platform_device *dev,
return -ENOMEM; return -ENOMEM;
} }
info->si_type = (enum si_type) match->data; info->si_type = (enum si_type) dev->dev.of_match->data;
info->addr_source = SI_DEVICETREE; info->addr_source = SI_DEVICETREE;
info->irq_setup = std_irq_setup; info->irq_setup = std_irq_setup;
@ -2632,13 +2624,15 @@ static int __devinit ipmi_of_probe(struct platform_device *dev,
kfree(info); kfree(info);
return -EBUSY; return -EBUSY;
} }
#endif
return 0; return 0;
} }
static int __devexit ipmi_of_remove(struct platform_device *dev) static int __devexit ipmi_remove(struct platform_device *dev)
{ {
#ifdef CONFIG_OF
cleanup_one_si(dev_get_drvdata(&dev->dev)); cleanup_one_si(dev_get_drvdata(&dev->dev));
#endif
return 0; return 0;
} }
@ -2653,16 +2647,15 @@ static struct of_device_id ipmi_match[] =
{}, {},
}; };
static struct of_platform_driver ipmi_of_platform_driver = { static struct platform_driver ipmi_driver = {
.driver = { .driver = {
.name = "ipmi", .name = DEVICE_NAME,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = ipmi_match, .of_match_table = ipmi_match,
}, },
.probe = ipmi_of_probe, .probe = ipmi_probe,
.remove = __devexit_p(ipmi_of_remove), .remove = __devexit_p(ipmi_remove),
}; };
#endif /* CONFIG_PPC_OF */
static int wait_for_msg_done(struct smi_info *smi_info) static int wait_for_msg_done(struct smi_info *smi_info)
{ {
@ -3340,8 +3333,7 @@ static int __devinit init_ipmi_si(void)
return 0; return 0;
initialized = 1; initialized = 1;
/* Register the device drivers. */ rv = platform_driver_register(&ipmi_driver);
rv = driver_register(&ipmi_driver.driver);
if (rv) { if (rv) {
printk(KERN_ERR PFX "Unable to register driver: %d\n", rv); printk(KERN_ERR PFX "Unable to register driver: %d\n", rv);
return rv; return rv;
@ -3365,15 +3357,9 @@ static int __devinit init_ipmi_si(void)
printk(KERN_INFO "IPMI System Interface driver.\n"); printk(KERN_INFO "IPMI System Interface driver.\n");
hardcode_find_bmc();
/* If the user gave us a device, they presumably want us to use it */ /* If the user gave us a device, they presumably want us to use it */
mutex_lock(&smi_infos_lock); if (!hardcode_find_bmc())
if (!list_empty(&smi_infos)) {
mutex_unlock(&smi_infos_lock);
return 0; return 0;
}
mutex_unlock(&smi_infos_lock);
#ifdef CONFIG_PCI #ifdef CONFIG_PCI
rv = pci_register_driver(&ipmi_pci_driver); rv = pci_register_driver(&ipmi_pci_driver);
@ -3396,11 +3382,6 @@ static int __devinit init_ipmi_si(void)
spmi_find_bmc(); spmi_find_bmc();
#endif #endif
#ifdef CONFIG_PPC_OF
of_register_platform_driver(&ipmi_of_platform_driver);
of_registered = 1;
#endif
/* We prefer devices with interrupts, but in the case of a machine /* We prefer devices with interrupts, but in the case of a machine
with multiple BMCs we assume that there will be several instances with multiple BMCs we assume that there will be several instances
of a given type so if we succeed in registering a type then also 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)
pnp_unregister_driver(&ipmi_pnp_driver); pnp_unregister_driver(&ipmi_pnp_driver);
#endif #endif
#ifdef CONFIG_PPC_OF platform_driver_unregister(&ipmi_driver);
if (of_registered)
of_unregister_platform_driver(&ipmi_of_platform_driver);
#endif
mutex_lock(&smi_infos_lock); mutex_lock(&smi_infos_lock);
list_for_each_entry_safe(e, tmp_e, &smi_infos, link) list_for_each_entry_safe(e, tmp_e, &smi_infos, link)
cleanup_one_si(e); cleanup_one_si(e);
mutex_unlock(&smi_infos_lock); mutex_unlock(&smi_infos_lock);
driver_unregister(&ipmi_driver.driver);
} }
module_exit(cleanup_ipmi_si); module_exit(cleanup_ipmi_si);