All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] Follow up patches and several new fixes
@ 2014-09-12 19:49 Christophe Ricard
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
  0 siblings, 1 reply; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Hi,

Please find in those patches a set of followup items according to
previous submissions feedback:
- NFC: st21nfca: Fix few coding style issue
- NFC: st21nfca: Fix potential skb leaks in NFC-DEP code
- NFC: st21nfca: Fix potential double kfree_skb error
are patches related to previous patch:
[PATCH 2/8] NFC: st21nfca: Fix potential skb leaks in NFC-DEP code

NFC: st21nfca: Replace all remaining IS_ERR(skb) with !skb is related
with [PATCH 4/5] NFC: st21nfca: Remove all remaining IS_ERR(skb) for 
simple !skb condition.
I have tried to review again and add some more explanation. Hope that
will be acceptable.

Other patches are new they:
- fix recursive fault in p2p target mode with st21nfca
- fix bad behavior on st21nfcb
- add ISO15693 technology for st21nfcb with a specific prioprietary
RF protocol value.
- fix st21nfcb dts documentation

Best Regards
Christophe

Christophe Ricard (11):
  NFC: st21nfca: Fix few coding style issue
  NFC: st21nfca: Fix potential skb leaks in NFC-DEP code
  NFC: st21nfca: Fix recursive fault when doing p2p in target mode.
  NFC: dts: st21nfcb_i2c: Fix invalid interrupts polarity.
  NFC: st21nfcb: Fix improper management of -EREMOTEIO error code.
  NFC: st21nfcb: Fix improper ndlc T2 management
  NFC: nci: Add support for proprietary RF Protocols
  NFC: st21nfcb: Add ISO15693 Reader/Writer support
  NFC: st21nfcb: remove error output
  NFC: st21nfca: Replace all remaining IS_ERR(skb) with !skb
  NFC: st21nfca: Fix potential double kfree_skb error

 .../devicetree/bindings/net/nfc/st21nfcb.txt       |  2 +-
 drivers/nfc/st21nfca/st21nfca.c                    |  5 ++---
 drivers/nfc/st21nfca/st21nfca_dep.c                | 25 ++++++++++++----------
 drivers/nfc/st21nfcb/i2c.c                         | 23 +++++---------------
 drivers/nfc/st21nfcb/ndlc.c                        |  6 +++++-
 drivers/nfc/st21nfcb/ndlc.h                        |  4 ++++
 drivers/nfc/st21nfcb/st21nfcb.c                    | 11 ++++++++++
 include/net/nfc/nci_core.h                         |  9 ++++----
 net/nfc/nci/ntf.c                                  |  9 +++++++-
 9 files changed, 55 insertions(+), 39 deletions(-)

-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 01/11] NFC: st21nfca: Fix few coding style issue
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 02/11] NFC: st21nfca: Fix potential skb leaks in NFC-DEP code Christophe Ricard
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Fix few conding style issue such as useless line return or tab.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfca/st21nfca_dep.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/nfc/st21nfca/st21nfca_dep.c b/drivers/nfc/st21nfca/st21nfca_dep.c
index 6c09a66..03dacc6 100644
--- a/drivers/nfc/st21nfca/st21nfca_dep.c
+++ b/drivers/nfc/st21nfca/st21nfca_dep.c
@@ -129,9 +129,8 @@ static void st21nfca_tx_work(struct work_struct *work)
 		device_lock(&dev->dev);
 
 		nfc_hci_send_cmd_async(info->hdev, ST21NFCA_RF_READER_F_GATE,
-							ST21NFCA_WR_XCHG_DATA,
-							skb->data, skb->len,
-							info->async_cb, info);
+				ST21NFCA_WR_XCHG_DATA, skb->data, skb->len,
+				info->async_cb, info);
 		device_unlock(&dev->dev);
 		kfree_skb(skb);
 	}
