Commit 9a6e180a authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: tsc2005 - do not use 0 in place of NULL

Sparse in unhappy when people use 0 instead of NULL for pointers so
let's rework the way we initialize spi_transfer structure in
tsc2005_cmd() and tsc2005_write().
Tested-by: default avatarAaro Koskinen <aaro.koskinen@nokia.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent c8b6846a
...@@ -148,16 +148,13 @@ struct tsc2005 { ...@@ -148,16 +148,13 @@ struct tsc2005 {
static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd) static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd)
{ {
u8 tx; u8 tx = TSC2005_CMD | TSC2005_CMD_12BIT | cmd;
struct spi_transfer xfer = {
.tx_buf = &tx,
.len = 1,
.bits_per_word = 8,
};
struct spi_message msg; struct spi_message msg;
struct spi_transfer xfer = { 0 };
tx = TSC2005_CMD | TSC2005_CMD_12BIT | cmd;
xfer.tx_buf = &tx;
xfer.rx_buf = NULL;
xfer.len = 1;
xfer.bits_per_word = 8;
spi_message_init(&msg); spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg); spi_message_add_tail(&xfer, &msg);
...@@ -166,17 +163,13 @@ static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd) ...@@ -166,17 +163,13 @@ static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd)
static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value) static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value)
{ {
u32 tx; u32 tx = ((reg | TSC2005_REG_PND0) << 16) | value;
struct spi_transfer xfer = {
.tx_buf = &tx,
.len = 4,
.bits_per_word = 24,
};
struct spi_message msg; struct spi_message msg;
struct spi_transfer xfer = { 0 };
tx = (reg | TSC2005_REG_PND0) << 16;
tx |= value;
xfer.tx_buf = &tx;
xfer.rx_buf = NULL;
xfer.len = 4;
xfer.bits_per_word = 24;
spi_message_init(&msg); spi_message_init(&msg);
spi_message_add_tail(&xfer, &msg); spi_message_add_tail(&xfer, &msg);
...@@ -185,6 +178,8 @@ static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value) ...@@ -185,6 +178,8 @@ static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value)
static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last) static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last)
{ {
memset(rd, 0, sizeof(*rd));
rd->spi_tx = (reg | TSC2005_REG_READ) << 16; rd->spi_tx = (reg | TSC2005_REG_READ) << 16;
rd->spi_xfer.tx_buf = &rd->spi_tx; rd->spi_xfer.tx_buf = &rd->spi_tx;
rd->spi_xfer.rx_buf = &rd->spi_rx; rd->spi_xfer.rx_buf = &rd->spi_rx;
...@@ -195,14 +190,15 @@ static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last) ...@@ -195,14 +190,15 @@ static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last)
static void tsc2005_read(struct tsc2005 *ts, u8 reg, u16 *value) static void tsc2005_read(struct tsc2005 *ts, u8 reg, u16 *value)
{ {
struct tsc2005_spi_rd spi_rd;
struct spi_message msg; struct spi_message msg;
struct tsc2005_spi_rd spi_rd = { { 0 }, 0, 0 };
tsc2005_setup_read(&spi_rd, reg, true); tsc2005_setup_read(&spi_rd, reg, true);
spi_message_init(&msg); spi_message_init(&msg);
spi_message_add_tail(&spi_rd.spi_xfer, &msg); spi_message_add_tail(&spi_rd.spi_xfer, &msg);
spi_sync(ts->spi, &msg); spi_sync(ts->spi, &msg);
*value = spi_rd.spi_rx; *value = spi_rd.spi_rx;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment