提交 a4ada6ca 编写于 作者: E Eric Lapuyade 提交者: Samuel Ortiz

NFC: NCI: zero struct spi_transfer variables before usage

Using ARM compiler, and without zero-ing spi_transfer, spi-s3c64xx
driver would issue abnormal errors due to bpw field value being set to
unexpected value. This structure MUST be set to all zeros except for
those field specifically used.
Signed-off-by: NEric Lapuyade <eric.lapuyade@intel.com>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 5ce3f32b
...@@ -44,6 +44,7 @@ static int __nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb) ...@@ -44,6 +44,7 @@ static int __nci_spi_send(struct nci_spi *nspi, struct sk_buff *skb)
struct spi_message m; struct spi_message m;
struct spi_transfer t; struct spi_transfer t;
memset(&t, 0, sizeof(struct spi_transfer));
t.tx_buf = skb->data; t.tx_buf = skb->data;
t.len = skb->len; t.len = skb->len;
t.cs_change = 0; t.cs_change = 0;
...@@ -173,16 +174,21 @@ static struct sk_buff *__nci_spi_recv_frame(struct nci_spi *nspi) ...@@ -173,16 +174,21 @@ static struct sk_buff *__nci_spi_recv_frame(struct nci_spi *nspi)
int ret; int ret;
spi_message_init(&m); spi_message_init(&m);
memset(&tx, 0, sizeof(struct spi_transfer));
req[0] = NCI_SPI_DIRECT_READ; req[0] = NCI_SPI_DIRECT_READ;
req[1] = nspi->acknowledge_mode; req[1] = nspi->acknowledge_mode;
tx.tx_buf = req; tx.tx_buf = req;
tx.len = 2; tx.len = 2;
tx.cs_change = 0; tx.cs_change = 0;
spi_message_add_tail(&tx, &m); spi_message_add_tail(&tx, &m);
memset(&rx, 0, sizeof(struct spi_transfer));
rx.rx_buf = resp_hdr; rx.rx_buf = resp_hdr;
rx.len = 2; rx.len = 2;
rx.cs_change = 1; rx.cs_change = 1;
spi_message_add_tail(&rx, &m); spi_message_add_tail(&rx, &m);
ret = spi_sync(nspi->spi, &m); ret = spi_sync(nspi->spi, &m);
if (ret) if (ret)
...@@ -199,11 +205,14 @@ static struct sk_buff *__nci_spi_recv_frame(struct nci_spi *nspi) ...@@ -199,11 +205,14 @@ static struct sk_buff *__nci_spi_recv_frame(struct nci_spi *nspi)
return NULL; return NULL;
spi_message_init(&m); spi_message_init(&m);
memset(&rx, 0, sizeof(struct spi_transfer));
rx.rx_buf = skb_put(skb, rx_len); rx.rx_buf = skb_put(skb, rx_len);
rx.len = rx_len; rx.len = rx_len;
rx.cs_change = 0; rx.cs_change = 0;
rx.delay_usecs = nspi->xfer_udelay; rx.delay_usecs = nspi->xfer_udelay;
spi_message_add_tail(&rx, &m); spi_message_add_tail(&rx, &m);
ret = spi_sync(nspi->spi, &m); ret = spi_sync(nspi->spi, &m);
if (ret) if (ret)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册