mei: nfc: clean nfc internal struct on host exit
NFC internal structure cleaning was dropped by commit
commit 487056932d
Author: Tomas Winkler <tomas.winkler@intel.com>
Date: Mon Feb 17 15:13:19 2014 +0200
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.
We allocate nfc_dev and free it across the reset
so we do not keep it in dirty state
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
148b1fda69
commit
a176c24dc9
3 changed files with 46 additions and 11 deletions
|
@ -140,7 +140,7 @@ static struct device_type mei_cl_device_type = {
|
||||||
.release = mei_cl_dev_release,
|
.release = mei_cl_dev_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev,
|
struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev,
|
||||||
uuid_le uuid)
|
uuid_le uuid)
|
||||||
{
|
{
|
||||||
struct mei_cl *cl;
|
struct mei_cl *cl;
|
||||||
|
@ -160,7 +160,7 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
|
||||||
struct mei_cl *cl;
|
struct mei_cl *cl;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
cl = mei_bus_find_mei_cl_by_uuid(dev, uuid);
|
cl = mei_cl_bus_find_cl_by_uuid(dev, uuid);
|
||||||
if (cl == NULL)
|
if (cl == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -349,6 +349,7 @@ void mei_cl_bus_rx_event(struct mei_cl *cl);
|
||||||
void mei_cl_bus_remove_devices(struct mei_device *dev);
|
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);
|
||||||
|
struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -117,8 +117,6 @@ struct mei_nfc_dev {
|
||||||
u16 recv_req_id;
|
u16 recv_req_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct mei_nfc_dev nfc_dev;
|
|
||||||
|
|
||||||
/* UUIDs for NFC F/W clients */
|
/* UUIDs for NFC F/W clients */
|
||||||
const uuid_le mei_nfc_guid = UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50,
|
const uuid_le mei_nfc_guid = UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50,
|
||||||
0x94, 0xd4, 0x50, 0x26,
|
0x94, 0xd4, 0x50, 0x26,
|
||||||
|
@ -138,6 +136,9 @@ static const uuid_le mei_nfc_info_guid = UUID_LE(0xd2de1625, 0x382d, 0x417d,
|
||||||
|
|
||||||
static void mei_nfc_free(struct mei_nfc_dev *ndev)
|
static void mei_nfc_free(struct mei_nfc_dev *ndev)
|
||||||
{
|
{
|
||||||
|
if (!ndev)
|
||||||
|
return;
|
||||||
|
|
||||||
if (ndev->cl) {
|
if (ndev->cl) {
|
||||||
list_del(&ndev->cl->device_link);
|
list_del(&ndev->cl->device_link);
|
||||||
mei_cl_unlink(ndev->cl);
|
mei_cl_unlink(ndev->cl);
|
||||||
|
@ -150,7 +151,7 @@ static void mei_nfc_free(struct mei_nfc_dev *ndev)
|
||||||
kfree(ndev->cl_info);
|
kfree(ndev->cl_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(ndev, 0, sizeof(struct mei_nfc_dev));
|
kfree(ndev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
|
static int mei_nfc_build_bus_name(struct mei_nfc_dev *ndev)
|
||||||
|
@ -319,9 +320,10 @@ err:
|
||||||
static int mei_nfc_enable(struct mei_cl_device *cldev)
|
static int mei_nfc_enable(struct mei_cl_device *cldev)
|
||||||
{
|
{
|
||||||
struct mei_device *dev;
|
struct mei_device *dev;
|
||||||
struct mei_nfc_dev *ndev = &nfc_dev;
|
struct mei_nfc_dev *ndev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
ndev = (struct mei_nfc_dev *)cldev->priv_data;
|
||||||
dev = ndev->cl->dev;
|
dev = ndev->cl->dev;
|
||||||
|
|
||||||
ret = mei_nfc_connect(ndev);
|
ret = mei_nfc_connect(ndev);
|
||||||
|
@ -479,15 +481,25 @@ err:
|
||||||
|
|
||||||
int mei_nfc_host_init(struct mei_device *dev)
|
int mei_nfc_host_init(struct mei_device *dev)
|
||||||
{
|
{
|
||||||
struct mei_nfc_dev *ndev = &nfc_dev;
|
struct mei_nfc_dev *ndev;
|
||||||
struct mei_cl *cl_info, *cl = NULL;
|
struct mei_cl *cl_info, *cl = NULL;
|
||||||
struct mei_me_client *me_cl;
|
struct mei_me_client *me_cl;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* already initialized */
|
|
||||||
if (ndev->cl_info)
|
/* in case of internal reset bail out
|
||||||
|
* as the device is already setup
|
||||||
|
*/
|
||||||
|
cl = mei_cl_bus_find_cl_by_uuid(dev, mei_nfc_guid);
|
||||||
|
if (cl)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
ndev = kzalloc(sizeof(struct mei_nfc_dev), GFP_KERNEL);
|
||||||
|
if (!ndev) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
ndev->cl_info = mei_cl_allocate(dev);
|
ndev->cl_info = mei_cl_allocate(dev);
|
||||||
ndev->cl = mei_cl_allocate(dev);
|
ndev->cl = mei_cl_allocate(dev);
|
||||||
|
|
||||||
|
@ -550,9 +562,31 @@ err:
|
||||||
|
|
||||||
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;
|
||||||
|
struct mei_cl *cl;
|
||||||
|
struct mei_cl_device *cldev;
|
||||||
|
|
||||||
cancel_work_sync(&ndev->init_work);
|
cl = mei_cl_bus_find_cl_by_uuid(dev, mei_nfc_guid);
|
||||||
|
if (!cl)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cldev = cl->device;
|
||||||
|
if (!cldev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ndev = (struct mei_nfc_dev *)cldev->priv_data;
|
||||||
|
if (ndev)
|
||||||
|
cancel_work_sync(&ndev->init_work);
|
||||||
|
|
||||||
|
cldev->priv_data = NULL;
|
||||||
|
|
||||||
|
mutex_lock(&dev->device_lock);
|
||||||
|
/* Need to remove the device here
|
||||||
|
* since mei_nfc_free will unlink the clients
|
||||||
|
*/
|
||||||
|
mei_cl_remove_device(cldev);
|
||||||
|
mei_nfc_free(ndev);
|
||||||
|
mutex_unlock(&dev->device_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue