2016-04-21 14:46:37

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 00/11] NFC: pn533: bug fixes and improvements

Hello Samuel,

This patchset fixes some major bugs in the pn533 drivers (usb and i2c) and
improves performance of the PN532 chip by increasing its clock speed.

Best Regards
Michael

Michael Thalmeier (11):
NFC: pn533: i2c: free irq on driver remove
NFC: pn533: fix order of initialization
NFC: pn533: i2c: do not call pn533_recv_frame with aborted commands
NFC: pn533: reset poll modulation list before calling nfc_targets_found
NFC: pn533: handle interrupted commands in pn533_recv_frame
NFC: pn533: usb: fix errors when poll is stopped
NFC: pn533: improve cmd queue handling
NFC: pn533: reduce output when stopping poll
NFC: pn533: use nfc_alloc_recv_skb for skb allocation
NFC: pn533: set cmd status when not set
nfc: pn533: increase clock frequency for PN532

drivers/nfc/pn533/i2c.c | 20 ++++--
drivers/nfc/pn533/pn533.c | 154 +++++++++++++++++++++++++++++++++++++---------
drivers/nfc/pn533/pn533.h | 5 +-
drivers/nfc/pn533/usb.c | 15 +++--
4 files changed, 153 insertions(+), 41 deletions(-)

--
2.5.5


2016-04-21 14:44:51

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 11/11] nfc: pn533: increase clock frequency for PN532

Default clock frequency of PN532 is 6.78 MHz. Increase the frequency to 27.12
MHz to increase throughput.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/pn533.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++
drivers/nfc/pn533/pn533.h | 2 ++
2 files changed, 72 insertions(+)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index 44bc5e0..19ee4ba 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2469,6 +2469,63 @@ static int pn532_sam_configuration(struct nfc_dev *nfc_dev)
return 0;
}

+#define PN533_CFR_27 0x00
+#define PN533_CFR_13 0x01
+#define PN533_CFR_6 0x02
+
+static int pn533_get_cfr(struct nfc_dev *nfc_dev)
+{
+ struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+ struct sk_buff *skb;
+ struct sk_buff *resp;
+ int clk;
+
+ dev_dbg(dev->dev, "%s\n", __func__);
+
+ skb = pn533_alloc_skb(dev, 2);
+ if (!skb)
+ return -ENOMEM;
+
+ *skb_put(skb, 1) = 0x02;
+ *skb_put(skb, 1) = 0xFF;
+
+ resp = pn533_send_cmd_sync(dev, PN533_CMD_READ_REGISTER, skb);
+ if (IS_ERR(resp))
+ return PTR_ERR(resp);
+
+ if (resp->len != 1)
+ return -EINVAL;
+
+ clk = resp->data[0];
+
+ dev_kfree_skb(resp);
+ return clk;
+}
+
+static int pn533_set_cfr(struct nfc_dev *nfc_dev, int clk)
+{
+ struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+ struct sk_buff *skb;
+ struct sk_buff *resp;
+
+ dev_dbg(dev->dev, "%s\n", __func__);
+
+ skb = pn533_alloc_skb(dev, 3);
+ if (!skb)
+ return -ENOMEM;
+
+ *skb_put(skb, 1) = 0x02;
+ *skb_put(skb, 1) = 0xFF;
+ *skb_put(skb, 1) = clk & 0x03;
+
+ resp = pn533_send_cmd_sync(dev, PN533_CMD_WRITE_REGISTER, skb);
+ if (IS_ERR(resp))
+ return PTR_ERR(resp);
+
+ dev_kfree_skb(resp);
+ return 0;
+}
+
static int pn533_dev_up(struct nfc_dev *nfc_dev)
{
struct pn533 *dev = nfc_get_drvdata(nfc_dev);
@@ -2478,6 +2535,10 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev)

if (rc)
return rc;
+
+ rc = pn533_set_cfr(nfc_dev, PN533_CFR_27);
+ if (rc)
+ return rc;
}

return pn533_rf_field(nfc_dev, 1);
@@ -2485,6 +2546,15 @@ static int pn533_dev_up(struct nfc_dev *nfc_dev)

