mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [char-misc V3 3.18] mei: nfc: clean nfc internal struct on host exit
@ 2014-11-04 14:14 Tomas Winkler
  2014-11-04 16:31 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Tomas Winkler @ 2014-11-04 14:14 UTC (permalink / raw)
  To: gregkh; +Cc: arnd, linux-kernel, Tomas Winkler, Alexander Usyskin

NFC internal structure cleaning was dropped by commit

commit 5ad1550a15cd5b75ed8aa3009e162822f720375e
Author: Tomas Winkler <tomas.winkler@intel.com>
Date:   Sun Jan 26 11:53:06 2014 +0200

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

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>
---
V2: allocate mei_nfc_dev dynamically
V3: Drop the stable request as manual rebase is required,
    a sperate request will be sent

 drivers/misc/mei/bus.c     |  4 ++--
 drivers/misc/mei/mei_dev.h |  1 +
 drivers/misc/mei/nfc.c     | 42 ++++++++++++++++++++++++++++++++----------
 3 files changed, 35 insertions(+), 12 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 4d20d60ca38d..b3a72bca5242 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -140,7 +140,7 @@ static struct device_type mei_cl_device_type = {
 	.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)
 {
 	struct mei_cl *cl;
@@ -160,7 +160,7 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
 	struct mei_cl *cl;
 	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)
 		return NULL;
 
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index 71744b16cc8c..1288a5cf60b9 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -349,6 +349,7 @@ 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);
 void mei_cl_bus_exit(void);
+struct mei_cl *mei_cl_bus_find_cl_by_uuid(struct mei_device *dev, uuid_le uuid);
 
 
 /**
diff --git a/drivers/misc/mei/nfc.c b/drivers/misc/mei/nfc.c
index 622654323177..82f38613c550 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,14 +481,16 @@ 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)
-		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 +554,27 @@ 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;
+
+	ndev = (struct mei_nfc_dev *)cldev->priv_data;
+	if (ndev)
+		cancel_work_sync(&ndev->init_work);
+
+	mutex_lock(&dev->device_lock);
+	mei_nfc_free(ndev);
+	mutex_unlock(&dev->device_lock);
 
-	cancel_work_sync(&ndev->init_work);
+	cldev->priv_data = NULL;
 }
 
 
-- 
1.9.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [char-misc V3 3.18] mei: nfc: clean nfc internal struct on host exit
  2014-11-04 14:14 [char-misc V3 3.18] mei: nfc: clean nfc internal struct on host exit Tomas Winkler
@ 2014-11-04 16:31 ` Greg KH
  2014-11-04 18:16   ` Winkler, Tomas
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2014-11-04 16:31 UTC (permalink / raw)
  To: Tomas Winkler; +Cc: arnd, linux-kernel, Alexander Usyskin

On Tue, Nov 04, 2014 at 04:14:49PM +0200, Tomas Winkler wrote:
> NFC internal structure cleaning was dropped by commit
> 
> commit 5ad1550a15cd5b75ed8aa3009e162822f720375e
> Author: Tomas Winkler <tomas.winkler@intel.com>
> Date:   Sun Jan 26 11:53:06 2014 +0200

Where is this commit id from?  I don't see it in Linus's tree.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [char-misc V3 3.18] mei: nfc: clean nfc internal struct on host exit
  2014-11-04 16:31 ` Greg KH
@ 2014-11-04 18:16   ` Winkler, Tomas
  0 siblings, 0 replies; 3+ messages in thread
From: Winkler, Tomas @ 2014-11-04 18:16 UTC (permalink / raw)
  To: Greg KH; +Cc: arnd, linux-kernel, Usyskin, Alexander



> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Tuesday, November 04, 2014 18:32
> To: Winkler, Tomas
> Cc: arnd@arndb.de; linux-kernel@vger.kernel.org; Usyskin, Alexander
> Subject: Re: [char-misc V3 3.18] mei: nfc: clean nfc internal struct on host exit
> 
> On Tue, Nov 04, 2014 at 04:14:49PM +0200, Tomas Winkler wrote:
> > NFC internal structure cleaning was dropped by commit
> >
> > commit 5ad1550a15cd5b75ed8aa3009e162822f720375e
> > Author: Tomas Winkler <tomas.winkler@intel.com>
> > Date:   Sun Jan 26 11:53:06 2014 +0200
> 
> Where is this commit id from?  I don't see it in Linus's tree.

This is the correct one 487056932d372cc4f6c636f21a928d6667b151d7
Will resend.
Tomas


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-04 18:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-04 14:14 [char-misc V3 3.18] mei: nfc: clean nfc internal struct on host exit Tomas Winkler
2014-11-04 16:31 ` Greg KH
2014-11-04 18:16   ` Winkler, Tomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®