mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Thalmeier <michael.thalmeier@hale.at>
To: Samuel Ortiz <sameo@linux.intel.com>
Cc: Lauro Ramos Venancio <lauro.venancio@openbossa.org>,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
	linux-kernel@vger.kernel.org, linux-nfc@ml01.01.org,
	michael@thalmeier.at
Subject: [PATCH 02/11] NFC: pn533: fix order of initialization
Date: Thu, 21 Apr 2016 16:43:50 +0200	[thread overview]
Message-ID: <1461249839-16962-3-git-send-email-michael.thalmeier@hale.at> (raw)
In-Reply-To: <1461249839-16962-1-git-send-email-michael.thalmeier@hale.at>

Correctly call nfc_set_parent_dev before nfc_register_device. Otherwise the
driver will oops when being removed.

Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
---
 drivers/nfc/pn533/i2c.c   | 3 ++-
 drivers/nfc/pn533/pn533.c | 4 +++-
 drivers/nfc/pn533/pn533.h | 3 ++-
 drivers/nfc/pn533/usb.c   | 3 +--
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/nfc/pn533/i2c.c b/drivers/nfc/pn533/i2c.c
index 1a622e1..0141f19 100644
--- a/drivers/nfc/pn533/i2c.c
+++ b/drivers/nfc/pn533/i2c.c
@@ -211,7 +211,8 @@ static int pn533_i2c_probe(struct i2c_client *client,
 				     PN533_NO_TYPE_B_PROTOCOLS,
 				     PN533_PROTO_REQ_ACK_RESP,
 				     phy, &i2c_phy_ops, NULL,
-				     &phy->i2c_dev->dev);
+				     &phy->i2c_dev->dev,
+				     &client->dev);
 
 	if (IS_ERR(priv)) {
 		r = PTR_ERR(priv);
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index ee9e8f1..d82eecd 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2554,7 +2554,8 @@ struct pn533 *pn533_register_device(u32 device_type,
 				void *phy,
 				struct pn533_phy_ops *phy_ops,
 				struct pn533_frame_ops *fops,
-				struct device *dev)
+				struct device *dev,
+				struct device *parent)
 {
 	struct pn533_fw_version fw_ver;
 	struct pn533 *priv;
@@ -2617,6 +2618,7 @@ struct pn533 *pn533_register_device(u32 device_type,
 		goto destroy_wq;
 	}
 
+	nfc_set_parent_dev(priv->nfc_dev, parent);
 	nfc_set_drvdata(priv->nfc_dev, priv);
 
 	rc = nfc_register_device(priv->nfc_dev);
diff --git a/drivers/nfc/pn533/pn533.h b/drivers/nfc/pn533/pn533.h
index ba604f6..553c7d1 100644
--- a/drivers/nfc/pn533/pn533.h
+++ b/drivers/nfc/pn533/pn533.h
@@ -228,7 +228,8 @@ struct pn533 *pn533_register_device(u32 device_type,
 				void *phy,
 				struct pn533_phy_ops *phy_ops,
 				struct pn533_frame_ops *fops,
-				struct device *dev);
+				struct device *dev,
+				struct device *parent);
 
 void pn533_unregister_device(struct pn533 *priv);
 void pn533_recv_frame(struct pn533 *dev, struct sk_buff *skb, int status);
diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index 4f73cbf..8ca0603 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -536,7 +536,7 @@ static int pn533_usb_probe(struct usb_interface *interface,
 
 	priv = pn533_register_device(id->driver_info, protocols, protocol_type,
 					phy, &usb_phy_ops, fops,
-					&phy->udev->dev);
+					&phy->udev->dev, &interface->dev);
 
 	if (IS_ERR(priv)) {
 		rc = PTR_ERR(priv);
@@ -544,7 +544,6 @@ static int pn533_usb_probe(struct usb_interface *interface,
 	}
 
 	phy->priv = priv;
-	nfc_set_parent_dev(priv->nfc_dev, &interface->dev);
 
 	usb_set_intfdata(interface, phy);
 
-- 
2.5.5

  parent reply	other threads:[~2016-04-21 14:44 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 14:43 [PATCH 00/11] NFC: pn533: bug fixes and improvements Michael Thalmeier
2016-04-21 14:43 ` [PATCH 01/11] NFC: pn533: i2c: free irq on driver remove Michael Thalmeier
2016-04-21 14:43 ` Michael Thalmeier [this message]
2016-04-21 14:43 ` [PATCH 03/11] NFC: pn533: i2c: do not call pn533_recv_frame with aborted commands Michael Thalmeier
2016-04-21 14:43 ` [PATCH 04/11] NFC: pn533: reset poll modulation list before calling nfc_targets_found Michael Thalmeier
2016-04-21 14:43 ` [PATCH 05/11] NFC: pn533: handle interrupted commands in pn533_recv_frame Michael Thalmeier
2016-04-21 14:43 ` [PATCH 06/11] NFC: pn533: usb: fix errors when poll is stopped Michael Thalmeier
2016-05-01 23:17   ` Samuel Ortiz
2016-04-21 14:43 ` [PATCH 07/11] NFC: pn533: improve cmd queue handling Michael Thalmeier
2016-05-01 23:17   ` Samuel Ortiz
2016-04-21 14:43 ` [PATCH 08/11] NFC: pn533: reduce output when stopping poll Michael Thalmeier
2016-05-01 23:18   ` Samuel Ortiz
2016-04-21 14:43 ` [PATCH 09/11] NFC: pn533: use nfc_alloc_recv_skb for skb allocation Michael Thalmeier
2016-05-01 23:17   ` Samuel Ortiz
2016-04-21 14:43 ` [PATCH 10/11] NFC: pn533: set cmd status when not set Michael Thalmeier
2016-04-21 14:43 ` [PATCH 11/11] nfc: pn533: increase clock frequency for PN532 Michael Thalmeier
2016-04-28 18:18 ` [PATCH 00/11] NFC: pn533: bug fixes and improvements Olliver Schinagl
2016-05-04 15:18   ` Olliver Schinagl
2016-05-09 11:59     ` Olliver Schinagl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461249839-16962-3-git-send-email-michael.thalmeier@hale.at \
    --to=michael.thalmeier@hale.at \
    --cc=aloisio.almeida@openbossa.org \
    --cc=lauro.venancio@openbossa.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfc@ml01.01.org \
    --cc=michael@thalmeier.at \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®