summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Peyer <David.Peyer@motorola.com>2014-06-05 21:04:27 -0500
committerDavid Peyer <David.Peyer@motorola.com>2014-06-06 13:16:37 -0500
commiteba38cd199268a657fa2928e29626704cc9cc8c2 (patch)
treee8fa950cb341d3df2c381f0d1875c8b6c5de6e62
parent0027b25543b6fa6975e7cb7c3d5b9a5795f630f1 (diff)
downloadolio-linux-3.10-eba38cd199268a657fa2928e29626704cc9cc8c2.tar.xz
olio-linux-3.10-eba38cd199268a657fa2928e29626704cc9cc8c2.zip
IKXCLOCK-1472 - PMIC SPI driver does not initialize the SPI transfer array resulting in random delays
The TPS65912 spi driver was updated to initialize the spi_transfer structure in the read and write cases. In addition it was updated to better handle other error cases. This will remove the random delays as well as random transfer speeds. Change-Id: I3a8850fb0cc1316ec034df5045c7a79c5a8a8db5
-rw-r--r--drivers/mfd/tps65912-spi.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/drivers/mfd/tps65912-spi.c b/drivers/mfd/tps65912-spi.c
index 922cc482ff4..8aef1f0dad0 100644
--- a/drivers/mfd/tps65912-spi.c
+++ b/drivers/mfd/tps65912-spi.c
@@ -27,27 +27,26 @@ static int tps65912_spi_write(struct tps65912 *tps65912, u8 addr,
int bytes, void *src)
{
struct spi_device *spi = tps65912->control_data;
- u8 *data = (u8 *) src;
- int ret;
/* bit 23 is the read/write bit */
- unsigned long spi_data = 1 << 23 | addr << 15 | *data;
+ u32 tx = 1 << 23 | addr << 15 | *(u8 *)src;
struct spi_transfer xfer;
struct spi_message msg;
- u32 tx_buf, rx_buf;
- tx_buf = spi_data;
- rx_buf = 0;
+ if ((spi == NULL) || (bytes == 0))
+ return -ENODATA;
- xfer.tx_buf = &tx_buf;
- xfer.rx_buf = NULL;
- xfer.len = sizeof(unsigned long);
- xfer.bits_per_word = 24;
+ if (bytes > 1)
+ dev_err(tps65912->dev, "too many bytes to write %d\n", bytes);
+ memset(&xfer, 0, sizeof(xfer));
+ /* Do not setup the bits per transfer or the speed, as this causes the
+ driver to re-initialize, which wastes time. */
+ xfer.tx_buf = &tx;
+ xfer.len = sizeof(tx);
+ xfer.bits_per_word = 24;
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
-
- ret = spi_sync(spi, &msg);
- return ret;
+ return spi_sync(spi, &msg);
}
static int tps65912_spi_read(struct tps65912 *tps65912, u8 addr,
@@ -55,30 +54,30 @@ static int tps65912_spi_read(struct tps65912 *tps65912, u8 addr,
{
struct spi_device *spi = tps65912->control_data;
/* bit 23 is the read/write bit */
- unsigned long spi_data = 0 << 23 | addr << 15;
+ u32 tx = 0 << 23 | addr << 15;
struct spi_transfer xfer;
struct spi_message msg;
+ u32 rx;
int ret;
- u8 *data = (u8 *) dest;
- u32 tx_buf, rx_buf;
- tx_buf = spi_data;
- rx_buf = 0;
+ if ((spi == NULL) || (bytes == 0))
+ return -ENODATA;
- xfer.tx_buf = &tx_buf;
- xfer.rx_buf = &rx_buf;
- xfer.len = sizeof(unsigned long);
- xfer.bits_per_word = 24;
+ if (bytes > 1)
+ dev_err(tps65912->dev, "too many bytes to read %d\n", bytes);
+ memset(&xfer, 0, sizeof(xfer));
+ /* Do not setup the bits per transfer or the speed, as this causes the
+ driver to re-initialize, which wastes time. */
+ xfer.tx_buf = &tx;
+ xfer.rx_buf = &rx;
+ xfer.len = sizeof(tx);
+ xfer.bits_per_word = 24;
spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg);
-
- if (spi == NULL)
- return 0;
-
ret = spi_sync(spi, &msg);
- if (ret == 0)
- *data = (u8) (rx_buf & 0xFF);
+ if (!ret)
+ *(u8 *)dest = (u8)rx & 0xff;
return ret;
}