From: Oder Chiou <oder_chiou@realtek.com>
To: broonie@kernel.org, lgirdwood@gmail.com
Cc: Oder Chiou <oder_chiou@realtek.com>,
jack.yu@realtek.com, alsa-devel@alsa-project.org,
hychao@google.com, albertchen@realtek.com, shumingf@realtek.com,
bardliao@realtek.com, flove@realtek.com
Subject: [PATCH] ASoC: rt5514: Use the local variable to get the data from SPI device
Date: Fri, 21 Jul 2017 16:00:47 +0800 [thread overview]
Message-ID: <1500624047-21492-1-git-send-email-oder_chiou@realtek.com> (raw)
The patch uses the local variable to get the data from SPI device to
prevent to get all zero data.
Signed-off-by: Oder Chiou <oder_chiou@realtek.com>
---
sound/soc/codecs/rt5514-spi.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 950d1ff..e693204 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -289,7 +289,7 @@ int rt5514_spi_burst_read(unsigned int addr, u8 *rxbuf, size_t len)
{
u8 spi_cmd = RT5514_SPI_CMD_BURST_READ;
int status;
- u8 write_buf[8];
+ u8 write_buf[8], read_buf[RT5514_SPI_BUF_LEN];
unsigned int i, end, offset = 0;
struct spi_message message;
@@ -319,7 +319,7 @@ int rt5514_spi_burst_read(unsigned int addr, u8 *rxbuf, size_t len)
spi_message_add_tail(&x[1], &message);
x[2].len = end;
- x[2].rx_buf = rxbuf + offset;
+ x[2].rx_buf = read_buf;
spi_message_add_tail(&x[2], &message);
status = spi_sync(rt5514_spi, &message);
@@ -327,6 +327,8 @@ int rt5514_spi_burst_read(unsigned int addr, u8 *rxbuf, size_t len)
if (status)
return false;
+ memcpy(rxbuf + offset, read_buf, end);
+
offset += RT5514_SPI_BUF_LEN;
}
@@ -365,14 +367,9 @@ int rt5514_spi_burst_read(unsigned int addr, u8 *rxbuf, size_t len)
int rt5514_spi_burst_write(u32 addr, const u8 *txbuf, size_t len)
{
u8 spi_cmd = RT5514_SPI_CMD_BURST_WRITE;
- u8 *write_buf;
+ u8 write_buf[RT5514_SPI_BUF_LEN + 6];
unsigned int i, end, offset = 0;
- write_buf = kmalloc(RT5514_SPI_BUF_LEN + 6, GFP_KERNEL);
-
- if (write_buf == NULL)
- return -ENOMEM;
-
while (offset < len) {
if (offset + RT5514_SPI_BUF_LEN <= len)
end = RT5514_SPI_BUF_LEN;
@@ -403,8 +400,6 @@ int rt5514_spi_burst_write(u32 addr, const u8 *txbuf, size_t len)
offset += RT5514_SPI_BUF_LEN;
}
- kfree(write_buf);
-
return 0;
}
EXPORT_SYMBOL_GPL(rt5514_spi_burst_write);
--
2.7.4
next reply other threads:[~2017-07-21 8:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-21 8:00 Oder Chiou [this message]
2017-07-21 10:51 ` [PATCH] ASoC: rt5514: Use the local variable to get the data from SPI device Mark Brown
[not found] ` <7EB0DE829A537248AF2ED30C97D12694023B5FB9@RTITMBSV02.realtek.com.tw>
2017-07-25 14:47 ` Hsin-yu Chao
2017-07-28 13:59 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1500624047-21492-1-git-send-email-oder_chiou@realtek.com \
--to=oder_chiou@realtek.com \
--cc=albertchen@realtek.com \
--cc=alsa-devel@alsa-project.org \
--cc=bardliao@realtek.com \
--cc=broonie@kernel.org \
--cc=flove@realtek.com \
--cc=hychao@google.com \
--cc=jack.yu@realtek.com \
--cc=lgirdwood@gmail.com \
--cc=shumingf@realtek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).