~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/nfc/nci/spi.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /net/nfc/nci/spi.c (Version linux-6.11.5) and /net/nfc/nci/spi.c (Version linux-4.11.12)


  1 // SPDX-License-Identifier: GPL-2.0-only       << 
  2 /*                                                  1 /*
  3  * Copyright (C) 2013  Intel Corporation. All       2  * Copyright (C) 2013  Intel Corporation. All rights reserved.
                                                   >>   3  *
                                                   >>   4  * This program is free software; you can redistribute it and/or modify it
                                                   >>   5  * under the terms and conditions of the GNU General Public License,
                                                   >>   6  * version 2, as published by the Free Software Foundation.
                                                   >>   7  *
                                                   >>   8  * This program is distributed in the hope it will be useful, but WITHOUT
                                                   >>   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
                                                   >>  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
                                                   >>  11  * more details.
                                                   >>  12  *
                                                   >>  13  * You should have received a copy of the GNU General Public License along with
                                                   >>  14  * this program; if not, write to the Free Software Foundation, Inc.,
                                                   >>  15  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
                                                   >>  16  *
  4  */                                                17  */
  5                                                    18 
  6 #define pr_fmt(fmt) "nci_spi: %s: " fmt, __fun     19 #define pr_fmt(fmt) "nci_spi: %s: " fmt, __func__
  7                                                    20 
  8 #include <linux/module.h>                          21 #include <linux/module.h>
  9                                                    22 
 10 #include <linux/export.h>                          23 #include <linux/export.h>
 11 #include <linux/spi/spi.h>                         24 #include <linux/spi/spi.h>
 12 #include <linux/crc-ccitt.h>                       25 #include <linux/crc-ccitt.h>
 13 #include <net/nfc/nci_core.h>                      26 #include <net/nfc/nci_core.h>
 14                                                    27 
 15 #define NCI_SPI_ACK_SHIFT               6          28 #define NCI_SPI_ACK_SHIFT               6
 16 #define NCI_SPI_MSB_PAYLOAD_MASK        0x3F       29 #define NCI_SPI_MSB_PAYLOAD_MASK        0x3F
 17                                                    30 
 18 #define NCI_SPI_SEND_TIMEOUT    (NCI_CMD_TIMEO     31 #define NCI_SPI_SEND_TIMEOUT    (NCI_CMD_TIMEOUT > NCI_DATA_TIMEOUT ? \
 19                                         NCI_CM     32                                         NCI_CMD_TIMEOUT : NCI_DATA_TIMEOUT)
 20                                                    33 
 21 #define NCI_SPI_DIRECT_WRITE    0x01               34 #define NCI_SPI_DIRECT_WRITE    0x01
 22 #define NCI_SPI_DIRECT_READ     0x02               35 #define NCI_SPI_DIRECT_READ     0x02
 23                                                    36 
 24 #define ACKNOWLEDGE_NONE        0                  37 #define ACKNOWLEDGE_NONE        0
 25 #define ACKNOWLEDGE_ACK         1                  38 #define ACKNOWLEDGE_ACK         1
 26 #define ACKNOWLEDGE_NACK        2                  39 #define ACKNOWLEDGE_NACK        2
 27                                                    40 
 28 #define CRC_INIT                0xFFFF             41 #define CRC_INIT                0xFFFF
 29                                                    42 
 30 static int __nci_spi_send(struct nci_spi *nspi !!  43 static int __nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb,
 31                           int cs_change)           44                           int cs_change)
 32 {                                                  45 {
 33         struct spi_message m;                      46         struct spi_message m;
 34         struct spi_transfer t;                     47         struct spi_transfer t;
 35                                                    48 
 36         memset(&t, 0, sizeof(struct spi_transf     49         memset(&t, 0, sizeof(struct spi_transfer));
 37         /* a NULL skb means we just want the S     50         /* a NULL skb means we just want the SPI chip select line to raise */
 38         if (skb) {                                 51         if (skb) {
 39                 t.tx_buf = skb->data;              52                 t.tx_buf = skb->data;
 40                 t.len = skb->len;                  53                 t.len = skb->len;
 41         } else {                                   54         } else {
 42                 /* still set tx_buf non NULL t     55                 /* still set tx_buf non NULL to make the driver happy */
 43                 t.tx_buf = &t;                     56                 t.tx_buf = &t;
 44                 t.len = 0;                         57                 t.len = 0;
 45         }                                          58         }
 46         t.cs_change = cs_change;                   59         t.cs_change = cs_change;
 47         t.delay.value = nspi->xfer_udelay;     !!  60         t.delay_usecs = nspi->xfer_udelay;
 48         t.delay.unit = SPI_DELAY_UNIT_USECS;   << 
 49         t.speed_hz = nspi->xfer_speed_hz;          61         t.speed_hz = nspi->xfer_speed_hz;
 50                                                    62 
 51         spi_message_init(&m);                      63         spi_message_init(&m);
 52         spi_message_add_tail(&t, &m);              64         spi_message_add_tail(&t, &m);
 53                                                    65 
 54         return spi_sync(nspi->spi, &m);            66         return spi_sync(nspi->spi, &m);
 55 }                                                  67 }
 56                                                    68 
 57 int nci_spi_send(struct nci_spi *nspi,             69 int nci_spi_send(struct nci_spi *nspi,
 58                  struct completion *write_hand     70                  struct completion *write_handshake_completion,
 59                  struct sk_buff *skb)              71                  struct sk_buff *skb)
 60 {                                                  72 {
 61         unsigned int payload_len = skb->len;       73         unsigned int payload_len = skb->len;
 62         unsigned char *hdr;                        74         unsigned char *hdr;
 63         int ret;                                   75         int ret;
 64         long completion_rc;                        76         long completion_rc;
 65                                                    77 
 66         /* add the NCI SPI header to the start     78         /* add the NCI SPI header to the start of the buffer */
 67         hdr = skb_push(skb, NCI_SPI_HDR_LEN);      79         hdr = skb_push(skb, NCI_SPI_HDR_LEN);
 68         hdr[0] = NCI_SPI_DIRECT_WRITE;             80         hdr[0] = NCI_SPI_DIRECT_WRITE;
 69         hdr[1] = nspi->acknowledge_mode;           81         hdr[1] = nspi->acknowledge_mode;
 70         hdr[2] = payload_len >> 8;                 82         hdr[2] = payload_len >> 8;
 71         hdr[3] = payload_len & 0xFF;               83         hdr[3] = payload_len & 0xFF;
 72                                                    84 
 73         if (nspi->acknowledge_mode == NCI_SPI_     85         if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) {
 74                 u16 crc;                           86                 u16 crc;
 75                                                    87 
 76                 crc = crc_ccitt(CRC_INIT, skb-     88                 crc = crc_ccitt(CRC_INIT, skb->data, skb->len);
 77                 skb_put_u8(skb, crc >> 8);     !!  89                 *skb_put(skb, 1) = crc >> 8;
 78                 skb_put_u8(skb, crc & 0xFF);   !!  90                 *skb_put(skb, 1) = crc & 0xFF;
 79         }                                          91         }
 80                                                    92 
 81         if (write_handshake_completion) {          93         if (write_handshake_completion) {
 82                 /* Trick SPI driver to raise c     94                 /* Trick SPI driver to raise chip select */
 83                 ret = __nci_spi_send(nspi, NUL     95                 ret = __nci_spi_send(nspi, NULL, 1);
 84                 if (ret)                           96                 if (ret)
 85                         goto done;                 97                         goto done;
 86                                                    98 
 87                 /* wait for NFC chip hardware      99                 /* wait for NFC chip hardware handshake to complete */
 88                 if (wait_for_completion_timeou    100                 if (wait_for_completion_timeout(write_handshake_completion,
 89                                                   101                                                 msecs_to_jiffies(1000)) == 0) {
 90                         ret = -ETIME;             102                         ret = -ETIME;
 91                         goto done;                103                         goto done;
 92                 }                                 104                 }
 93         }                                         105         }
 94                                                   106 
 95         ret = __nci_spi_send(nspi, skb, 0);       107         ret = __nci_spi_send(nspi, skb, 0);
 96         if (ret != 0 || nspi->acknowledge_mode    108         if (ret != 0 || nspi->acknowledge_mode == NCI_SPI_CRC_DISABLED)
 97                 goto done;                        109                 goto done;
 98                                                   110 
 99         reinit_completion(&nspi->req_completio    111         reinit_completion(&nspi->req_completion);
100         completion_rc = wait_for_completion_in    112         completion_rc = wait_for_completion_interruptible_timeout(
101                                                   113                                                         &nspi->req_completion,
102                                                   114                                                         NCI_SPI_SEND_TIMEOUT);
103                                                   115 
104         if (completion_rc <= 0 || nspi->req_re    116         if (completion_rc <= 0 || nspi->req_result == ACKNOWLEDGE_NACK)
105                 ret = -EIO;                       117                 ret = -EIO;
106                                                   118 
107 done:                                             119 done:
108         kfree_skb(skb);                           120         kfree_skb(skb);
109                                                   121 
110         return ret;                               122         return ret;
111 }                                                 123 }
112 EXPORT_SYMBOL_GPL(nci_spi_send);                  124 EXPORT_SYMBOL_GPL(nci_spi_send);
113                                                   125 
114 /* ---- Interface to NCI SPI drivers ---- */      126 /* ---- Interface to NCI SPI drivers ---- */
115                                                   127 
116 /**                                               128 /**
117  * nci_spi_allocate_spi - allocate a new nci s    129  * nci_spi_allocate_spi - allocate a new nci spi
118  *                                                130  *
119  * @spi: SPI device                               131  * @spi: SPI device
120  * @acknowledge_mode: Acknowledge mode used by    132  * @acknowledge_mode: Acknowledge mode used by the NFC device
121  * @delay: delay between transactions in us       133  * @delay: delay between transactions in us
122  * @ndev: nci dev to send incoming nci frames     134  * @ndev: nci dev to send incoming nci frames to
123  */                                               135  */
124 struct nci_spi *nci_spi_allocate_spi(struct sp    136 struct nci_spi *nci_spi_allocate_spi(struct spi_device *spi,
125                                      u8 acknow    137                                      u8 acknowledge_mode, unsigned int delay,
126                                      struct nc    138                                      struct nci_dev *ndev)
127 {                                                 139 {
128         struct nci_spi *nspi;                     140         struct nci_spi *nspi;
129                                                   141 
130         nspi = devm_kzalloc(&spi->dev, sizeof(    142         nspi = devm_kzalloc(&spi->dev, sizeof(struct nci_spi), GFP_KERNEL);
131         if (!nspi)                                143         if (!nspi)
132                 return NULL;                      144                 return NULL;
133                                                   145 
134         nspi->acknowledge_mode = acknowledge_m    146         nspi->acknowledge_mode = acknowledge_mode;
135         nspi->xfer_udelay = delay;                147         nspi->xfer_udelay = delay;
136         /* Use controller max SPI speed by def    148         /* Use controller max SPI speed by default */
137         nspi->xfer_speed_hz = 0;                  149         nspi->xfer_speed_hz = 0;
138         nspi->spi = spi;                          150         nspi->spi = spi;
139         nspi->ndev = ndev;                        151         nspi->ndev = ndev;
140         init_completion(&nspi->req_completion)    152         init_completion(&nspi->req_completion);
141                                                   153 
142         return nspi;                              154         return nspi;
143 }                                                 155 }
144 EXPORT_SYMBOL_GPL(nci_spi_allocate_spi);          156 EXPORT_SYMBOL_GPL(nci_spi_allocate_spi);
145                                                   157 
146 static int send_acknowledge(struct nci_spi *ns    158 static int send_acknowledge(struct nci_spi *nspi, u8 acknowledge)
147 {                                                 159 {
148         struct sk_buff *skb;                      160         struct sk_buff *skb;
149         unsigned char *hdr;                       161         unsigned char *hdr;
150         u16 crc;                                  162         u16 crc;
151         int ret;                                  163         int ret;
152                                                   164 
153         skb = nci_skb_alloc(nspi->ndev, 0, GFP    165         skb = nci_skb_alloc(nspi->ndev, 0, GFP_KERNEL);
154         if (!skb)                              << 
155                 return -ENOMEM;                << 
156                                                   166 
157         /* add the NCI SPI header to the start    167         /* add the NCI SPI header to the start of the buffer */
158         hdr = skb_push(skb, NCI_SPI_HDR_LEN);     168         hdr = skb_push(skb, NCI_SPI_HDR_LEN);
159         hdr[0] = NCI_SPI_DIRECT_WRITE;            169         hdr[0] = NCI_SPI_DIRECT_WRITE;
160         hdr[1] = NCI_SPI_CRC_ENABLED;             170         hdr[1] = NCI_SPI_CRC_ENABLED;
161         hdr[2] = acknowledge << NCI_SPI_ACK_SH    171         hdr[2] = acknowledge << NCI_SPI_ACK_SHIFT;
162         hdr[3] = 0;                               172         hdr[3] = 0;
163                                                   173 
164         crc = crc_ccitt(CRC_INIT, skb->data, s    174         crc = crc_ccitt(CRC_INIT, skb->data, skb->len);
165         skb_put_u8(skb, crc >> 8);             !! 175         *skb_put(skb, 1) = crc >> 8;
166         skb_put_u8(skb, crc & 0xFF);           !! 176         *skb_put(skb, 1) = crc & 0xFF;
167                                                   177 
168         ret = __nci_spi_send(nspi, skb, 0);       178         ret = __nci_spi_send(nspi, skb, 0);
169                                                   179 
170         kfree_skb(skb);                           180         kfree_skb(skb);
171                                                   181 
172         return ret;                               182         return ret;
173 }                                                 183 }
174                                                   184 
175 static struct sk_buff *__nci_spi_read(struct n    185 static struct sk_buff *__nci_spi_read(struct nci_spi *nspi)
176 {                                                 186 {
177         struct sk_buff *skb;                      187         struct sk_buff *skb;
178         struct spi_message m;                     188         struct spi_message m;
179         unsigned char req[2], resp_hdr[2];        189         unsigned char req[2], resp_hdr[2];
180         struct spi_transfer tx, rx;               190         struct spi_transfer tx, rx;
181         unsigned short rx_len = 0;                191         unsigned short rx_len = 0;
182         int ret;                                  192         int ret;
183                                                   193 
184         spi_message_init(&m);                     194         spi_message_init(&m);
185                                                   195 
186         memset(&tx, 0, sizeof(struct spi_trans    196         memset(&tx, 0, sizeof(struct spi_transfer));
187         req[0] = NCI_SPI_DIRECT_READ;             197         req[0] = NCI_SPI_DIRECT_READ;
188         req[1] = nspi->acknowledge_mode;          198         req[1] = nspi->acknowledge_mode;
189         tx.tx_buf = req;                          199         tx.tx_buf = req;
190         tx.len = 2;                               200         tx.len = 2;
191         tx.cs_change = 0;                         201         tx.cs_change = 0;
192         tx.speed_hz = nspi->xfer_speed_hz;        202         tx.speed_hz = nspi->xfer_speed_hz;
193         spi_message_add_tail(&tx, &m);            203         spi_message_add_tail(&tx, &m);
194                                                   204 
195         memset(&rx, 0, sizeof(struct spi_trans    205         memset(&rx, 0, sizeof(struct spi_transfer));
196         rx.rx_buf = resp_hdr;                     206         rx.rx_buf = resp_hdr;
197         rx.len = 2;                               207         rx.len = 2;
198         rx.cs_change = 1;                         208         rx.cs_change = 1;
199         rx.speed_hz = nspi->xfer_speed_hz;        209         rx.speed_hz = nspi->xfer_speed_hz;
200         spi_message_add_tail(&rx, &m);            210         spi_message_add_tail(&rx, &m);
201                                                   211 
202         ret = spi_sync(nspi->spi, &m);            212         ret = spi_sync(nspi->spi, &m);
203         if (ret)                                  213         if (ret)
204                 return NULL;                      214                 return NULL;
205                                                   215 
206         if (nspi->acknowledge_mode == NCI_SPI_    216         if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED)
207                 rx_len = ((resp_hdr[0] & NCI_S    217                 rx_len = ((resp_hdr[0] & NCI_SPI_MSB_PAYLOAD_MASK) << 8) +
208                                 resp_hdr[1] +     218                                 resp_hdr[1] + NCI_SPI_CRC_LEN;
209         else                                      219         else
210                 rx_len = (resp_hdr[0] << 8) |     220                 rx_len = (resp_hdr[0] << 8) | resp_hdr[1];
211                                                   221 
212         skb = nci_skb_alloc(nspi->ndev, rx_len    222         skb = nci_skb_alloc(nspi->ndev, rx_len, GFP_KERNEL);
213         if (!skb)                                 223         if (!skb)
214                 return NULL;                      224                 return NULL;
215                                                   225 
216         spi_message_init(&m);                     226         spi_message_init(&m);
217                                                   227 
218         memset(&rx, 0, sizeof(struct spi_trans    228         memset(&rx, 0, sizeof(struct spi_transfer));
219         rx.rx_buf = skb_put(skb, rx_len);         229         rx.rx_buf = skb_put(skb, rx_len);
220         rx.len = rx_len;                          230         rx.len = rx_len;
221         rx.cs_change = 0;                         231         rx.cs_change = 0;
222         rx.delay.value = nspi->xfer_udelay;    !! 232         rx.delay_usecs = nspi->xfer_udelay;
223         rx.delay.unit = SPI_DELAY_UNIT_USECS;  << 
224         rx.speed_hz = nspi->xfer_speed_hz;        233         rx.speed_hz = nspi->xfer_speed_hz;
225         spi_message_add_tail(&rx, &m);            234         spi_message_add_tail(&rx, &m);
226                                                   235 
227         ret = spi_sync(nspi->spi, &m);            236         ret = spi_sync(nspi->spi, &m);
228         if (ret)                                  237         if (ret)
229                 goto receive_error;               238                 goto receive_error;
230                                                   239 
231         if (nspi->acknowledge_mode == NCI_SPI_    240         if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) {
232                 *(u8 *)skb_push(skb, 1) = resp !! 241                 *skb_push(skb, 1) = resp_hdr[1];
233                 *(u8 *)skb_push(skb, 1) = resp !! 242                 *skb_push(skb, 1) = resp_hdr[0];
234         }                                         243         }
235                                                   244 
236         return skb;                               245         return skb;
237                                                   246 
238 receive_error:                                    247 receive_error:
239         kfree_skb(skb);                           248         kfree_skb(skb);
240                                                   249 
241         return NULL;                              250         return NULL;
242 }                                                 251 }
243                                                   252 
244 static int nci_spi_check_crc(struct sk_buff *s    253 static int nci_spi_check_crc(struct sk_buff *skb)
245 {                                                 254 {
246         u16 crc_data = (skb->data[skb->len - 2    255         u16 crc_data = (skb->data[skb->len - 2] << 8) |
247                         skb->data[skb->len - 1    256                         skb->data[skb->len - 1];
248         int ret;                                  257         int ret;
249                                                   258 
250         ret = (crc_ccitt(CRC_INIT, skb->data,     259         ret = (crc_ccitt(CRC_INIT, skb->data, skb->len - NCI_SPI_CRC_LEN)
251                         == crc_data);             260                         == crc_data);
252                                                   261 
253         skb_trim(skb, skb->len - NCI_SPI_CRC_L    262         skb_trim(skb, skb->len - NCI_SPI_CRC_LEN);
254                                                   263 
255         return ret;                               264         return ret;
256 }                                                 265 }
257                                                   266 
258 static u8 nci_spi_get_ack(struct sk_buff *skb)    267 static u8 nci_spi_get_ack(struct sk_buff *skb)
259 {                                                 268 {
260         u8 ret;                                   269         u8 ret;
261                                                   270 
262         ret = skb->data[0] >> NCI_SPI_ACK_SHIF    271         ret = skb->data[0] >> NCI_SPI_ACK_SHIFT;
263                                                   272 
264         /* Remove NFCC part of the header: ACK    273         /* Remove NFCC part of the header: ACK, NACK and MSB payload len */
265         skb_pull(skb, 2);                         274         skb_pull(skb, 2);
266                                                   275 
267         return ret;                               276         return ret;
268 }                                                 277 }
269                                                   278 
270 /**                                               279 /**
271  * nci_spi_read - read frame from NCI SPI driv    280  * nci_spi_read - read frame from NCI SPI drivers
272  *                                                281  *
273  * @nspi: The nci spi                             282  * @nspi: The nci spi
274  * Context: can sleep                             283  * Context: can sleep
275  *                                                284  *
276  * This call may only be used from a context t    285  * This call may only be used from a context that may sleep.  The sleep
277  * is non-interruptible, and has no timeout.      286  * is non-interruptible, and has no timeout.
278  *                                                287  *
279  * It returns an allocated skb containing the     288  * It returns an allocated skb containing the frame on success, or NULL.
280  */                                               289  */
281 struct sk_buff *nci_spi_read(struct nci_spi *n    290 struct sk_buff *nci_spi_read(struct nci_spi *nspi)
282 {                                                 291 {
283         struct sk_buff *skb;                      292         struct sk_buff *skb;
284                                                   293 
285         /* Retrieve frame from SPI */             294         /* Retrieve frame from SPI */
286         skb = __nci_spi_read(nspi);               295         skb = __nci_spi_read(nspi);
287         if (!skb)                                 296         if (!skb)
288                 goto done;                        297                 goto done;
289                                                   298 
290         if (nspi->acknowledge_mode == NCI_SPI_    299         if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) {
291                 if (!nci_spi_check_crc(skb)) {    300                 if (!nci_spi_check_crc(skb)) {
292                         send_acknowledge(nspi,    301                         send_acknowledge(nspi, ACKNOWLEDGE_NACK);
293                         goto done;                302                         goto done;
294                 }                                 303                 }
295                                                   304 
296                 /* In case of acknowledged mod    305                 /* In case of acknowledged mode: if ACK or NACK received,
297                  * unblock completion of lates    306                  * unblock completion of latest frame sent.
298                  */                               307                  */
299                 nspi->req_result = nci_spi_get    308                 nspi->req_result = nci_spi_get_ack(skb);
300                 if (nspi->req_result)             309                 if (nspi->req_result)
301                         complete(&nspi->req_co    310                         complete(&nspi->req_completion);
302         }                                         311         }
303                                                   312 
304         /* If there is no payload (ACK/NACK on    313         /* If there is no payload (ACK/NACK only frame),
305          * free the socket buffer                 314          * free the socket buffer
306          */                                       315          */
307         if (!skb->len) {                          316         if (!skb->len) {
308                 kfree_skb(skb);                   317                 kfree_skb(skb);
309                 skb = NULL;                       318                 skb = NULL;
310                 goto done;                        319                 goto done;
311         }                                         320         }
312                                                   321 
313         if (nspi->acknowledge_mode == NCI_SPI_    322         if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED)
314                 send_acknowledge(nspi, ACKNOWL    323                 send_acknowledge(nspi, ACKNOWLEDGE_ACK);
315                                                   324 
316 done:                                             325 done:
317                                                   326 
318         return skb;                               327         return skb;
319 }                                                 328 }
320 EXPORT_SYMBOL_GPL(nci_spi_read);                  329 EXPORT_SYMBOL_GPL(nci_spi_read);
321                                                   330 
322 MODULE_DESCRIPTION("NFC Controller Interface ( << 
323 MODULE_LICENSE("GPL");                            331 MODULE_LICENSE("GPL");
324                                                   332 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php