@@ -239,7 +238,6 @@ static int st21nfca_tm_send_psl_res(struct nfc_hci_dev *hdev,
 	struct st21nfca_psl_res *psl_res;
 	struct sk_buff *skb;
 	u8 bitrate[2] = {0, 0};
-
 	int r;
 
 	skb = alloc_skb(sizeof(struct st21nfca_psl_res), GFP_KERNEL);
@@ -311,7 +309,7 @@ int st21nfca_tm_send_dep_res(struct nfc_hci_dev *hdev, struct sk_buff *skb)
 	*skb_push(skb, 1) = skb->len;
 
 	r = nfc_hci_send_event(hdev, ST21NFCA_RF_CARD_F_GATE,
-				ST21NFCA_EVT_SEND_DATA, skb->data, skb->len);
+			ST21NFCA_EVT_SEND_DATA, skb->data, skb->len);
 	kfree_skb(skb);
 
 	return r;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 02/11] NFC: st21nfca: Fix potential skb leaks in NFC-DEP code
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
  2014-09-12 19:49   ` [PATCH 01/11] NFC: st21nfca: Fix few coding style issue Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 03/11] NFC: st21nfca: Fix recursive fault when doing p2p in target mode Christophe Ricard
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

After a unsuccessful call to nfc_hci_send_event the skb was not
freed and might lead to memory leak.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfca/st21nfca_dep.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/st21nfca/st21nfca_dep.c b/drivers/nfc/st21nfca/st21nfca_dep.c
index 03dacc6..bf3132b 100644
--- a/drivers/nfc/st21nfca/st21nfca_dep.c
+++ b/drivers/nfc/st21nfca/st21nfca_dep.c
@@ -185,8 +185,10 @@ static int st21nfca_tm_send_atr_res(struct nfc_hci_dev *hdev,
 
 	info->dep_info.curr_nfc_dep_pni = 0;
 
-	return nfc_hci_send_event(hdev, ST21NFCA_RF_CARD_F_GATE,
+	r = nfc_hci_send_event(hdev, ST21NFCA_RF_CARD_F_GATE,
 				ST21NFCA_EVT_SEND_DATA, skb->data, skb->len);
+	kfree_skb(skb);
+	return r;
 }
 
 static int st21nfca_tm_recv_atr_req(struct nfc_hci_dev *hdev,
@@ -254,6 +256,8 @@ static int st21nfca_tm_send_psl_res(struct nfc_hci_dev *hdev,
 
 	r = nfc_hci_send_event(hdev, ST21NFCA_RF_CARD_F_GATE,
 				ST21NFCA_EVT_SEND_DATA, skb->data, skb->len);
+	if (r < 0)
+		goto error;
 
 	/*
 	 * ST21NFCA only support P2P passive.
@@ -269,8 +273,11 @@ static int st21nfca_tm_send_psl_res(struct nfc_hci_dev *hdev,
 	}
 
 	/* Send an event to change bitrate change event to card f */
-	return nfc_hci_send_event(hdev, ST21NFCA_RF_CARD_F_GATE,
+	r = nfc_hci_send_event(hdev, ST21NFCA_RF_CARD_F_GATE,
 			ST21NFCA_EVT_CARD_F_BITRATE, bitrate, 2);
+error:
+	kfree_skb(skb);
+	return r;
 }
 
 static int st21nfca_tm_recv_psl_req(struct nfc_hci_dev *hdev,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 03/11] NFC: st21nfca: Fix recursive fault when doing p2p in target mode.
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
  2014-09-12 19:49   ` [PATCH 01/11] NFC: st21nfca: Fix few coding style issue Christophe Ricard
  2014-09-12 19:49   ` [PATCH 02/11] NFC: st21nfca: Fix potential skb leaks in NFC-DEP code Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 04/11] NFC: dts: st21nfcb_i2c: Fix invalid interrupts polarity Christophe Ricard
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

This patch fix a previous patch introduce by commit	0a91e8ac240a12ac3a03581deb8cd531788c63d4

It is actually fixing a double free mistake in all st21nfca_tm_* function.
We decide to return directly in case of successful execution because skb
got already freed. In st21nfca_tm_recv_dep_req it got freed by nfc_tm_data_received.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfca/st21nfca.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/nfc/st21nfca/st21nfca.c b/drivers/nfc/st21nfca/st21nfca.c
index e5f92aa..aad1774 100644
--- a/drivers/nfc/st21nfca/st21nfca.c
+++ b/drivers/nfc/st21nfca/st21nfca.c
@@ -861,7 +861,8 @@ static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 gate,
 		if (gate == ST21NFCA_RF_CARD_F_GATE) {
 			r = st21nfca_tm_event_send_data(hdev, skb, gate);
 			if (r < 0)
-				goto exit;
+				return r;
+			return 0;
 		} else {
 			info->dep_info.curr_nfc_dep_pni = 0;
 			return 1;
@@ -872,8 +873,6 @@ static int st21nfca_hci_event_received(struct nfc_hci_dev *hdev, u8 gate,
 	}
 	kfree_skb(skb);
 	return 0;
-exit:
-	return r;
 }
 
 static struct nfc_hci_ops st21nfca_hci_ops = {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 04/11] NFC: dts: st21nfcb_i2c: Fix invalid interrupts polarity.
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (2 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 03/11] NFC: st21nfca: Fix recursive fault when doing p2p in target mode Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 05/11] NFC: st21nfcb: Fix improper management of -EREMOTEIO error code Christophe Ricard
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

St21nfcb has a reverse polarity compare to st21nfca.
In st21nfcb case, the irq pin is active high.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 Documentation/devicetree/bindings/net/nfc/st21nfcb.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/net/nfc/st21nfcb.txt b/Documentation/devicetree/bindings/net/nfc/st21nfcb.txt
index 3b58ae4..9005608 100644
--- a/Documentation/devicetree/bindings/net/nfc/st21nfcb.txt
+++ b/Documentation/devicetree/bindings/net/nfc/st21nfcb.txt
@@ -26,7 +26,7 @@ Example (for ARM-based BeagleBoard xM with ST21NFCB on I2C2):
 		clock-frequency = <400000>;
 
 		interrupt-parent = <&gpio5>;
-		interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+		interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
 
 		reset-gpios = <&gpio5 29 GPIO_ACTIVE_HIGH>;
 	};
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 05/11] NFC: st21nfcb: Fix improper management of -EREMOTEIO error code.
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (3 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 04/11] NFC: dts: st21nfcb_i2c: Fix invalid interrupts polarity Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 06/11] NFC: st21nfcb: Fix improper ndlc T2 management Christophe Ricard
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

On st21nfcb the irq line might be kept to active state because of other
interfaces activity. This may generate i2c read tentative resulting in
i2c NACK.

This fix will currently let NDLC upper layer to decide when it is relevent
to signal to the physical layer when the chip as muted.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfcb/i2c.c  | 19 ++++---------------
 drivers/nfc/st21nfcb/ndlc.h |  4 ++++
 2 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c
index 8342346..0b8f721 100644
--- a/drivers/nfc/st21nfcb/i2c.c
+++ b/drivers/nfc/st21nfcb/i2c.c
@@ -55,12 +55,6 @@ struct st21nfcb_i2c_phy {
 	unsigned int irq_polarity;
 
 	int powered;
-
-	/*
-	 * < 0 if hardware error occured (e.g. i2c err)
-	 * and prevents normal operation.
-	 */
-	int hard_fault;
 };
 
 #define I2C_DUMP_SKB(info, skb)					\
@@ -114,8 +108,8 @@ static int st21nfcb_nci_i2c_write(void *phy_id, struct sk_buff *skb)
 
 	I2C_DUMP_SKB("st21nfcb_nci_i2c_write", skb);
 
-	if (phy->hard_fault != 0)
-		return phy->hard_fault;
+	if (phy->ndlc->hard_fault != 0)
+		return phy->ndlc->hard_fault;
 
 	r = i2c_master_send(client, skb->data, skb->len);
 	if (r == -EREMOTEIO) {  /* Retry, chip was in standby */
@@ -218,7 +212,7 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id)
 	client = phy->i2c_dev;
 	dev_dbg(&client->dev, "IRQ\n");
 
-	if (phy->hard_fault)
+	if (phy->ndlc->hard_fault)
 		return IRQ_HANDLED;
 
 	if (!phy->powered) {
@@ -227,13 +221,8 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id)
 	}
 
 	r = st21nfcb_nci_i2c_read(phy, &skb);
-	if (r == -EREMOTEIO) {
-		phy->hard_fault = r;
-		ndlc_recv(phy->ndlc, NULL);
-		return IRQ_HANDLED;
-	} else if (r == -ENOMEM || r == -EBADMSG) {
+	if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG)
 		return IRQ_HANDLED;
-	}
 
 	ndlc_recv(phy->ndlc, skb);
 
diff --git a/drivers/nfc/st21nfcb/ndlc.h b/drivers/nfc/st21nfcb/ndlc.h
index c30a2f0..b28140e 100644
--- a/drivers/nfc/st21nfcb/ndlc.h
+++ b/drivers/nfc/st21nfcb/ndlc.h
@@ -42,6 +42,10 @@ struct llt_ndlc {
 
 	struct device *dev;
 
+	/*
+	 * < 0 if hardware error occured
+	 * and prevents normal operation.
+	 */
 	int hard_fault;
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 06/11] NFC: st21nfcb: Fix improper ndlc T2 management
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (4 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 05/11] NFC: st21nfcb: Fix improper management of -EREMOTEIO error code Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 07/11] NFC: nci: Add support for proprietary RF Protocols Christophe Ricard
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

T2 was never started when sending a command.
Start it when sending a command for the first attempt
and stop it once we receive the answer.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfcb/ndlc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/st21nfcb/ndlc.c b/drivers/nfc/st21nfcb/ndlc.c
index 83c97c3..e7bff89 100644
--- a/drivers/nfc/st21nfcb/ndlc.c
+++ b/drivers/nfc/st21nfcb/ndlc.c
@@ -112,6 +112,10 @@ static void llt_ndlc_send_queue(struct llt_ndlc *ndlc)
 		ndlc->t1_active = true;
 		mod_timer(&ndlc->t1_timer, time_sent +
 			msecs_to_jiffies(NDLC_TIMER_T1));
+		/* start timer t2 for chip availability */
+		ndlc->t2_active = true;
+		mod_timer(&ndlc->t2_timer, time_sent +
+			msecs_to_jiffies(NDLC_TIMER_T2));
 	}
 }
 
@@ -207,7 +211,7 @@ static void llt_ndlc_sm_work(struct work_struct *work)
 		ndlc->t2_active = false;
 		ndlc->t1_active = false;
 		del_timer_sync(&ndlc->t1_timer);
-
+		del_timer_sync(&ndlc->t2_timer);
 		ndlc_close(ndlc);
 		ndlc->hard_fault = -EREMOTEIO;
 	}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 07/11] NFC: nci: Add support for proprietary RF Protocols
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (5 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 06/11] NFC: st21nfcb: Fix improper ndlc T2 management Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 08/11] NFC: st21nfcb: Add ISO15693 Reader/Writer support Christophe Ricard
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

In NFC Forum NCI specification, some RF Protocol values are
reserved for proprietary use (from 0x80 to 0xfe).
Some CLF vendor may need to use one value within this range
for specific technology.
Furthermore, some CLF may not becompliant with NFC Froum NCI
specification 2.0 and therefore will not support RF Protocol
value 0x06 for PROTOCOL_T5T as mention in a draft specification
and in a recent push.

Adding get_rf_protocol handle to the nci_ops structure will
help to set the correct technology to target.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfcb/st21nfcb.c | 10 ++++++++++
 include/net/nfc/nci_core.h      |  9 +++++----
 net/nfc/nci/ntf.c               |  9 ++++++++-
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/nfc/st21nfcb/st21nfcb.c b/drivers/nfc/st21nfcb/st21nfcb.c
index 90d3715..e72dae8 100644
--- a/drivers/nfc/st21nfcb/st21nfcb.c
+++ b/drivers/nfc/st21nfcb/st21nfcb.c
@@ -25,6 +25,8 @@
 
 #define DRIVER_DESC "NCI NFC driver for ST21NFCB"
 
+#define ST21NFCB_NCI1_X_PROPRIETARY_ISO15693 0x83
+
 static int st21nfcb_nci_open(struct nci_dev *ndev)
 {
 	struct st21nfcb_nci_info *info = nci_get_drvdata(ndev);
@@ -64,10 +66,18 @@ static int st21nfcb_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
 	return ndlc_send(info->ndlc, skb);
 }
 
+static __u32 st21nfcb_nci_get_rfprotocol(struct nci_dev *ndev,
+					 __u8 rf_protocol)
+{
+	return rf_protocol == ST21NFCB_NCI1_X_PROPRIETARY_ISO15693 ?
+		NFC_PROTO_ISO15693_MASK : 0;
+}
+
 static struct nci_ops st21nfcb_nci_ops = {
 	.open = st21nfcb_nci_open,
 	.close = st21nfcb_nci_close,
 	.send = st21nfcb_nci_send,
+	.get_rfprotocol = st21nfcb_nci_get_rfprotocol,
 };
 
 int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h
index 1f9a0f5..75d10e6 100644
--- a/include/net/nfc/nci_core.h
+++ b/include/net/nfc/nci_core.h
@@ -64,10 +64,11 @@ enum nci_state {
 struct nci_dev;
 
 struct nci_ops {
-	int (*open)(struct nci_dev *ndev);
-	int (*close)(struct nci_dev *ndev);
-	int (*send)(struct nci_dev *ndev, struct sk_buff *skb);
-	int (*setup)(struct nci_dev *ndev);
+	int   (*open)(struct nci_dev *ndev);
+	int   (*close)(struct nci_dev *ndev);
+	int   (*send)(struct nci_dev *ndev, struct sk_buff *skb);
+	int   (*setup)(struct nci_dev *ndev);
+	__u32 (*get_rfprotocol)(struct nci_dev *ndev, __u8 rf_protocol);
 };
 
 #define NCI_MAX_SUPPORTED_RF_INTERFACES		4
diff --git a/net/nfc/nci/ntf.c b/net/nfc/nci/ntf.c
index 25e44ce..205b35f6 100644
--- a/net/nfc/nci/ntf.c
+++ b/net/nfc/nci/ntf.c
@@ -167,6 +167,13 @@ static __u8 *nci_extract_rf_params_nfcv_passive_poll(struct nci_dev *ndev,
 	return data;
 }
 
+__u32 nci_get_prop_rf_protocol(struct nci_dev *ndev, __u8 rf_protocol)
+{
+	if (ndev->ops->get_rfprotocol)
+		return ndev->ops->get_rfprotocol(ndev, rf_protocol);
+	return 0;
+}
+
 static int nci_add_new_protocol(struct nci_dev *ndev,
 				struct nfc_target *target,
 				__u8 rf_protocol,
@@ -195,7 +202,7 @@ static int nci_add_new_protocol(struct nci_dev *ndev,
 	else if (rf_protocol == NCI_RF_PROTOCOL_T5T)
 		protocol = NFC_PROTO_ISO15693_MASK;
 	else
-		protocol = 0;
+		protocol = nci_get_prop_rf_protocol(ndev, rf_protocol);
 
 	if (!(protocol & ndev->poll_prots)) {
 		pr_err("the target found does not have the desired protocol\n");
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 08/11] NFC: st21nfcb: Add ISO15693 Reader/Writer support
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (6 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 07/11] NFC: nci: Add support for proprietary RF Protocols Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 09/11] NFC: st21nfcb: remove error output Christophe Ricard
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

Add support for ISO/IEC 15693 RF technology and Type 5 tags.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfcb/st21nfcb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nfc/st21nfcb/st21nfcb.c b/drivers/nfc/st21nfcb/st21nfcb.c
index e72dae8..ea63d58 100644
--- a/drivers/nfc/st21nfcb/st21nfcb.c
+++ b/drivers/nfc/st21nfcb/st21nfcb.c
@@ -97,6 +97,7 @@ int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
 		| NFC_PROTO_FELICA_MASK
 		| NFC_PROTO_ISO14443_MASK
 		| NFC_PROTO_ISO14443_B_MASK
+		| NFC_PROTO_ISO15693_MASK
 		| NFC_PROTO_NFC_DEP_MASK;
 
 	ndlc->ndev = nci_allocate_device(&st21nfcb_nci_ops, protocols,
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 09/11] NFC: st21nfcb: remove error output
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (7 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 08/11] NFC: st21nfcb: Add ISO15693 Reader/Writer support Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 10/11] NFC: st21nfca: Replace all remaining IS_ERR(skb) with !skb Christophe Ricard
  2014-09-12 19:49   ` [PATCH 11/11] NFC: st21nfca: Fix potential double kfree_skb error Christophe Ricard
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

