From: Jeremy Kerr <j...@ozlabs.org> 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 <j...@ozlabs.org> Reworked to support multiple interfaces on a BMC. Signed-off-by: Corey Minyard <cminy...@mvista.com> --- drivers/char/ipmi/ipmi_msghandler.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 89b7242..8814f4b 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 @@ 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; -- 2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openipmi-developer mailing list Openipmi-developer@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openipmi-developer