NFC: st21nfca: Improved start of frame detection
authorChristophe Ricard <christophe.ricard@gmail.com>
Tue, 20 May 2014 20:21:55 +0000 (22:21 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 22 Jul 2014 23:04:31 +0000 (01:04 +0200)
A start of frame is 7E 00 not only 7E. Make sure the first read sequence is
starting with 7E 00.
For example: 7E FF FF FF FF is as a correct crc but it is a bad frame.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/st21nfca/i2c.c

index d10d837fb8880066322ec8cfc2156bc1d0124945..70564b3f2ab2db09665104c91f4fb5f3ea3a44b1 100644 (file)
@@ -397,12 +397,11 @@ static int st21nfca_hci_i2c_read(struct st21nfca_i2c_phy *phy,
                 * The first read sequence does not start with SOF.
                 * Data is corrupeted so we drop it.
                 */
-               if (!phy->current_read_len && buf[0] != ST21NFCA_SOF_EOF) {
+               if (!phy->current_read_len && !IS_START_OF_FRAME(buf)) {
                        skb_trim(skb, 0);
                        phy->current_read_len = 0;
                        return -EIO;
-               } else if (phy->current_read_len &&
-                       IS_START_OF_FRAME(buf)) {
+               } else if (phy->current_read_len && IS_START_OF_FRAME(buf)) {
                        /*
                         * Previous frame transmission was interrupted and
                         * the frame got repeated.