In case we are not able to read out the NDLC/NCI header, we do not
consider this as an issue and we will give a later chance.
The NDLC layer will handle errors thanks to its internal timers.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfcb/i2c.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c
index 0b8f721..c5d2427 100644
--- a/drivers/nfc/st21nfcb/i2c.c
+++ b/drivers/nfc/st21nfcb/i2c.c
@@ -156,10 +156,8 @@ static int st21nfcb_nci_i2c_read(struct st21nfcb_i2c_phy *phy,
 		r = i2c_master_recv(client, buf, ST21NFCB_NCI_I2C_MIN_SIZE);
 	}
 
-	if (r != ST21NFCB_NCI_I2C_MIN_SIZE) {
-		nfc_err(&client->dev, "cannot read ndlc & nci header\n");
+	if (r != ST21NFCB_NCI_I2C_MIN_SIZE)
 		return -EREMOTEIO;
-	}
 
 	len = be16_to_cpu(*(__be16 *) (buf + 2));
 	if (len > ST21NFCB_NCI_I2C_MAX_SIZE) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 10/11] NFC: st21nfca: Replace all remaining IS_ERR(skb) with !skb
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (8 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 09/11] NFC: st21nfcb: remove error output Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  2014-09-12 19:49   ` [PATCH 11/11] NFC: st21nfca: Fix potential double kfree_skb error Christophe Ricard
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

!skb is much simpler and more appropriate for callback returning void
because:
- IS_ERR(NULL) return false and skb migth be NULL.
- skb cannot be a ERR_PTR as nfc_hci_send_cmd_async it never using such cast.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfca/st21nfca_dep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/st21nfca/st21nfca_dep.c b/drivers/nfc/st21nfca/st21nfca_dep.c
index bf3132b..9408122 100644
--- a/drivers/nfc/st21nfca/st21nfca_dep.c
+++ b/drivers/nfc/st21nfca/st21nfca_dep.c
@@ -443,7 +443,7 @@ static void st21nfca_im_recv_atr_res_cb(void *context, struct sk_buff *skb,
 	if (err != 0)
 		return;
 
-	if (IS_ERR(skb))
+	if (!skb)
 		return;
 
 	switch (info->async_cb_type) {
@@ -555,7 +555,7 @@ static void st21nfca_im_recv_dep_res_cb(void *context, struct sk_buff *skb,
 	if (err != 0)
 		return;
 
-	if (IS_ERR(skb))
+	if (!skb)
 		return;
 
 	switch (info->async_cb_type) {
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 11/11] NFC: st21nfca: Fix potential double kfree_skb error
       [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
                     ` (9 preceding siblings ...)
  2014-09-12 19:49   ` [PATCH 10/11] NFC: st21nfca: Replace all remaining IS_ERR(skb) with !skb Christophe Ricard
@ 2014-09-12 19:49   ` Christophe Ricard
  10 siblings, 0 replies; 12+ messages in thread