static int pn533_dev_down(struct nfc_dev *nfc_dev)
{
+ struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+
+ if (dev->device_type == PN533_DEVICE_PN532) {
+ int rc = pn533_set_cfr(nfc_dev, PN533_CFR_6);
+
+ if (rc)
+ return rc;
+ }
+
return pn533_rf_field(nfc_dev, 0);
}

diff --git a/drivers/nfc/pn533/pn533.h b/drivers/nfc/pn533/pn533.h
index 553c7d1..2bd3816 100644
--- a/drivers/nfc/pn533/pn533.h
+++ b/drivers/nfc/pn533/pn533.h
@@ -74,6 +74,8 @@
#define PN533_FRAME_CMD(f) (f->data[1])

#define PN533_CMD_GET_FIRMWARE_VERSION 0x02
+#define PN533_CMD_READ_REGISTER 0x06
+#define PN533_CMD_WRITE_REGISTER 0x08
#define PN533_CMD_SAM_CONFIGURATION 0x14
#define PN533_CMD_RF_CONFIGURATION 0x32
#define PN533_CMD_IN_DATA_EXCHANGE 0x40
--
2.5.5

2016-04-21 14:44:53

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 01/11] NFC: pn533: i2c: free irq on driver remove

The requested irq needs to be freed when removing the driver, otherwise a
following driver load fails to request the irq.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/i2c.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/nfc/pn533/i2c.c b/drivers/nfc/pn533/i2c.c
index 9679aa5..1a622e1 100644
--- a/drivers/nfc/pn533/i2c.c
+++ b/drivers/nfc/pn533/i2c.c
@@ -236,6 +236,8 @@ static int pn533_i2c_remove(struct i2c_client *client)

pn533_unregister_device(phy->priv);

+ free_irq(client->irq, phy);
+
return 0;
}

--
2.5.5

2016-04-21 14:44:56

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 10/11] NFC: pn533: set cmd status when not set

When pn533_recv_frame is called with skb = NULL and cmd->status = 0, set
cmd->status to an error code.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/pn533.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index ae13277..44bc5e0 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2040,6 +2040,8 @@ void pn533_recv_frame(struct pn533 *dev, struct sk_buff *skb, int status)

if (skb == NULL) {
pr_err("NULL Frame -> link is dead\n");
+ if (!dev->cmd->status)
+ dev->cmd->status = -ENOENT;
goto sched_wq;
}

--
2.5.5

2016-04-21 14:44:55

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 05/11] NFC: pn533: handle interrupted commands in pn533_recv_frame

When pn533_recv_frame is called from within abort_command context the current
dev->cmd is not guaranteed to be set.

Additionally on receiving an error status we can omit frame checking and
simply schedule the workquueue.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/pn533.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index 745181e..d9c5583 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2016,8 +2016,16 @@ _error:
*/
void pn533_recv_frame(struct pn533 *dev, struct sk_buff *skb, int status)
{
+ if (!dev->cmd)
+ goto sched_wq;
+
dev->cmd->status = status;

+ if (status != 0) {
+ dev_dbg(dev->dev, "%s: Error received: %d\n", __func__, status);
+ goto sched_wq;
+ }
+
if (skb == NULL) {
pr_err("NULL Frame -> link is dead\n");
goto sched_wq;
--
2.5.5

2016-04-21 14:44:54

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 02/11] NFC: pn533: fix order of initialization

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

Signed-off-by: Michael Thalmeier <[email protected]>
---
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

2016-04-21 14:45:58

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 03/11] NFC: pn533: i2c: do not call pn533_recv_frame with aborted commands

