diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2017-08-25 10:47:22 +0300 |
---|---|---|
committer | Corey Minyard <cminyard@mvista.com> | 2017-09-28 00:03:45 +0300 |
commit | a9137c3dfae9f371e302ee3fc6658f0fe6b904e7 (patch) | |
tree | d578baaca17eb9bbe8bc3dafc5733d938db0fcdf /drivers/char/ipmi | |
parent | 511d57dc71a22514e106f79a878e788cb22f73e3 (diff) | |
download | linux-a9137c3dfae9f371e302ee3fc6658f0fe6b904e7.tar.xz |
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: Jeremy Kerr <jk@ozlabs.org>
Reworked to support multiple interfaces on a BMC.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char/ipmi')
-rw-r--r-- | drivers/char/ipmi/ipmi_msghandler.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 89b72425f9ce..8814f4bed862 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -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 @@ out_unlink1: 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 @@ out_put_bmc: 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; |