Lines Matching refs:nspi

30 static int __nci_spi_send(struct nci_spi *nspi, const struct sk_buff *skb,  in __nci_spi_send()  argument
47 t.delay.value = nspi->xfer_udelay; in __nci_spi_send()
49 t.speed_hz = nspi->xfer_speed_hz; in __nci_spi_send()
54 return spi_sync(nspi->spi, &m); in __nci_spi_send()
57 int nci_spi_send(struct nci_spi *nspi, in nci_spi_send() argument
69 hdr[1] = nspi->acknowledge_mode; in nci_spi_send()
73 if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) { in nci_spi_send()
83 ret = __nci_spi_send(nspi, NULL, 1); in nci_spi_send()
95 ret = __nci_spi_send(nspi, skb, 0); in nci_spi_send()
96 if (ret != 0 || nspi->acknowledge_mode == NCI_SPI_CRC_DISABLED) in nci_spi_send()
99 reinit_completion(&nspi->req_completion); in nci_spi_send()
101 &nspi->req_completion, in nci_spi_send()
104 if (completion_rc <= 0 || nspi->req_result == ACKNOWLEDGE_NACK) in nci_spi_send()
128 struct nci_spi *nspi; in nci_spi_allocate_spi() local
130 nspi = devm_kzalloc(&spi->dev, sizeof(struct nci_spi), GFP_KERNEL); in nci_spi_allocate_spi()
131 if (!nspi) in nci_spi_allocate_spi()
134 nspi->acknowledge_mode = acknowledge_mode; in nci_spi_allocate_spi()
135 nspi->xfer_udelay = delay; in nci_spi_allocate_spi()
137 nspi->xfer_speed_hz = 0; in nci_spi_allocate_spi()
138 nspi->spi = spi; in nci_spi_allocate_spi()
139 nspi->ndev = ndev; in nci_spi_allocate_spi()
140 init_completion(&nspi->req_completion); in nci_spi_allocate_spi()
142 return nspi; in nci_spi_allocate_spi()
146 static int send_acknowledge(struct nci_spi *nspi, u8 acknowledge) in send_acknowledge() argument
153 skb = nci_skb_alloc(nspi->ndev, 0, GFP_KERNEL); in send_acknowledge()
168 ret = __nci_spi_send(nspi, skb, 0); in send_acknowledge()
175 static struct sk_buff *__nci_spi_read(struct nci_spi *nspi) in __nci_spi_read() argument
188 req[1] = nspi->acknowledge_mode; in __nci_spi_read()
192 tx.speed_hz = nspi->xfer_speed_hz; in __nci_spi_read()
199 rx.speed_hz = nspi->xfer_speed_hz; in __nci_spi_read()
202 ret = spi_sync(nspi->spi, &m); in __nci_spi_read()
206 if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) in __nci_spi_read()
212 skb = nci_skb_alloc(nspi->ndev, rx_len, GFP_KERNEL); in __nci_spi_read()
222 rx.delay.value = nspi->xfer_udelay; in __nci_spi_read()
224 rx.speed_hz = nspi->xfer_speed_hz; in __nci_spi_read()
227 ret = spi_sync(nspi->spi, &m); in __nci_spi_read()
231 if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) { in __nci_spi_read()
281 struct sk_buff *nci_spi_read(struct nci_spi *nspi) in nci_spi_read() argument
286 skb = __nci_spi_read(nspi); in nci_spi_read()
290 if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) { in nci_spi_read()
292 send_acknowledge(nspi, ACKNOWLEDGE_NACK); in nci_spi_read()
299 nspi->req_result = nci_spi_get_ack(skb); in nci_spi_read()
300 if (nspi->req_result) in nci_spi_read()
301 complete(&nspi->req_completion); in nci_spi_read()
313 if (nspi->acknowledge_mode == NCI_SPI_CRC_ENABLED) in nci_spi_read()
314 send_acknowledge(nspi, ACKNOWLEDGE_ACK); in nci_spi_read()