When a command gets aborted the pn533 core does not need any RX frames that
may be received until a new frame is sent.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/i2c.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/pn533/i2c.c b/drivers/nfc/pn533/i2c.c
index 0141f19..1dc89248 100644
--- a/drivers/nfc/pn533/i2c.c
+++ b/drivers/nfc/pn533/i2c.c
@@ -39,6 +39,8 @@ struct pn533_i2c_phy {
struct i2c_client *i2c_dev;
struct pn533 *priv;

+ bool aborted;
+
int hard_fault; /*
* < 0 if hardware error occurred (e.g. i2c err)
* and prevents normal operation.
@@ -71,6 +73,8 @@ static int pn533_i2c_send_frame(struct pn533 *dev,
if (phy->priv == NULL)
phy->priv = dev;

+ phy->aborted = false;
+
print_hex_dump_debug("PN533_i2c TX: ", DUMP_PREFIX_NONE, 16, 1,
out->data, out->len, false);

@@ -93,13 +97,15 @@ static int pn533_i2c_send_frame(struct pn533 *dev,

static void pn533_i2c_abort_cmd(struct pn533 *dev, gfp_t flags)
{
+ struct pn533_i2c_phy *phy = dev->phy;
+
+ phy->aborted = true;
+
/* An ack will cancel the last issued command */
pn533_i2c_send_ack(dev, flags);

/* schedule cmd_complete_work to finish current command execution */
- if (dev->cmd != NULL)
- dev->cmd->status = -ENOENT;
- queue_work(dev->wq, &dev->cmd_complete_work);
+ pn533_recv_frame(phy->priv, NULL, -ENOENT);
}

static int pn533_i2c_read(struct pn533_i2c_phy *phy, struct sk_buff **skb)
@@ -164,7 +170,8 @@ static irqreturn_t pn533_i2c_irq_thread_fn(int irq, void *data)
return IRQ_HANDLED;
}

- pn533_recv_frame(phy->priv, skb, 0);
+ if (!phy->aborted)
+ pn533_recv_frame(phy->priv, skb, 0);

return IRQ_HANDLED;
}
--
2.5.5

2016-04-21 14:45:57

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 06/11] NFC: pn533: usb: fix errors when poll is stopped

When a poll ist stopped we need to kill the out_urb request too before
starting a new request.

Additionally check if cmd is set in pn533_recv_ack befor accessing its struct
members.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/usb.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index 8ca0603..5500175 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -98,7 +98,8 @@ static void pn533_recv_ack(struct urb *urb)
struct pn533_std_frame *in_frame;
int rc;

- cmd->status = urb->status;
+ if (cmd)
+ cmd->status = urb->status;

switch (urb->status) {
case 0:
@@ -120,7 +121,8 @@ static void pn533_recv_ack(struct urb *urb)

if (!pn533_rx_frame_is_ack(in_frame)) {
nfc_err(&phy->udev->dev, "Received an invalid ack\n");
- cmd->status = -EIO;
+ if (cmd)
+ cmd->status = -EIO;
goto sched_wq;
}

@@ -128,7 +130,8 @@ static void pn533_recv_ack(struct urb *urb)
if (rc) {
nfc_err(&phy->udev->dev,
"usb_submit_urb failed with result %d\n", rc);
- cmd->status = rc;
+ if (cmd)
+ cmd->status = rc;
goto sched_wq;
}

@@ -209,6 +212,9 @@ static void pn533_usb_abort_cmd(struct pn533 *dev, gfp_t flags)
if (dev->device_type == PN533_DEVICE_ACR122U)
return;

+ /* cancel the out urb request */
+ usb_kill_urb(phy->out_urb);
+
/* An ack will cancel the last issued command */
pn533_usb_send_ack(dev, flags);

--
2.5.5

2016-04-21 14:46:32

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 07/11] NFC: pn533: improve cmd queue handling

