Commit a9137c3d authored by Jeremy Kerr's avatar Jeremy Kerr Committed by Corey Minyard

ipmi: Add a reference from BMC devices to their interfaces

In an upcoming change, we'll want to grab a reference to the ipmi_smi_t
from a struct bmc_device. This change adds a pointer to allow this.
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>

Reworked to support multiple interfaces on a BMC.
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
parent 511d57dc
......@@ -265,6 +265,7 @@ struct ipmi_proc_entry {
struct bmc_device {
struct platform_device pdev;
struct ipmi_device_id id;
struct list_head intfs;
unsigned char guid[16];
int guid_set;
char name[16];
......@@ -404,6 +405,7 @@ struct ipmi_smi {
struct bmc_device *bmc;
bool bmc_registered;
struct list_head bmc_link;
char *my_dev_name;
/*
......@@ -2616,6 +2618,8 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
intf->my_dev_name = NULL;
mutex_lock(&ipmidriver_mutex);
list_del(&intf->bmc_link);
intf->bmc = NULL;
kref_put(&bmc->usecount, cleanup_bmc_device);
mutex_unlock(&ipmidriver_mutex);
intf->bmc_registered = false;
......@@ -2646,7 +2650,10 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum)
*/
if (old_bmc) {
kfree(bmc);
mutex_lock(&ipmidriver_mutex);
intf->bmc = old_bmc;
list_add_tail(&intf->bmc_link, &bmc->intfs);
mutex_unlock(&ipmidriver_mutex);
bmc = old_bmc;
printk(KERN_INFO
......@@ -2697,6 +2704,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum)
kref_init(&bmc->usecount);
rv = platform_device_register(&bmc->pdev);
list_add_tail(&intf->bmc_link, &bmc->intfs);
mutex_unlock(&ipmidriver_mutex);
if (rv) {
printk(KERN_ERR
......@@ -2761,6 +2769,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum)
out_put_bmc:
mutex_lock(&ipmidriver_mutex);
list_del(&intf->bmc_link);
intf->bmc = NULL;
kref_put(&bmc->usecount, cleanup_bmc_device);
mutex_unlock(&ipmidriver_mutex);
......@@ -2768,6 +2777,7 @@ static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum)
out_list_del:
mutex_lock(&ipmidriver_mutex);
list_del(&intf->bmc_link);
intf->bmc = NULL;
mutex_unlock(&ipmidriver_mutex);
put_device(&bmc->pdev.dev);
......@@ -2990,6 +3000,7 @@ int ipmi_register_smi(const struct ipmi_smi_handlers *handlers,
kfree(intf);
return -ENOMEM;
}
INIT_LIST_HEAD(&intf->bmc->intfs);
intf->intf_num = -1; /* Mark it invalid for now. */
kref_init(&intf->refcount);
intf->bmc->id = *device_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment