diff options
-rw-r--r-- | include/net/nfc/nci_core.h | 2 | ||||
-rw-r--r-- | net/nfc/nci/spi.c | 26 |
2 files changed, 11 insertions, 17 deletions
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h index 37ba06f2dfa9..1d505317dc67 100644 --- a/include/net/nfc/nci_core.h +++ b/include/net/nfc/nci_core.h | |||
@@ -233,6 +233,6 @@ struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi, | |||
233 | u8 acknowledge_mode, unsigned int delay, | 233 | u8 acknowledge_mode, unsigned int delay, |
234 | struct nci_dev *ndev); | 234 | struct nci_dev *ndev); |
235 | int nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb); | 235 | int nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb); |
236 | int nci_spi_recv_frame(struct nci_spi *nspi); | 236 | struct sk_buff *nci_spi_read(struct nci_spi *nspi); |
237 | 237 | ||
238 | #endif /* __NCI_CORE_H */ | 238 | #endif /* __NCI_CORE_H */ |
diff --git a/net/nfc/nci/spi.c b/net/nfc/nci/spi.c index c111506b36d1..734c6dde7751 100644 --- a/net/nfc/nci/spi.c +++ b/net/nfc/nci/spi.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <linux/export.h> | 21 | #include <linux/export.h> |
22 | #include <linux/spi/spi.h> | 22 | #include <linux/spi/spi.h> |
23 | #include <linux/crc-ccitt.h> | 23 | #include <linux/crc-ccitt.h> |
24 | #include <linux/nfc.h> | ||
25 | #include <net/nfc/nci_core.h> | 24 | #include <net/nfc/nci_core.h> |
26 | 25 | ||
27 | #define NCI_SPI_ACK_SHIFT 6 | 26 | #define NCI_SPI_ACK_SHIFT 6 |
@@ -164,7 +163,7 @@ static int send_acknowledge(struct nci_spi *nspi, u8 acknowledge) | |||
164 | return ret; | 163 | return ret; |
165 | } | 164 | } |
166 | 165 | ||
167 | static struct sk_buff *__nci_spi_recv_frame(struct nci_spi *nspi) | 166 | static struct sk_buff *__nci_spi_read(struct nci_spi *nspi) |
168 | { | 167 | { |
169 | struct sk_buff *skb; | 168 | struct sk_buff *skb; |
170 | struct spi_message m; | 169 | struct spi_message m; |
@@ -258,7 +257,7 @@ static u8 nci_spi_get_ack(struct sk_buff *skb) | |||
258 | } | 257 | } |
259 | 258 | ||
260 | /** | 259 | /** |
261 | * nci_spi_recv_frame - receive frame from NCI SPI drivers | 260 | * nci_spi_read - read frame from NCI SPI drivers |
262 | * | 261 | * |
263 | * @nspi: The nci spi | 262 | * @nspi: The nci spi |
264 | * Context: can sleep | 263 | * Context: can sleep |
@@ -266,21 +265,18 @@ static u8 nci_spi_get_ack(struct sk_buff *skb) | |||
266 | * This call may only be used from a context that may sleep. The sleep | 265 | * This call may only be used from a context that may sleep. The sleep |
267 | * is non-interruptible, and has no timeout. | 266 | * is non-interruptible, and has no timeout. |
268 | * | 267 | * |
269 | * It returns zero on success, else a negative error code. | 268 | * It returns an allocated skb containing the frame on success, or NULL. |
270 | */ | 269 | */ |
271 | int nci_spi_recv_frame(struct nci_spi *nspi) | 270 | struct sk_buff *nci_spi_read(struct nci_spi *nspi) |
272 | { | 271 | { |
273 | struct sk_buff *skb; | 272 | struct sk_buff *skb; |
274 | int ret = 0; | ||
275 | 273 | ||
276 | nspi->ops->deassert_int(nspi); | 274 | nspi->ops->deassert_int(nspi); |
277 | 275 | ||
278 | /* Retrieve frame from SPI */ | 276 | /* Retrieve frame from SPI */ |
279 | skb = __nci_spi_recv_frame(nspi); | 277 | skb = __nci_spi_read(nspi); |
280 | if (!skb) { | 278 | if (!skb) |
281 | ret = -EIO; | ||
282 | goto done; | 279 | goto done; |
283 | } | ||
284 | 280 | ||
285 | if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) { | 281 | if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) { |
286 | if (!nci_spi_check_crc(skb)) { | 282 | if (!nci_spi_check_crc(skb)) { |
@@ -299,20 +295,18 @@ int nci_spi_recv_frame(struct nci_spi *nspi) | |||
299 | /* If there is no payload (ACK/NACK only frame), | 295 | /* If there is no payload (ACK/NACK only frame), |
300 | * free the socket buffer | 296 | * free the socket buffer |
301 | */ | 297 | */ |
302 | if (skb->len == 0) { | 298 | if (!skb->len) { |
303 | kfree_skb(skb); | 299 | kfree_skb(skb); |
300 | skb = NULL; | ||
304 | goto done; | 301 | goto done; |
305 | } | 302 | } |
306 | 303 | ||
307 | if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) | 304 | if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) |
308 | send_acknowledge(nspi, ACKNOWLEDGE_ACK); | 305 | send_acknowledge(nspi, ACKNOWLEDGE_ACK); |
309 | 306 | ||
310 | /* Forward skb to NCI core layer */ | ||
311 | ret = nci_recv_frame(nspi->ndev, skb); | ||
312 | |||
313 | done: | 307 | done: |
314 | nspi->ops->assert_int(nspi); | 308 | nspi->ops->assert_int(nspi); |
315 | 309 | ||
316 | return ret; | 310 | return skb; |
317 | } | 311 | } |
318 | EXPORT_SYMBOL_GPL(nci_spi_recv_frame); | 312 | EXPORT_SYMBOL_GPL(nci_spi_read); |