diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 16:43:47 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-14 16:43:47 -0800 |
commit | 6ae840e7cc4be0be3aa40d9f67c35c75cfc67d83 (patch) | |
tree | 9c83c87a8670ef678d95f8d6f76a07f24a09a49f /drivers/misc/mei/nfc.c | |
parent | e6b5be2be4e30037eb551e0ed09dd97bd00d85d3 (diff) | |
parent | 91905b6f4afe51e23a3f58df93e4cdc5e49cf40c (diff) | |
download | linux-6ae840e7cc4be0be3aa40d9f67c35c75cfc67d83.tar.bz2 |
Merge tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver updates from Greg KH:
"Here's the big char/misc driver update for 3.19-rc1
Lots of little things all over the place in different drivers, and a
new subsystem, "coresight" has been added. Full details are in the
shortlog"
* tag 'char-misc-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (73 commits)
parport: parport_pc, do not remove parent devices early
spmi: Remove shutdown/suspend/resume kernel-doc
carma-fpga-program: drop videobuf dependency
carma-fpga: drop videobuf dependency
carma-fpga-program.c: fix compile errors
i8k: Fix temperature bug handling in i8k_get_temp()
cxl: Name interrupts in /proc/interrupt
CXL: Return error to PSL if IRQ demultiplexing fails & print clearer warning
coresight-replicator: remove .owner field for driver
coresight: fixed comments in coresight.h
coresight: fix typo in comment in coresight-priv.h
coresight: bindings for coresight drivers
coresight: Adding ABI documentation
w1: support auto-load of w1_bq27000 module.
w1: avoid potential u16 overflow
cn: verify msg->len before making callback
mei: export fw status registers through sysfs
mei: read and print all six FW status registers
mei: txe: add cherrytrail device id
mei: kill cached host and me csr values
...
Diffstat (limited to 'drivers/misc/mei/nfc.c')
-rw-r--r-- | drivers/misc/mei/nfc.c | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c index 622654323177..60ca9240368e 100644 --- a/drivers/misc/mei/nfc.c +++ b/drivers/misc/mei/nfc.c @@ -117,8 +117,6 @@ struct mei_nfc_dev { u16 recv_req_id; }; -static struct mei_nfc_dev nfc_dev; - /* UUIDs for NFC F/W clients */ const uuid_le mei_nfc_guid = UUID_LE(0x0bb17a78, 0x2a8e, 0x4c50, 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) { + if (!ndev) + return; + if (ndev->cl) { list_del(&ndev->cl->device_link); mei_cl_unlink(ndev->cl); @@ -150,7 +151,7 @@ static void mei_nfc_free(struct mei_nfc_dev *ndev) 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) @@ -319,9 +320,10 @@ err: static int mei_nfc_enable(struct mei_cl_device *cldev) { struct mei_device *dev; - struct mei_nfc_dev *ndev = &nfc_dev; + struct mei_nfc_dev *ndev; int ret; + ndev = (struct mei_nfc_dev *)cldev->priv_data; dev = ndev->cl->dev; ret = mei_nfc_connect(ndev); @@ -479,15 +481,25 @@ err: 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_me_client *me_cl; 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; + ndev = kzalloc(sizeof(struct mei_nfc_dev), GFP_KERNEL); + if (!ndev) { + ret = -ENOMEM; + goto err; + } + ndev->cl_info = mei_cl_allocate(dev); ndev->cl = mei_cl_allocate(dev); @@ -550,9 +562,31 @@ err: 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; + + cl = mei_cl_bus_find_cl_by_uuid(dev, mei_nfc_guid); + if (!cl) + return; + + cldev = cl->device; + if (!cldev) + return; - cancel_work_sync(&ndev->init_work); + 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); } |