Commit a313dec6 authored by Corey Minyard's avatar Corey Minyard

ipmi_ssif: Convert over to a shutdown handler

Move the shutdown handling to a shutdown function called from
the IPMI core code.  That makes for a cleaner shutdown.
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
parent 7960f18a
...@@ -1225,25 +1225,9 @@ static const struct attribute_group ipmi_ssif_dev_attr_group = { ...@@ -1225,25 +1225,9 @@ static const struct attribute_group ipmi_ssif_dev_attr_group = {
.attrs = ipmi_ssif_dev_attrs, .attrs = ipmi_ssif_dev_attrs,
}; };
static int ssif_remove(struct i2c_client *client) static void shutdown_ssif(void *send_info)
{ {
struct ssif_info *ssif_info = i2c_get_clientdata(client); struct ssif_info *ssif_info = send_info;
struct ssif_addr_info *addr_info;
int rv;
if (!ssif_info)
return 0;
/*
* After this point, we won't deliver anything asychronously
* to the message handler. We can unregister ourself.
*/
rv = ipmi_unregister_smi(ssif_info->intf);
if (rv) {
pr_err(PFX "Unable to unregister device: errno=%d\n", rv);
return rv;
}
ssif_info->intf = NULL;
device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group); device_remove_group(&ssif_info->client->dev, &ipmi_ssif_dev_attr_group);
dev_set_drvdata(&ssif_info->client->dev, NULL); dev_set_drvdata(&ssif_info->client->dev, NULL);
...@@ -1259,6 +1243,33 @@ static int ssif_remove(struct i2c_client *client) ...@@ -1259,6 +1243,33 @@ static int ssif_remove(struct i2c_client *client)
kthread_stop(ssif_info->thread); kthread_stop(ssif_info->thread);
} }
/*
* No message can be outstanding now, we have removed the
* upper layer and it permitted us to do so.
*/
kfree(ssif_info);
}
static int ssif_remove(struct i2c_client *client)
{
struct ssif_info *ssif_info = i2c_get_clientdata(client);
struct ipmi_smi *intf;
struct ssif_addr_info *addr_info;
int rv;
if (!ssif_info)
return 0;
/*
* After this point, we won't deliver anything asychronously
* to the message handler. We can unregister ourself.
*/
intf = ssif_info->intf;
ssif_info->intf = NULL;
rv = ipmi_unregister_smi(intf);
if (rv)
pr_err(PFX "Unable to unregister device: errno=%d\n", rv);
list_for_each_entry(addr_info, &ssif_infos, link) { list_for_each_entry(addr_info, &ssif_infos, link) {
if (addr_info->client == client) { if (addr_info->client == client) {
addr_info->client = NULL; addr_info->client = NULL;
...@@ -1266,12 +1277,7 @@ static int ssif_remove(struct i2c_client *client) ...@@ -1266,12 +1277,7 @@ static int ssif_remove(struct i2c_client *client)
} }
} }
/* return rv;
* No message can be outstanding now, we have removed the
* upper layer and it permitted us to do so.
*/
kfree(ssif_info);
return 0;
} }
static int do_cmd(struct i2c_client *client, int len, unsigned char *msg, static int do_cmd(struct i2c_client *client, int len, unsigned char *msg,
...@@ -1697,6 +1703,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -1697,6 +1703,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id)
ssif_info->handlers.owner = THIS_MODULE; ssif_info->handlers.owner = THIS_MODULE;
ssif_info->handlers.start_processing = ssif_start_processing; ssif_info->handlers.start_processing = ssif_start_processing;
ssif_info->handlers.shutdown = shutdown_ssif;
ssif_info->handlers.get_smi_info = get_smi_info; ssif_info->handlers.get_smi_info = get_smi_info;
ssif_info->handlers.sender = sender; ssif_info->handlers.sender = sender;
ssif_info->handlers.request_events = request_events; ssif_info->handlers.request_events = request_events;
......
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