Commit 48705693 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

mei: Remove all bus devices from the mei_dev list when stopping the MEI

When stopping the MEI, we should remove and potentially unregister
all bus devices queued on the mei_dev linked list.
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ba4b60e8
...@@ -524,6 +524,22 @@ void mei_cl_bus_rx_event(struct mei_cl *cl) ...@@ -524,6 +524,22 @@ void mei_cl_bus_rx_event(struct mei_cl *cl)
schedule_work(&device->event_work); schedule_work(&device->event_work);
} }
void mei_cl_bus_remove_devices(struct mei_device *dev)
{
struct mei_cl *cl, *next;
mutex_lock(&dev->device_lock);
list_for_each_entry_safe(cl, next, &dev->device_list, device_link) {
if (cl->device)
mei_cl_remove_device(cl->device);
list_del(&cl->device_link);
mei_cl_unlink(cl);
kfree(cl);
}
mutex_unlock(&dev->device_lock);
}
int __init mei_cl_bus_init(void) int __init mei_cl_bus_init(void)
{ {
return bus_register(&mei_cl_bus_type); return bus_register(&mei_cl_bus_type);
......
...@@ -288,6 +288,8 @@ void mei_stop(struct mei_device *dev) ...@@ -288,6 +288,8 @@ void mei_stop(struct mei_device *dev)
mei_nfc_host_exit(dev); mei_nfc_host_exit(dev);
mei_cl_bus_remove_devices(dev);
mutex_lock(&dev->device_lock); mutex_lock(&dev->device_lock);
mei_wd_stop(dev); mei_wd_stop(dev);
......
...@@ -296,6 +296,7 @@ int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length); ...@@ -296,6 +296,7 @@ int __mei_cl_async_send(struct mei_cl *cl, u8 *buf, size_t length);
int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length); int __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length);
int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length); int __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length);
void mei_cl_bus_rx_event(struct mei_cl *cl); void mei_cl_bus_rx_event(struct mei_cl *cl);
void mei_cl_bus_remove_devices(struct mei_device *dev);
int mei_cl_bus_init(void); int mei_cl_bus_init(void);
void mei_cl_bus_exit(void); void mei_cl_bus_exit(void);
......
...@@ -552,13 +552,7 @@ int mei_nfc_host_init(struct mei_device *dev) ...@@ -552,13 +552,7 @@ int mei_nfc_host_init(struct mei_device *dev)
void mei_nfc_host_exit(struct mei_device *dev) void mei_nfc_host_exit(struct mei_device *dev)
{ {
struct mei_nfc_dev *ndev = &nfc_dev; struct mei_nfc_dev *ndev = &nfc_dev;
cancel_work_sync(&ndev->init_work); cancel_work_sync(&ndev->init_work);
}
mutex_lock(&dev->device_lock);
if (ndev->cl && ndev->cl->device)
mei_cl_remove_device(ndev->cl->device);
mei_nfc_free(ndev);
mutex_unlock(&dev->device_lock);
}
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