From: Christophe Ricard @ 2014-09-12 19:49 UTC (permalink / raw)
  To: sameo-VuQAYsv1563Yd54FQh9/CA
  Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw,
	christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
	christophe-h.ricard-qxv4g6HH51o,
	devicetree-u79uwXL29TY76Z2rM5mHXA

skb is already freed in st21nfca_tx_work and was freed also in
st21nfca_im_send_psl_req.

Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
 drivers/nfc/st21nfca/st21nfca_dep.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/nfc/st21nfca/st21nfca_dep.c b/drivers/nfc/st21nfca/st21nfca_dep.c
index 9408122..bfb6df5 100644
--- a/drivers/nfc/st21nfca/st21nfca_dep.c
+++ b/drivers/nfc/st21nfca/st21nfca_dep.c
@@ -428,8 +428,6 @@ static void st21nfca_im_send_psl_req(struct nfc_hci_dev *hdev, u8 did, u8 bsi,
 	*skb_push(skb, 1) = info->dep_info.to | 0x10;
 
 	st21nfca_im_send_pdu(info, skb);
-
-	kfree_skb(skb);
 }
 
 #define ST21NFCA_CB_TYPE_READER_F 1
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2014-09-12 19:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-12 19:49 [PATCH 00/11] Follow up patches and several new fixes Christophe Ricard
     [not found] ` <1410551381-7565-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2014-09-12 19:49   ` [PATCH 01/11] NFC: st21nfca: Fix few coding style issue Christophe Ricard
