diff options
Diffstat (limited to 'drivers/nfc/st21nfca/i2c.c')
-rw-r--r-- | drivers/nfc/st21nfca/i2c.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c index 4df15ef2528a..e29351ca7dd1 100644 --- a/drivers/nfc/st21nfca/i2c.c +++ b/drivers/nfc/st21nfca/i2c.c | |||
@@ -48,11 +48,11 @@ | |||
48 | #define ST21NFCA_BYTE_STUFFING_MASK 0x20 | 48 | #define ST21NFCA_BYTE_STUFFING_MASK 0x20 |
49 | #define ST21NFCA_ESCAPE_BYTE_STUFFING 0x7d | 49 | #define ST21NFCA_ESCAPE_BYTE_STUFFING 0x7d |
50 | 50 | ||
51 | /* SOF + 00 fill size */ | 51 | /* SOF + 00 */ |
52 | #define ST21NFCA_FRAME_HEADROOM 2 | 52 | #define ST21NFCA_FRAME_HEADROOM 2 |
53 | 53 | ||
54 | /* 4 bytes crc (worst case byte stuffing) + EOF */ | 54 | /* 2 bytes crc + EOF */ |
55 | #define ST21NFCA_FRAME_TAILROOM 5 | 55 | #define ST21NFCA_FRAME_TAILROOM 3 |
56 | 56 | ||
57 | #define ST21NFCA_HCI_I2C_DRIVER_NAME "st21nfca_hci_i2c" | 57 | #define ST21NFCA_HCI_I2C_DRIVER_NAME "st21nfca_hci_i2c" |
58 | 58 | ||
@@ -166,9 +166,8 @@ static void st21nfca_hci_i2c_disable(void *phy_id) | |||
166 | phy->powered = 0; | 166 | phy->powered = 0; |
167 | } | 167 | } |
168 | 168 | ||
169 | static int st21nfca_hci_add_len_crc(struct sk_buff *skb) | 169 | static void st21nfca_hci_add_len_crc(struct sk_buff *skb) |
170 | { | 170 | { |
171 | int ret = 2; | ||
172 | u16 crc; | 171 | u16 crc; |
173 | u8 tmp; | 172 | u8 tmp; |
174 | 173 | ||
@@ -182,14 +181,12 @@ static int st21nfca_hci_add_len_crc(struct sk_buff *skb) | |||
182 | 181 | ||
183 | tmp = (crc >> 8) & 0x00ff; | 182 | tmp = (crc >> 8) & 0x00ff; |
184 | *skb_put(skb, 1) = tmp; | 183 | *skb_put(skb, 1) = tmp; |
185 | |||
186 | return ret; | ||
187 | } | 184 | } |
188 | 185 | ||
189 | static void st21nfca_hci_remove_len_crc(struct sk_buff *skb, int crc_len) | 186 | static void st21nfca_hci_remove_len_crc(struct sk_buff *skb) |
190 | { | 187 | { |
191 | skb_pull(skb, ST21NFCA_FRAME_HEADROOM); | 188 | skb_pull(skb, ST21NFCA_FRAME_HEADROOM); |
192 | skb_trim(skb, crc_len); | 189 | skb_trim(skb, skb->len - ST21NFCA_FRAME_TAILROOM); |
193 | } | 190 | } |
194 | 191 | ||
195 | /* | 192 | /* |
@@ -199,7 +196,7 @@ static void st21nfca_hci_remove_len_crc(struct sk_buff *skb, int crc_len) | |||
199 | */ | 196 | */ |
200 | static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb) | 197 | static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb) |
201 | { | 198 | { |
202 | int r = -1, i, j, len; | 199 | int r = -1, i, j; |
203 | struct st21nfca_i2c_phy *phy = phy_id; | 200 | struct st21nfca_i2c_phy *phy = phy_id; |
204 | struct i2c_client *client = phy->i2c_dev; | 201 | struct i2c_client *client = phy->i2c_dev; |
205 | u8 tmp[ST21NFCA_HCI_LLC_MAX_SIZE * 2]; | 202 | u8 tmp[ST21NFCA_HCI_LLC_MAX_SIZE * 2]; |
@@ -215,7 +212,7 @@ static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb) | |||
215 | * Note st21nfca_hci_add_len_crc is doing a byte stuffing | 212 | * Note st21nfca_hci_add_len_crc is doing a byte stuffing |
216 | * on its own value | 213 | * on its own value |
217 | */ | 214 | */ |
218 | len = st21nfca_hci_add_len_crc(skb); | 215 | st21nfca_hci_add_len_crc(skb); |
219 | 216 | ||
220 | /* add ST21NFCA_SOF_EOF on tail */ | 217 | /* add ST21NFCA_SOF_EOF on tail */ |
221 | *skb_put(skb, 1) = ST21NFCA_SOF_EOF; | 218 | *skb_put(skb, 1) = ST21NFCA_SOF_EOF; |
@@ -259,7 +256,7 @@ static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb) | |||
259 | r = 0; | 256 | r = 0; |
260 | } | 257 | } |
261 | 258 | ||
262 | st21nfca_hci_remove_len_crc(skb, len); | 259 | st21nfca_hci_remove_len_crc(skb); |
263 | 260 | ||
264 | return r; | 261 | return r; |
265 | } | 262 | } |