* [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci
@ 2015-08-14 20:33 Christophe Ricard
2015-08-14 20:33 ` [PATCH 01/11] nfc: st-nci: Remove duplicate file include/linux/platform_data/st_nci.h Christophe Ricard
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo-VuQAYsv1563Yd54FQh9/CA
Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw, christophe-h.ricard-qxv4g6HH51o,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA
Hi Samuel,
Please find in this serie:
- some few patches provided earlier:
https://lists.01.org/pipermail/linux-nfc/2015-July/003609.html
- SPI phy support for st-nci. SPI is only supported on st21nfcb CLF.
For your information I2C is the only valid interface on ST21NFCA.
- One fix for the vendor_cmd interface i am currently working on for
ST CLFs.
Best Regards
Christophe
Christophe Ricard (11):
nfc: st-nci: Remove duplicate file
include/linux/platform_data/st_nci.h
nfc: st-nci: Fix typo when changing from st21nfcb to st-nci
nfc: st-nci: Fix non accurate comment for st_nci_i2c_read
NFC: st21nfca: fix use of uninitialized variables in error path
NFC: st-nci: fix use of uninitialized variables in error path
nfc: st-nci: Remove data from ack_pending_q when receiving a NDLC
PCB_SYNC_ACK
nfc: st-nci: Free data with irrelevant NDLC PCB_SYNC value
nfc: st-nci: Add spi phy support for st21nfcb
nfc: st-nci: Add device tree documentation for spi phy
nfc: st-nci: Remove pr_err in llt_ndlc_rcv_queue when ndlc header is
unknown
nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA
.../devicetree/bindings/net/nfc/st-nci-i2c.txt | 33 ++
.../devicetree/bindings/net/nfc/st-nci-spi.txt | 31 ++
.../devicetree/bindings/net/nfc/st-nci.txt | 33 --
drivers/nfc/st-nci/Kconfig | 11 +
drivers/nfc/st-nci/Makefile | 3 +
drivers/nfc/st-nci/i2c.c | 23 +-
drivers/nfc/st-nci/ndlc.c | 7 +-
drivers/nfc/st-nci/spi.c | 392 +++++++++++++++++++++
drivers/nfc/st-nci/st-nci_se.c | 8 +-
drivers/nfc/st21nfca/st21nfca.c | 11 +-
include/linux/platform_data/st_nci.h | 29 --
net/nfc/netlink.c | 7 +-
12 files changed, 496 insertions(+), 92 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/nfc/st-nci-i2c.txt
create mode 100644 Documentation/devicetree/bindings/net/nfc/st-nci-spi.txt
delete mode 100644 Documentation/devicetree/bindings/net/nfc/st-nci.txt
create mode 100644 drivers/nfc/st-nci/spi.c
delete mode 100644 include/linux/platform_data/st_nci.h
--
2.1.4
--
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] 14+ messages in thread
* [PATCH 01/11] nfc: st-nci: Remove duplicate file include/linux/platform_data/st_nci.h
2015-08-14 20:33 [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 02/11] nfc: st-nci: Fix typo when changing from st21nfcb to st-nci Christophe Ricard
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo; +Cc: linux-nfc, christophe-h.ricard, christophe.ricard, devicetree,
stable
commit "nfc: st-nci: Rename st21nfcb to st-nci" adds
include/linux/platform_data/st_nci.h duplicated with
include/linux/platform_data/st-nci.h.
Only drivers/nfc/st-nci/i2c.c uses include/linux/platform_data/st_nci.h.
Cc: stable@vger.kernel.org
Reported-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
drivers/nfc/st-nci/i2c.c | 2 +-
include/linux/platform_data/st_nci.h | 29 -----------------------------
2 files changed, 1 insertion(+), 30 deletions(-)
delete mode 100644 include/linux/platform_data/st_nci.h
diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 06175ce..b2a467c 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -25,7 +25,7 @@
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/nfc.h>
-#include <linux/platform_data/st_nci.h>
+#include <linux/platform_data/st-nci.h>
#include "ndlc.h"
diff --git a/include/linux/platform_data/st_nci.h b/include/linux/platform_data/st_nci.h
deleted file mode 100644
index d9d400a..0000000
--- a/include/linux/platform_data/st_nci.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Driver include for ST NCI NFC chip family.
- *
- * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef _ST_NCI_H_
-#define _ST_NCI_H_
-
-#define ST_NCI_DRIVER_NAME "st_nci"
-
-struct st_nci_nfc_platform_data {
- unsigned int gpio_reset;
- unsigned int irq_polarity;
-};
-
-#endif /* _ST_NCI_H_ */
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/11] nfc: st-nci: Fix typo when changing from st21nfcb to st-nci
2015-08-14 20:33 [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Christophe Ricard
2015-08-14 20:33 ` [PATCH 01/11] nfc: st-nci: Remove duplicate file include/linux/platform_data/st_nci.h Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 03/11] nfc: st-nci: Fix non accurate comment for st_nci_i2c_read Christophe Ricard
` (4 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo; +Cc: linux-nfc, christophe-h.ricard, christophe.ricard, devicetree,
stable
Replace ST21NFCB with ST_NCI or st21nfcb with st_nci as it was forgotten
in commit "nfc: st-nci: Rename st21nfcb to st-nci"
ed06aeefdac348cfb91a3db5fe1067e3202afd70
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
drivers/nfc/st-nci/i2c.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index b2a467c..a15144d 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -29,11 +29,11 @@
#include "ndlc.h"
-#define DRIVER_DESC "NCI NFC driver for ST21NFCB"
+#define DRIVER_DESC "NCI NFC driver for ST_NCI"
/* ndlc header */
-#define ST21NFCB_FRAME_HEADROOM 1
-#define ST21NFCB_FRAME_TAILROOM 0
+#define ST_NCI_FRAME_HEADROOM 1
+#define ST_NCI_FRAME_TAILROOM 0
#define ST_NCI_I2C_MIN_SIZE 4 /* PCB(1) + NCI Packet header(3) */
#define ST_NCI_I2C_MAX_SIZE 250 /* req 4.2.1 */
@@ -118,14 +118,14 @@ static int st_nci_i2c_write(void *phy_id, struct sk_buff *skb)
/*
* Reads an ndlc frame and returns it in a newly allocated sk_buff.
* returns:
- * frame size : if received frame is complete (find ST21NFCB_SOF_EOF at
+ * frame size : if received frame is complete (find ST_NCI_SOF_EOF at
* end of read)
- * -EAGAIN : if received frame is incomplete (not find ST21NFCB_SOF_EOF
+ * -EAGAIN : if received frame is incomplete (not find ST_NCI_SOF_EOF
* at end of read)
* -EREMOTEIO : i2c read error (fatal)
* -EBADMSG : frame was incorrect and discarded
* (value returned from st_nci_i2c_repack)
- * -EIO : if no ST21NFCB_SOF_EOF is found after reaching
+ * -EIO : if no ST_NCI_SOF_EOF is found after reaching
* the read length end sequence
*/
static int st_nci_i2c_read(struct st_nci_i2c_phy *phy,
@@ -179,7 +179,7 @@ static int st_nci_i2c_read(struct st_nci_i2c_phy *phy,
/*
* Reads an ndlc frame from the chip.
*
- * On ST21NFCB, IRQ goes in idle state when read starts.
+ * On ST_NCI, IRQ goes in idle state when read starts.
*/
static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id)
{
@@ -325,12 +325,12 @@ static int st_nci_i2c_probe(struct i2c_client *client,
}
} else {
nfc_err(&client->dev,
- "st21nfcb platform resources not available\n");
+ "st_nci platform resources not available\n");
return -ENODEV;
}
r = ndlc_probe(phy, &i2c_phy_ops, &client->dev,
- ST21NFCB_FRAME_HEADROOM, ST21NFCB_FRAME_TAILROOM,
+ ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM,
&phy->ndlc);
if (r < 0) {
nfc_err(&client->dev, "Unable to register ndlc layer\n");
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/11] nfc: st-nci: Fix non accurate comment for st_nci_i2c_read
2015-08-14 20:33 [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Christophe Ricard
2015-08-14 20:33 ` [PATCH 01/11] nfc: st-nci: Remove duplicate file include/linux/platform_data/st_nci.h Christophe Ricard
2015-08-14 20:33 ` [PATCH 02/11] nfc: st-nci: Fix typo when changing from st21nfcb to st-nci Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 04/11] NFC: st21nfca: fix use of uninitialized variables in error path Christophe Ricard
` (3 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo; +Cc: linux-nfc, christophe-h.ricard, christophe.ricard, devicetree,
stable
Due to a copy and paste error st_nci_i2c_read still contain st21nfca header
comment.
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
drivers/nfc/st-nci/i2c.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index a15144d..707ed2e 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -118,15 +118,10 @@ static int st_nci_i2c_write(void *phy_id, struct sk_buff *skb)
/*
* Reads an ndlc frame and returns it in a newly allocated sk_buff.
* returns:
- * frame size : if received frame is complete (find ST_NCI_SOF_EOF at
- * end of read)
- * -EAGAIN : if received frame is incomplete (not find ST_NCI_SOF_EOF
- * at end of read)
+ * 0 : if received frame is complete
* -EREMOTEIO : i2c read error (fatal)
* -EBADMSG : frame was incorrect and discarded
- * (value returned from st_nci_i2c_repack)
- * -EIO : if no ST_NCI_SOF_EOF is found after reaching
- * the read length end sequence
+ * -ENOMEM : cannot allocate skb, frame dropped
*/
static int st_nci_i2c_read(struct st_nci_i2c_phy *phy,
struct sk_buff **skb)
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/11] NFC: st21nfca: fix use of uninitialized variables in error path
2015-08-14 20:33 [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Christophe Ricard
` (2 preceding siblings ...)
2015-08-14 20:33 ` [PATCH 03/11] nfc: st-nci: Fix non accurate comment for st_nci_i2c_read Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 06/11] nfc: st-nci: Remove data from ack_pending_q when receiving a NDLC PCB_SYNC_ACK Christophe Ricard
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo
Cc: linux-nfc, christophe-h.ricard, christophe.ricard, devicetree,
stable, Nicolas Iooss
st21nfca_hci_load_session() calls kfree_skb() on unitialized variables
skb_pipe_info and skb_pipe_list if the call to nfc_hci_connect_gate()
failed. Reword the error path to not use these variables when they are
not initialized. While at it, there seemed to be a memory leak because
skb_pipe_info was only freed once, after the for-loop, even though
several ones were created by nfc_hci_send_cmd.
Fixes: ec03ff1a8f9a ("NFC: st21nfca: Remove skb_pipe_list and skb_pipe_info
useless allocation")
Cc: stable@vger.kernel.org
Acked-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
---
drivers/nfc/st21nfca/st21nfca.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/nfc/st21nfca/st21nfca.c b/drivers/nfc/st21nfca/st21nfca.c
index d251f72..0512865 100644
--- a/drivers/nfc/st21nfca/st21nfca.c
+++ b/drivers/nfc/st21nfca/st21nfca.c
@@ -148,14 +148,14 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DEVICE_MGNT_PIPE);
if (r < 0)
- goto free_info;
+ return r;
/* Get pipe list */
r = nfc_hci_send_cmd(hdev, ST21NFCA_DEVICE_MGNT_GATE,
ST21NFCA_DM_GETINFO, pipe_list, sizeof(pipe_list),
&skb_pipe_list);
if (r < 0)
- goto free_info;
+ return r;
/* Complete the existing gate_pipe table */
for (i = 0; i < skb_pipe_list->len; i++) {
@@ -181,6 +181,7 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
info->src_host_id != ST21NFCA_ESE_HOST_ID) {
pr_err("Unexpected apdu_reader pipe on host %x\n",
info->src_host_id);
+ kfree_skb(skb_pipe_info);
continue;
}
@@ -200,6 +201,7 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
hdev->pipes[st21nfca_gates[j].pipe].dest_host =
info->src_host_id;
}
+ kfree_skb(skb_pipe_info);
}
/*
@@ -214,13 +216,12 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
st21nfca_gates[i].gate,
st21nfca_gates[i].pipe);
if (r < 0)
- goto free_info;
+ goto free_list;
}
}
memcpy(hdev->init_data.gates, st21nfca_gates, sizeof(st21nfca_gates));
-free_info:
- kfree_skb(skb_pipe_info);
+free_list:
kfree_skb(skb_pipe_list);
return r;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/11] NFC: st-nci: fix use of uninitialized variables in error path
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 07/11] nfc: st-nci: Free data with irrelevant NDLC PCB_SYNC value Christophe Ricard
` (4 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo-VuQAYsv1563Yd54FQh9/CA
Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw, christophe-h.ricard-qxv4g6HH51o,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA,
Nicolas Iooss
st_nci_hci_load_session() calls kfree_skb() on unitialized variables
skb_pipe_info and skb_pipe_list if the call to nci_hci_connect_gate()
failed. Reword the error path to not use these variables when they are
not initialized. While at it, there seemed to be a memory leak because
skb_pipe_info was only freed once, after the for-loop, even though
several ones were created by nci_hci_send_cmd.
Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Acked-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
Signed-off-by: Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
---
drivers/nfc/st-nci/st-nci_se.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/nfc/st-nci/st-nci_se.c b/drivers/nfc/st-nci/st-nci_se.c
index 97addfa..c742ef6 100644
--- a/drivers/nfc/st-nci/st-nci_se.c
+++ b/drivers/nfc/st-nci/st-nci_se.c
@@ -189,14 +189,14 @@ int st_nci_hci_load_session(struct nci_dev *ndev)
ST_NCI_DEVICE_MGNT_GATE,
ST_NCI_DEVICE_MGNT_PIPE);
if (r < 0)
- goto free_info;
+ return r;
/* Get pipe list */
r = nci_hci_send_cmd(ndev, ST_NCI_DEVICE_MGNT_GATE,
ST_NCI_DM_GETINFO, pipe_list, sizeof(pipe_list),
&skb_pipe_list);
if (r < 0)
- goto free_info;
+ return r;
/* Complete the existing gate_pipe table */
for (i = 0; i < skb_pipe_list->len; i++) {
@@ -222,6 +222,7 @@ int st_nci_hci_load_session(struct nci_dev *ndev)
dm_pipe_info->src_host_id != ST_NCI_ESE_HOST_ID) {
pr_err("Unexpected apdu_reader pipe on host %x\n",
dm_pipe_info->src_host_id);
+ kfree_skb(skb_pipe_info);
continue;
}
@@ -241,13 +242,12 @@ int st_nci_hci_load_session(struct nci_dev *ndev)
ndev->hci_dev->pipes[st_nci_gates[j].pipe].host =
dm_pipe_info->src_host_id;
}
+ kfree_skb(skb_pipe_info);
}
memcpy(ndev->hci_dev->init_data.gates, st_nci_gates,
sizeof(st_nci_gates));
-free_info:
- kfree_skb(skb_pipe_info);
kfree_skb(skb_pipe_list);
return r;
}
--
2.1.4
--
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] 14+ messages in thread
* [PATCH 06/11] nfc: st-nci: Remove data from ack_pending_q when receiving a NDLC PCB_SYNC_ACK
2015-08-14 20:33 [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Christophe Ricard
` (3 preceding siblings ...)
2015-08-14 20:33 ` [PATCH 04/11] NFC: st21nfca: fix use of uninitialized variables in error path Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 11/11] nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA Christophe Ricard
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
6 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo; +Cc: linux-nfc, christophe-h.ricard, christophe.ricard, devicetree,
stable
When receiving a NDLC PCB_SYNC_ACK the pending data was never removed from
ack_pending_q and cleared.
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
drivers/nfc/st-nci/ndlc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/nfc/st-nci/ndlc.c b/drivers/nfc/st-nci/ndlc.c
index 56c6a4c..bb08b16 100644
--- a/drivers/nfc/st-nci/ndlc.c
+++ b/drivers/nfc/st-nci/ndlc.c
@@ -171,6 +171,8 @@ static void llt_ndlc_rcv_queue(struct llt_ndlc *ndlc)
if ((pcb & PCB_TYPE_MASK) == PCB_TYPE_SUPERVISOR) {
switch (pcb & PCB_SYNC_MASK) {
case PCB_SYNC_ACK:
+ skb = skb_dequeue(&ndlc->ack_pending_q);
+ kfree_skb(skb);
del_timer_sync(&ndlc->t1_timer);
del_timer_sync(&ndlc->t2_timer);
ndlc->t2_active = false;
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/11] nfc: st-nci: Free data with irrelevant NDLC PCB_SYNC value
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2015-08-14 20:33 ` [PATCH 05/11] NFC: st-nci: fix use of uninitialized variables in error path Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 08/11] nfc: st-nci: Add spi phy support for st21nfcb Christophe Ricard
` (3 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo-VuQAYsv1563Yd54FQh9/CA
Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw, christophe-h.ricard-qxv4g6HH51o,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA, stable-u79uwXL29TY76Z2rM5mHXA
PCB_SYNC different than PCB_TYPE_SUPERVISOR or PCB_TYPE_DATAFRAME should
be discarded.
Irrelevant data may be forwarded up to the ndlc state machine by phys like
spi to prevent missing potential data during "write" transaction.
Cc: stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/nfc/st-nci/ndlc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/nfc/st-nci/ndlc.c b/drivers/nfc/st-nci/ndlc.c
index bb08b16..4f51649 100644
--- a/drivers/nfc/st-nci/ndlc.c
+++ b/drivers/nfc/st-nci/ndlc.c
@@ -198,8 +198,10 @@ static void llt_ndlc_rcv_queue(struct llt_ndlc *ndlc)
kfree_skb(skb);
break;
}
- } else {
+ } else if ((pcb & PCB_TYPE_MASK) == PCB_TYPE_DATAFRAME) {
nci_recv_frame(ndlc->ndev, skb);
+ } else {
+ kfree_skb(skb);
}
}
}
--
2.1.4
--
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] 14+ messages in thread
* [PATCH 08/11] nfc: st-nci: Add spi phy support for st21nfcb
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2015-08-14 20:33 ` [PATCH 05/11] NFC: st-nci: fix use of uninitialized variables in error path Christophe Ricard
2015-08-14 20:33 ` [PATCH 07/11] nfc: st-nci: Free data with irrelevant NDLC PCB_SYNC value Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 09/11] nfc: st-nci: Add device tree documentation for spi phy Christophe Ricard
` (2 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo-VuQAYsv1563Yd54FQh9/CA
Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw, christophe-h.ricard-qxv4g6HH51o,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA
st21nfcb does support another phy than i2c: spi.
st21nfcc does not support spi as the spi ios are used
by the AMS RF booster.
st21nfcb is not following NCI NFC Forum recommendations for spi but rely
on ST prioritary protocol ndlc as for i2c.
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/nfc/st-nci/Kconfig | 11 ++
drivers/nfc/st-nci/Makefile | 3 +
drivers/nfc/st-nci/spi.c | 392 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 406 insertions(+)
create mode 100644 drivers/nfc/st-nci/spi.c
diff --git a/drivers/nfc/st-nci/Kconfig b/drivers/nfc/st-nci/Kconfig
index fc3904c..e7c6db9 100644
--- a/drivers/nfc/st-nci/Kconfig
+++ b/drivers/nfc/st-nci/Kconfig
@@ -21,3 +21,14 @@ config NFC_ST_NCI_I2C
If you choose to build a module, it'll be called st-nci_i2c.
Say N if unsure.
+
+config NFC_ST_NCI_SPI
+ tristate "NFC ST NCI spi support"
+ depends on NFC_ST_NCI && SPI
+ ---help---
+ This module adds support for an SPI interface to the
+ STMicroelectronics NFC NCI chips familly.
+ Select this if your platform is using the spi bus.
+
+ If you choose to build a module, it'll be called st-nci_spi.
+ Say N if unsure.
diff --git a/drivers/nfc/st-nci/Makefile b/drivers/nfc/st-nci/Makefile
index 0df157d..348ce76 100644
--- a/drivers/nfc/st-nci/Makefile
+++ b/drivers/nfc/st-nci/Makefile
@@ -7,3 +7,6 @@ obj-$(CONFIG_NFC_ST_NCI) += st-nci.o
st-nci_i2c-objs = i2c.o
obj-$(CONFIG_NFC_ST_NCI_I2C) += st-nci_i2c.o
+
+st-nci_spi-objs = spi.o
+obj-$(CONFIG_NFC_ST_NCI_SPI) += st-nci_spi.o
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
new file mode 100644
index 0000000..598a58c
--- /dev/null
+++ b/drivers/nfc/st-nci/spi.c
@@ -0,0 +1,392 @@
+/*
+ * SPI Link Layer for ST NCI based Driver
+ * Copyright (C) 2014-2015 STMicroelectronics SAS. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+#include <linux/gpio.h>
+#include <linux/of_irq.h>
+#include <linux/of_gpio.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/nfc.h>
+#include <linux/platform_data/st-nci.h>
+
+#include "ndlc.h"
+
+#define DRIVER_DESC "NCI NFC driver for ST_NCI"
+
+/* ndlc header */
+#define ST_NCI_FRAME_HEADROOM 1
+#define ST_NCI_FRAME_TAILROOM 0
+
+#define ST_NCI_SPI_MIN_SIZE 4 /* PCB(1) + NCI Packet header(3) */
+#define ST_NCI_SPI_MAX_SIZE 250 /* req 4.2.1 */
+
+#define ST_NCI_SPI_DRIVER_NAME "st_nci_spi"
+
+static struct spi_device_id st_nci_spi_id_table[] = {
+ {ST_NCI_SPI_DRIVER_NAME, 0},
+ {}
+};
+MODULE_DEVICE_TABLE(spi, st_nci_spi_id_table);
+
+struct st_nci_spi_phy {
+ struct spi_device *spi_dev;
+ struct llt_ndlc *ndlc;
+
+ unsigned int gpio_reset;
+ unsigned int irq_polarity;
+};
+
+#define SPI_DUMP_SKB(info, skb) \
+do { \
+ pr_debug("%s:\n", info); \
+ print_hex_dump(KERN_DEBUG, "spi: ", DUMP_PREFIX_OFFSET, \
+ 16, 1, (skb)->data, (skb)->len, 0); \
+} while (0)
+
+static int st_nci_spi_enable(void *phy_id)
+{
+ struct st_nci_spi_phy *phy = phy_id;
+
+ gpio_set_value(phy->gpio_reset, 0);
+ usleep_range(10000, 15000);
+ gpio_set_value(phy->gpio_reset, 1);
+ usleep_range(80000, 85000);
+
+ if (phy->ndlc->powered == 0)
+ enable_irq(phy->spi_dev->irq);
+
+ return 0;
+}
+
+static void st_nci_spi_disable(void *phy_id)
+{
+ struct st_nci_spi_phy *phy = phy_id;
+
+ disable_irq_nosync(phy->spi_dev->irq);
+}
+
+/*
+ * Writing a frame must not return the number of written bytes.
+ * It must return either zero for success, or <0 for error.
+ * In addition, it must not alter the skb
+ */
+static int st_nci_spi_write(void *phy_id, struct sk_buff *skb)
+{
+ int r;
+ struct st_nci_spi_phy *phy = phy_id;
+ struct spi_device *dev = phy->spi_dev;
+ struct sk_buff *skb_rx;
+ u8 buf[ST_NCI_SPI_MAX_SIZE];
+ struct spi_transfer spi_xfer = {
+ .tx_buf = skb->data,
+ .rx_buf = buf,
+ .len = skb->len,
+ };
+
+ SPI_DUMP_SKB("st_nci_spi_write", skb);
+
+ if (phy->ndlc->hard_fault != 0)
+ return phy->ndlc->hard_fault;
+
+ r = spi_sync_transfer(dev, &spi_xfer, 1);
+ /*
+ * We may have received some valuable data on miso line.
+ * Send them back in the ndlc state machine.
+ */
+ if (!r) {
+ skb_rx = alloc_skb(skb->len, GFP_KERNEL);
+ if (!skb_rx) {
+ r = -ENOMEM;
+ goto exit;
+ }
+
+ skb_put(skb_rx, skb->len);
+ memcpy(skb_rx->data, buf, skb->len);
+ ndlc_recv(phy->ndlc, skb_rx);
+ }
+
+exit:
+ return r;
+}
+
+/*
+ * Reads an ndlc frame and returns it in a newly allocated sk_buff.
+ * returns:
+ * 0 : if received frame is complete
+ * -EREMOTEIO : i2c read error (fatal)
+ * -EBADMSG : frame was incorrect and discarded
+ * -ENOMEM : cannot allocate skb, frame dropped
+ */
+static int st_nci_spi_read(struct st_nci_spi_phy *phy,
+ struct sk_buff **skb)
+{
+ int r;
+ u8 len;
+ u8 buf[ST_NCI_SPI_MAX_SIZE];
+ struct spi_device *dev = phy->spi_dev;
+ struct spi_transfer spi_xfer = {
+ .rx_buf = buf,
+ .len = ST_NCI_SPI_MIN_SIZE,
+ };
+
+ r = spi_sync_transfer(dev, &spi_xfer, 1);
+ if (r < 0)
+ return -EREMOTEIO;
+
+ len = be16_to_cpu(*(__be16 *) (buf + 2));
+ if (len > ST_NCI_SPI_MAX_SIZE) {
+ nfc_err(&dev->dev, "invalid frame len\n");
+ phy->ndlc->hard_fault = 1;
+ return -EBADMSG;
+ }
+
+ *skb = alloc_skb(ST_NCI_SPI_MIN_SIZE + len, GFP_KERNEL);
+ if (*skb == NULL)
+ return -ENOMEM;
+
+ skb_reserve(*skb, ST_NCI_SPI_MIN_SIZE);
+ skb_put(*skb, ST_NCI_SPI_MIN_SIZE);
+ memcpy((*skb)->data, buf, ST_NCI_SPI_MIN_SIZE);
+
+ if (!len)
+ return 0;
+
+ spi_xfer.len = len;
+ r = spi_sync_transfer(dev, &spi_xfer, 1);
+ if (r < 0) {
+ kfree_skb(*skb);
+ return -EREMOTEIO;
+ }
+
+ skb_put(*skb, len);
+ memcpy((*skb)->data + ST_NCI_SPI_MIN_SIZE, buf, len);
+
+ SPI_DUMP_SKB("spi frame read", *skb);
+
+ return 0;
+}
+
+/*
+ * Reads an ndlc frame from the chip.
+ *
+ * On ST21NFCB, IRQ goes in idle state when read starts.
+ */
+static irqreturn_t st_nci_irq_thread_fn(int irq, void *phy_id)
+{
+ struct st_nci_spi_phy *phy = phy_id;
+ struct spi_device *dev;
+ struct sk_buff *skb = NULL;
+ int r;
+
+ if (!phy || !phy->ndlc || irq != phy->spi_dev->irq) {
+ WARN_ON_ONCE(1);
+ return IRQ_NONE;
+ }
+
+ dev = phy->spi_dev;
+ dev_dbg(&dev->dev, "IRQ\n");
+
+ if (phy->ndlc->hard_fault)
+ return IRQ_HANDLED;
+
+ if (!phy->ndlc->powered) {
+ st_nci_spi_disable(phy);
+ return IRQ_HANDLED;
+ }
+
+ r = st_nci_spi_read(phy, &skb);
+ if (r == -EREMOTEIO || r == -ENOMEM || r == -EBADMSG)
+ return IRQ_HANDLED;
+
+ ndlc_recv(phy->ndlc, skb);
+
+ return IRQ_HANDLED;
+}
+
+static struct nfc_phy_ops spi_phy_ops = {
+ .write = st_nci_spi_write,
+ .enable = st_nci_spi_enable,
+ .disable = st_nci_spi_disable,
+};
+
+#ifdef CONFIG_OF
+static int st_nci_spi_of_request_resources(struct spi_device *dev)
+{
+ struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
+ struct device_node *pp;
+ int gpio;
+ int r;
+
+ pp = dev->dev.of_node;
+ if (!pp)
+ return -ENODEV;
+
+ /* Get GPIO from device tree */
+ gpio = of_get_named_gpio(pp, "reset-gpios", 0);
+ if (gpio < 0) {
+ nfc_err(&dev->dev,
+ "Failed to retrieve reset-gpios from device tree\n");
+ return gpio;
+ }
+
+ /* GPIO request and configuration */
+ r = devm_gpio_request_one(&dev->dev, gpio,
+ GPIOF_OUT_INIT_HIGH, "clf_reset");
+ if (r) {
+ nfc_err(&dev->dev, "Failed to request reset pin\n");
+ return r;
+ }
+ phy->gpio_reset = gpio;
+
+ phy->irq_polarity = irq_get_trigger_type(dev->irq);
+
+ return 0;
+}
+#else
+static int st_nci_spi_of_request_resources(struct spi_device *dev)
+{
+ return -ENODEV;
+}
+#endif
+
+static int st_nci_spi_request_resources(struct spi_device *dev)
+{
+ struct st_nci_nfc_platform_data *pdata;
+ struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
+ int r;
+
+ pdata = dev->dev.platform_data;
+ if (pdata == NULL) {
+ nfc_err(&dev->dev, "No platform data\n");
+ return -EINVAL;
+ }
+
+ /* store for later use */
+ phy->gpio_reset = pdata->gpio_reset;
+ phy->irq_polarity = pdata->irq_polarity;
+
+ r = devm_gpio_request_one(&dev->dev,
+ phy->gpio_reset, GPIOF_OUT_INIT_HIGH, "clf_reset");
+ if (r) {
+ pr_err("%s : reset gpio_request failed\n", __FILE__);
+ return r;
+ }
+
+ return 0;
+}
+
+static int st_nci_spi_probe(struct spi_device *dev)
+{
+ struct st_nci_spi_phy *phy;
+ struct st_nci_nfc_platform_data *pdata;
+ int r;
+
+ dev_dbg(&dev->dev, "%s\n", __func__);
+ dev_dbg(&dev->dev, "IRQ: %d\n", dev->irq);
+
+ /* Check SPI platform functionnalities */
+ if (!dev) {
+ pr_debug("%s: dev is NULL. Device is not accessible.\n",
+ __func__);
+ return -ENODEV;
+ }
+
+ phy = devm_kzalloc(&dev->dev, sizeof(struct st_nci_spi_phy),
+ GFP_KERNEL);
+ if (!phy)
+ return -ENOMEM;
+
+ phy->spi_dev = dev;
+
+ spi_set_drvdata(dev, phy);
+
+ pdata = dev->dev.platform_data;
+ if (!pdata && dev->dev.of_node) {
+ r = st_nci_spi_of_request_resources(dev);
+ if (r) {
+ nfc_err(&dev->dev, "No platform data\n");
+ return r;
+ }
+ } else if (pdata) {
+ r = st_nci_spi_request_resources(dev);
+ if (r) {
+ nfc_err(&dev->dev,
+ "Cannot get platform resources\n");
+ return r;
+ }
+ } else {
+ nfc_err(&dev->dev,
+ "st_nci platform resources not available\n");
+ return -ENODEV;
+ }
+
+ r = ndlc_probe(phy, &spi_phy_ops, &dev->dev,
+ ST_NCI_FRAME_HEADROOM, ST_NCI_FRAME_TAILROOM,
+ &phy->ndlc);
+ if (r < 0) {
+ nfc_err(&dev->dev, "Unable to register ndlc layer\n");
+ return r;
+ }
+
+ r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL,
+ st_nci_irq_thread_fn,
+ phy->irq_polarity | IRQF_ONESHOT,
+ ST_NCI_SPI_DRIVER_NAME, phy);
+ if (r < 0)
+ nfc_err(&dev->dev, "Unable to register IRQ handler\n");
+
+ return r;
+}
+
+static int st_nci_spi_remove(struct spi_device *dev)
+{
+ struct st_nci_spi_phy *phy = spi_get_drvdata(dev);
+
+ dev_dbg(&dev->dev, "%s\n", __func__);
+
+ ndlc_remove(phy->ndlc);
+
+ return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id of_st_nci_spi_match[] = {
+ { .compatible = "st,st21nfcb-spi", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, of_st_nci_spi_match);
+#endif
+
+static struct spi_driver st_nci_spi_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = ST_NCI_SPI_DRIVER_NAME,
+ .of_match_table = of_match_ptr(of_st_nci_spi_match),
+ },
+ .probe = st_nci_spi_probe,
+ .id_table = st_nci_spi_id_table,
+ .remove = st_nci_spi_remove,
+};
+
+module_spi_driver(st_nci_spi_driver);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION(DRIVER_DESC);
--
2.1.4
--
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] 14+ messages in thread
* [PATCH 09/11] nfc: st-nci: Add device tree documentation for spi phy
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (2 preceding siblings ...)
2015-08-14 20:33 ` [PATCH 08/11] nfc: st-nci: Add spi phy support for st21nfcb Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-14 20:33 ` [PATCH 10/11] nfc: st-nci: Remove pr_err in llt_ndlc_rcv_queue when ndlc header is unknown Christophe Ricard
2015-08-16 23:39 ` [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Samuel Ortiz
5 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo-VuQAYsv1563Yd54FQh9/CA
Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw, christophe-h.ricard-qxv4g6HH51o,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA
Add st-nci-spi phy devicetree documentation
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
.../devicetree/bindings/net/nfc/st-nci-i2c.txt | 33 ++++++++++++++++++++++
.../devicetree/bindings/net/nfc/st-nci-spi.txt | 31 ++++++++++++++++++++
.../devicetree/bindings/net/nfc/st-nci.txt | 33 ----------------------
3 files changed, 64 insertions(+), 33 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/nfc/st-nci-i2c.txt
create mode 100644 Documentation/devicetree/bindings/net/nfc/st-nci-spi.txt
delete mode 100644 Documentation/devicetree/bindings/net/nfc/st-nci.txt
diff --git a/Documentation/devicetree/bindings/net/nfc/st-nci-i2c.txt b/Documentation/devicetree/bindings/net/nfc/st-nci-i2c.txt
new file mode 100644
index 0000000..d707588
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/nfc/st-nci-i2c.txt
@@ -0,0 +1,33 @@
+* STMicroelectronics SAS. ST NCI NFC Controller
+
+Required properties:
+- compatible: Should be "st,st21nfcb-i2c" or "st,st21nfcc-i2c".
+- clock-frequency: I²C work frequency.
+- reg: address on the bus
+- interrupt-parent: phandle for the interrupt gpio controller
+- interrupts: GPIO interrupt to which the chip is connected
+- reset-gpios: Output GPIO pin used to reset the ST21NFCB
+
+Optional SoC Specific Properties:
+- pinctrl-names: Contains only one value - "default".
+- pintctrl-0: Specifies the pin control groups used for this controller.
+
+Example (for ARM-based BeagleBoard xM with ST21NFCB on I2C2):
+
+&i2c2 {
+
+ status = "okay";
+
+ st21nfcb: st21nfcb@8 {
+
+ compatible = "st,st21nfcb-i2c";
+
+ reg = <0x08>;
+ clock-frequency = <400000>;
+
+ interrupt-parent = <&gpio5>;
+ interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
+
+ reset-gpios = <&gpio5 29 GPIO_ACTIVE_HIGH>;
+ };
+};
diff --git a/Documentation/devicetree/bindings/net/nfc/st-nci-spi.txt b/Documentation/devicetree/bindings/net/nfc/st-nci-spi.txt
new file mode 100644
index 0000000..525681b
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/nfc/st-nci-spi.txt
@@ -0,0 +1,31 @@
+* STMicroelectronics SAS. ST NCI NFC Controller
+
+Required properties:
+- compatible: Should be "st,st21nfcb-spi"
+- spi-max-frequency: Maximum SPI frequency (<= 10000000).
+- interrupt-parent: phandle for the interrupt gpio controller
+- interrupts: GPIO interrupt to which the chip is connected
+- reset-gpios: Output GPIO pin used to reset the ST21NFCB
+
+Optional SoC Specific Properties:
+- pinctrl-names: Contains only one value - "default".
+- pintctrl-0: Specifies the pin control groups used for this controller.
+
+Example (for ARM-based BeagleBoard xM with ST21NFCB on SPI4):
+
+&mcspi4 {
+
+ status = "okay";
+
+ st21nfcb: st21nfcb@0 {
+
+ compatible = "st,st21nfcb-spi";
+
+ clock-frequency = <4000000>;
+
+ interrupt-parent = <&gpio5>;
+ interrupts = <2 IRQ_TYPE_EDGE_RISING>;
+
+ reset-gpios = <&gpio5 29 GPIO_ACTIVE_HIGH>;
+ };
+};
diff --git a/Documentation/devicetree/bindings/net/nfc/st-nci.txt b/Documentation/devicetree/bindings/net/nfc/st-nci.txt
deleted file mode 100644
index d707588..0000000
--- a/Documentation/devicetree/bindings/net/nfc/st-nci.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-* STMicroelectronics SAS. ST NCI NFC Controller
-
-Required properties:
-- compatible: Should be "st,st21nfcb-i2c" or "st,st21nfcc-i2c".
-- clock-frequency: I²C work frequency.
-- reg: address on the bus
-- interrupt-parent: phandle for the interrupt gpio controller
-- interrupts: GPIO interrupt to which the chip is connected
-- reset-gpios: Output GPIO pin used to reset the ST21NFCB
-
-Optional SoC Specific Properties:
-- pinctrl-names: Contains only one value - "default".
-- pintctrl-0: Specifies the pin control groups used for this controller.
-
-Example (for ARM-based BeagleBoard xM with ST21NFCB on I2C2):
-
-&i2c2 {
-
- status = "okay";
-
- st21nfcb: st21nfcb@8 {
-
- compatible = "st,st21nfcb-i2c";
-
- reg = <0x08>;
- clock-frequency = <400000>;
-
- interrupt-parent = <&gpio5>;
- interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
-
- reset-gpios = <&gpio5 29 GPIO_ACTIVE_HIGH>;
- };
-};
--
2.1.4
--
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] 14+ messages in thread
* [PATCH 10/11] nfc: st-nci: Remove pr_err in llt_ndlc_rcv_queue when ndlc header is unknown
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (3 preceding siblings ...)
2015-08-14 20:33 ` [PATCH 09/11] nfc: st-nci: Add device tree documentation for spi phy Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-16 23:39 ` [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Samuel Ortiz
5 siblings, 0 replies; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo-VuQAYsv1563Yd54FQh9/CA
Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw, christophe-h.ricard-qxv4g6HH51o,
christophe.ricard-Re5JQEeQqe8AvxtiuMwx3w,
devicetree-u79uwXL29TY76Z2rM5mHXA
spi phy needs to use ndlc_recv at every spi transaction causing "unknown
packet control byte" error message each time the header is 00.
Make this silent.
Signed-off-by: Christophe Ricard <christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
---
drivers/nfc/st-nci/ndlc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/nfc/st-nci/ndlc.c b/drivers/nfc/st-nci/ndlc.c
index 4f51649..d2cf84e 100644
--- a/drivers/nfc/st-nci/ndlc.c
+++ b/drivers/nfc/st-nci/ndlc.c
@@ -194,7 +194,6 @@ static void llt_ndlc_rcv_queue(struct llt_ndlc *ndlc)
msecs_to_jiffies(NDLC_TIMER_T1_WAIT));
break;
default:
- pr_err("UNKNOWN Packet Control Byte=%d\n", pcb);
kfree_skb(skb);
break;
}
--
2.1.4
--
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] 14+ messages in thread
* [PATCH 11/11] nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA
2015-08-14 20:33 [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Christophe Ricard
` (4 preceding siblings ...)
2015-08-14 20:33 ` [PATCH 06/11] nfc: st-nci: Remove data from ack_pending_q when receiving a NDLC PCB_SYNC_ACK Christophe Ricard
@ 2015-08-14 20:33 ` Christophe Ricard
2015-08-16 23:38 ` Samuel Ortiz
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
6 siblings, 1 reply; 14+ messages in thread
From: Christophe Ricard @ 2015-08-14 20:33 UTC (permalink / raw)
To: sameo; +Cc: linux-nfc, christophe-h.ricard, christophe.ricard, devicetree,
stable
NFC_ATTR_VENDOR_DATA is an optional vendor_cmd argument.
The current code was potentially using a non existing argument leading
to potential catastrophic results.
Cc: stable@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
---
net/nfc/netlink.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index f85f37e..dcb858e 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1450,8 +1450,6 @@ nla_put_failure:
free_msg:
nlmsg_free(msg);
kfree(ctx);
-
- return;
}
static int nfc_genl_se_io(struct sk_buff *skb, struct genl_info *info)
@@ -1518,8 +1516,8 @@ static int nfc_genl_vendor_cmd(struct sk_buff *skb,
if (!dev || !dev->vendor_cmds || !dev->n_vendor_cmds)
return -ENODEV;
- data = nla_data(info->attrs[NFC_ATTR_VENDOR_DATA]);
- if (data) {
+ if (info->attrs[NFC_ATTR_VENDOR_DATA]) {
+ data = nla_data(info->attrs[NFC_ATTR_VENDOR_DATA]);
data_len = nla_len(info->attrs[NFC_ATTR_VENDOR_DATA]);
if (data_len == 0)
return -EINVAL;
@@ -1529,7 +1527,6 @@ static int nfc_genl_vendor_cmd(struct sk_buff *skb,
for (i = 0; i < dev->n_vendor_cmds; i++) {
cmd = &dev->vendor_cmds[i];
-
if (cmd->vendor_id != vid || cmd->subcmd != subcmd)
continue;
--
2.1.4
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 11/11] nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA
2015-08-14 20:33 ` [PATCH 11/11] nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA Christophe Ricard
@ 2015-08-16 23:38 ` Samuel Ortiz
0 siblings, 0 replies; 14+ messages in thread
From: Samuel Ortiz @ 2015-08-16 23:38 UTC (permalink / raw)
To: Christophe Ricard; +Cc: linux-nfc, christophe-h.ricard, devicetree, stable
Hi Christophe,
On Fri, Aug 14, 2015 at 10:33:40PM +0200, Christophe Ricard wrote:
> @@ -1450,8 +1450,6 @@ nla_put_failure:
> free_msg:
> nlmsg_free(msg);
> kfree(ctx);
> -
> - return;
This should not be part of the patch, I removed it.
> @@ -1529,7 +1527,6 @@ static int nfc_genl_vendor_cmd(struct sk_buff *skb,
>
> for (i = 0; i < dev->n_vendor_cmds; i++) {
> cmd = &dev->vendor_cmds[i];
> -
Ditto.
Cheers,
Samuel.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
` (4 preceding siblings ...)
2015-08-14 20:33 ` [PATCH 10/11] nfc: st-nci: Remove pr_err in llt_ndlc_rcv_queue when ndlc header is unknown Christophe Ricard
@ 2015-08-16 23:39 ` Samuel Ortiz
5 siblings, 0 replies; 14+ messages in thread
From: Samuel Ortiz @ 2015-08-16 23:39 UTC (permalink / raw)
To: Christophe Ricard
Cc: linux-nfc-hn68Rpc1hR1g9hUCZPvPmw, christophe-h.ricard-qxv4g6HH51o,
devicetree-u79uwXL29TY76Z2rM5mHXA
Hi Christophe,
On Fri, Aug 14, 2015 at 10:33:29PM +0200, Christophe Ricard wrote:
> Christophe Ricard (11):
> nfc: st-nci: Remove duplicate file
> include/linux/platform_data/st_nci.h
> nfc: st-nci: Fix typo when changing from st21nfcb to st-nci
> nfc: st-nci: Fix non accurate comment for st_nci_i2c_read
> NFC: st21nfca: fix use of uninitialized variables in error path
> NFC: st-nci: fix use of uninitialized variables in error path
> nfc: st-nci: Remove data from ack_pending_q when receiving a NDLC
> PCB_SYNC_ACK
> nfc: st-nci: Free data with irrelevant NDLC PCB_SYNC value
> nfc: st-nci: Add spi phy support for st21nfcb
> nfc: st-nci: Add device tree documentation for spi phy
> nfc: st-nci: Remove pr_err in llt_ndlc_rcv_queue when ndlc header is
> unknown
> nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA
Thanks a lot, all 11 patches applied, with a couple of minor fixes
for patch #11.
Cheers,
Samuel.
--
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] 14+ messages in thread
end of thread, other threads:[~2015-08-16 23:39 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-14 20:33 [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Christophe Ricard
2015-08-14 20:33 ` [PATCH 01/11] nfc: st-nci: Remove duplicate file include/linux/platform_data/st_nci.h Christophe Ricard
2015-08-14 20:33 ` [PATCH 02/11] nfc: st-nci: Fix typo when changing from st21nfcb to st-nci Christophe Ricard
2015-08-14 20:33 ` [PATCH 03/11] nfc: st-nci: Fix non accurate comment for st_nci_i2c_read Christophe Ricard
2015-08-14 20:33 ` [PATCH 04/11] NFC: st21nfca: fix use of uninitialized variables in error path Christophe Ricard
2015-08-14 20:33 ` [PATCH 06/11] nfc: st-nci: Remove data from ack_pending_q when receiving a NDLC PCB_SYNC_ACK Christophe Ricard
2015-08-14 20:33 ` [PATCH 11/11] nfc: netlink: Add check on NFC_ATTR_VENDOR_DATA Christophe Ricard
2015-08-16 23:38 ` Samuel Ortiz
[not found] ` <1439584420-5446-1-git-send-email-christophe-h.ricard-qxv4g6HH51o@public.gmane.org>
2015-08-14 20:33 ` [PATCH 05/11] NFC: st-nci: fix use of uninitialized variables in error path Christophe Ricard
2015-08-14 20:33 ` [PATCH 07/11] nfc: st-nci: Free data with irrelevant NDLC PCB_SYNC value Christophe Ricard
2015-08-14 20:33 ` [PATCH 08/11] nfc: st-nci: Add spi phy support for st21nfcb Christophe Ricard
2015-08-14 20:33 ` [PATCH 09/11] nfc: st-nci: Add device tree documentation for spi phy Christophe Ricard
2015-08-14 20:33 ` [PATCH 10/11] nfc: st-nci: Remove pr_err in llt_ndlc_rcv_queue when ndlc header is unknown Christophe Ricard
2015-08-16 23:39 ` [PATCH 00/11] Few st21nfca/st-nci NFC fixes and SPI phy support for st-nci Samuel Ortiz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).