Make sure cmd is set before a frame is passed to the transport layer for
sending. In addition pn533_send_async_complete checks if cmd is set before
accessing its members.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/pn533.c | 54 +++++++++++++++++++++++++++++------------------
1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index d9c5583..d1cc70a 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -383,26 +383,36 @@ static void pn533_build_cmd_frame(struct pn533 *dev, u8 cmd_code,
static int pn533_send_async_complete(struct pn533 *dev)
{
struct pn533_cmd *cmd = dev->cmd;
- int status = cmd->status;
+ int rc = 0;

- struct sk_buff *req = cmd->req;
- struct sk_buff *resp = cmd->resp;
+ if (cmd) {
+ int status = cmd->status;

- int rc;
+ struct sk_buff *req = cmd->req;
+ struct sk_buff *resp = cmd->resp;

- dev_kfree_skb(req);
+ dev_kfree_skb(req);

- if (status < 0) {
- rc = cmd->complete_cb(dev, cmd->complete_cb_context,
- ERR_PTR(status));
- dev_kfree_skb(resp);
- goto done;
- }
+ if (status < 0) {
+ rc = cmd->complete_cb(dev, cmd->complete_cb_context,
+ ERR_PTR(status));
+ dev_kfree_skb(resp);
+ goto done;
+ }
+
+ /* when no response is set we got interrupted */
+ if (!resp)
+ resp = ERR_PTR(-EINTR);

- skb_pull(resp, dev->ops->rx_header_len);
- skb_trim(resp, resp->len - dev->ops->rx_tail_len);
+ if (!IS_ERR(resp)) {
+ skb_pull(resp, dev->ops->rx_header_len);
+ skb_trim(resp, resp->len - dev->ops->rx_tail_len);
+ }

- rc = cmd->complete_cb(dev, cmd->complete_cb_context, resp);
+ rc = cmd->complete_cb(dev, cmd->complete_cb_context, resp);
+ } else {
+ dev_dbg(dev->dev, "%s: cmd not set\n", __func__);
+ }

done:
kfree(cmd);
@@ -434,12 +444,14 @@ static int __pn533_send_async(struct pn533 *dev, u8 cmd_code,
mutex_lock(&dev->cmd_lock);

if (!dev->cmd_pending) {
+ dev->cmd = cmd;
rc = dev->phy_ops->send_frame(dev, req);
- if (rc)
+ if (rc) {
+ dev->cmd = NULL;
goto error;
+ }

dev->cmd_pending = 1;
- dev->cmd = cmd;
goto unlock;
}

@@ -511,11 +523,12 @@ static int pn533_send_cmd_direct_async(struct pn533 *dev, u8 cmd_code,

pn533_build_cmd_frame(dev, cmd_code, req);

+ dev->cmd = cmd;
rc = dev->phy_ops->send_frame(dev, req);
- if (rc < 0)
+ if (rc < 0) {
+ dev->cmd = NULL;
kfree(cmd);
- else
- dev->cmd = cmd;
+ }

return rc;
}
@@ -550,14 +563,15 @@ static void pn533_wq_cmd(struct work_struct *work)

mutex_unlock(&dev->cmd_lock);

+ dev->cmd = cmd;
rc = dev->phy_ops->send_frame(dev, cmd->req);
if (rc < 0) {
+ dev->cmd = NULL;
dev_kfree_skb(cmd->req);
kfree(cmd);
return;
}

- dev->cmd = cmd;
}

struct pn533_sync_cmd_response {
--
2.5.5

2016-04-21 14:46:35

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 08/11] NFC: pn533: reduce output when stopping poll

Handle return codes for stopped polling operations better to reduce logging
activity.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/pn533.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index d1cc70a..c06d22f 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -1259,7 +1259,8 @@ static int pn533_rf_complete(struct pn533 *dev, void *arg,
if (IS_ERR(resp)) {
rc = PTR_ERR(resp);

- nfc_err(dev->dev, "RF setting error %d\n", rc);
+ if (rc != -ENOENT)
+ nfc_err(dev->dev, "RF setting error %d\n", rc);

return rc;
}
@@ -1416,9 +1417,6 @@ static int pn533_poll_complete(struct pn533 *dev, void *arg,
if (IS_ERR(resp)) {
rc = PTR_ERR(resp);

- nfc_err(dev->dev, "%s Poll complete error %d\n",
- __func__, rc);
-
if (rc == -ENOENT) {
if (dev->poll_mod_count != 0)
return rc;
@@ -1457,7 +1455,7 @@ done:
return rc;

stop_poll:
- nfc_err(dev->dev, "Polling operation has been stopped\n");
+ dev_dbg(dev->dev, "Polling operation has been stopped\n");

pn533_poll_reset_mod_list(dev);
dev->poll_protocols = 0;
--
2.5.5

2016-04-21 14:46:33

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 09/11] NFC: pn533: use nfc_alloc_recv_skb for skb allocation

When multiple receive frames need to be put together in pn533_build_response
we need to use nfc_alloc_recv_skb instead of the normal alloc_skb. Otherwise
the nfc core causes an skb error when it tries to push the status byte in
front of the data.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/pn533.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index c06d22f..ae13277 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -1942,7 +1942,7 @@ static struct sk_buff *pn533_build_response(struct pn533 *dev)
dev_dbg(dev->dev, "%s total length %d\n",
__func__, skb_len);

- skb = alloc_skb(skb_len, GFP_KERNEL);
+ skb = nfc_alloc_recv_skb(skb_len, GFP_KERNEL);
if (skb == NULL)
goto out;

--
2.5.5

2016-04-21 14:46:31

by Michael Thalmeier

[permalink] [raw]
Subject: [PATCH 04/11] NFC: pn533: reset poll modulation list before calling nfc_targets_found

We need to reset the poll modulation list before calling nfc_targets_found
because otherwise it is possible that the application is scheduled to run
before the modulation list is cleared and gets an error "Cannot activate
target while polling" upon calling activate_target.

Signed-off-by: Michael Thalmeier <[email protected]>
---
drivers/nfc/pn533/pn533.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index d82eecd..745181e 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -865,6 +865,7 @@ static int pn533_target_found_type_b(struct nfc_target *nfc_tgt, u8 *tgt_data,
return 0;
}

+static void pn533_poll_reset_mod_list(struct pn533 *dev);
static int pn533_target_found(struct pn533 *dev, u8 tg, u8 *tgdata,
int tgdata_len)
{
@@ -914,6 +915,7 @@ static int pn533_target_found(struct pn533 *dev, u8 tg, u8 *tgdata,

dev->tgt_available_prots = nfc_tgt.supported_protocols;

+ pn533_poll_reset_mod_list(dev);
nfc_targets_found(dev->nfc_dev, &nfc_tgt, 1);

return 0;
@@ -980,10 +982,8 @@ static int pn533_start_poll_complete(struct pn533 *dev, struct sk_buff *resp)
rc = pn533_target_found(dev, tg, tgdata, tgdata_len);

/* We must stop the poll after a valid target found */
- if (rc == 0) {
- pn533_poll_reset_mod_list(dev);
+ if (rc == 0)
return 0;
- }
}

return -EAGAIN;
--
2.5.5

2016-04-28 18:19:10

by Olliver Schinagl

[permalink] [raw]
Subject: Re: [PATCH 00/11] NFC: pn533: bug fixes and improvements

Hi Michael,

I know i'm a little late to the party, but why did you not name the
directory/driver pn53x? I don't think we should debate wether a 533 is a
532 with a USB added, or wether a 532 is a 533 with the USB stripped, I
was just curious. As for the pn533-i2c, in the KConfig, I'd probably
recommend naming it pn532 at the least though, since there is no variant
other then USB for the 533?

Further more, I think it would be wise to add some documentation and nfc
bindings examples.

I'm using it as a subnode of an i2c node as such:

&i2c2 {
pinctrl-names = "default";
pinctrl-0 = <&i2c2_pins_a>;
status = "okay";

pn532: pn53x@48 {
compatible = "nxp,pn532-i2c";
reg = <0x48>;
};
};

But not sure if this is correct at all (I haven't gotten it to work yet,
partly due to a burnt level shifter). For example, I'm not sure what
other properties are needed.

Olliver

On 21-04-16 16:43, Michael Thalmeier wrote:
> Hello Samuel,
>
> This patchset fixes some major bugs in the pn533 drivers (usb and i2c) and
> improves performance of the PN532 chip by increasing its clock speed.
>
> Best Regards
> Michael
>
> Michael Thalmeier (11):
> NFC: pn533: i2c: free irq on driver remove
> NFC: pn533: fix order of initialization
> NFC: pn533: i2c: do not call pn533_recv_frame with aborted commands
> NFC: pn533: reset poll modulation list before calling nfc_targets_found
> NFC: pn533: handle interrupted commands in pn533_recv_frame
> NFC: pn533: usb: fix errors when poll is stopped
> NFC: pn533: improve cmd queue handling
> NFC: pn533: reduce output when stopping poll
> NFC: pn533: use nfc_alloc_recv_skb for skb allocation
> NFC: pn533: set cmd status when not set
> nfc: pn533: increase clock frequency for PN532
>
> drivers/nfc/pn533/i2c.c | 20 ++++--
> drivers/nfc/pn533/pn533.c | 154 +++++++++++++++++++++++++++++++++++++---------
> drivers/nfc/pn533/pn533.h | 5 +-
> drivers/nfc/pn533/usb.c | 15 +++--
> 4 files changed, 153 insertions(+), 41 deletions(-)
>