2014-09-12 19:49   ` [PATCH 02/11] NFC: st21nfca: Fix potential skb leaks in NFC-DEP code Christophe Ricard
2014-09-12 19:49   ` [PATCH 03/11] NFC: st21nfca: Fix recursive fault when doing p2p in target mode Christophe Ricard
2014-09-12 19:49   ` [PATCH 04/11] NFC: dts: st21nfcb_i2c: Fix invalid interrupts polarity Christophe Ricard
2014-09-12 19:49   ` [PATCH 05/11] NFC: st21nfcb: Fix improper management of -EREMOTEIO error code Christophe Ricard
2014-09-12 19:49   ` [PATCH 06/11] NFC: st21nfcb: Fix improper ndlc T2 management Christophe Ricard
2014-09-12 19:49   ` [PATCH 07/11] NFC: nci: Add support for proprietary RF Protocols Christophe Ricard
2014-09-12 19:49   ` [PATCH 08/11] NFC: st21nfcb: Add ISO15693 Reader/Writer support Christophe Ricard
2014-09-12 19:49   ` [PATCH 09/11] NFC: st21nfcb: remove error output Christophe Ricard
2014-09-12 19:49   ` [PATCH 10/11] NFC: st21nfca: Replace all remaining IS_ERR(skb) with !skb Christophe Ricard
2014-09-12 19:49   ` [PATCH 11/11] NFC: st21nfca: Fix potential double kfree_skb error Christophe Ricard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.