aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2011-03-17 01:10:52 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-03-17 02:29:08 -0400
commit9a6e180af78247e3a7680460240bb450c39d3a5b (patch)
tree5ab415c2795f9974b515c94220986f055dd7fadc /drivers/input
parentc8b6846a7559e64d7ac4ba1ccdba05f3ee2e34e8 (diff)
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: Aaro Koskinen <aaro.koskinen@nokia.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/tsc2005.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/drivers/input/touchscreen/tsc2005.c b/drivers/input/touchscreen/tsc2005.c
index f457cb95b95b..289057e1b9a2 100644
--- a/drivers/input/touchscreen/tsc2005.c
+++ b/drivers/input/touchscreen/tsc2005.c
@@ -148,16 +148,13 @@ struct tsc2005 {
148 148
149static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd) 149static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd)
150{ 150{
151 u8 tx; 151 u8 tx = TSC2005_CMD | TSC2005_CMD_12BIT | cmd;
152 struct spi_transfer xfer = {
153 .tx_buf = &tx,
154 .len = 1,
155 .bits_per_word = 8,
156 };
152 struct spi_message msg; 157 struct spi_message msg;
153 struct spi_transfer xfer = { 0 };
154
155 tx = TSC2005_CMD | TSC2005_CMD_12BIT | cmd;
156
157 xfer.tx_buf = &tx;
158 xfer.rx_buf = NULL;
159 xfer.len = 1;
160 xfer.bits_per_word = 8;
161 158
162 spi_message_init(&msg); 159 spi_message_init(&msg);
163 spi_message_add_tail(&xfer, &msg); 160 spi_message_add_tail(&xfer, &msg);
@@ -166,17 +163,13 @@ static void tsc2005_cmd(struct tsc2005 *ts, u8 cmd)
166 163
167static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value) 164static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value)
168{ 165{
169 u32 tx; 166 u32 tx = ((reg | TSC2005_REG_PND0) << 16) | value;
167 struct spi_transfer xfer = {
168 .tx_buf = &tx,
169 .len = 4,
170 .bits_per_word = 24,
171 };
170 struct spi_message msg; 172 struct spi_message msg;
171 struct spi_transfer xfer = { 0 };
172
173 tx = (reg | TSC2005_REG_PND0) << 16;
174 tx |= value;
175
176 xfer.tx_buf = &tx;
177 xfer.rx_buf = NULL;
178 xfer.len = 4;
179 xfer.bits_per_word = 24;
180 173
181 spi_message_init(&msg); 174 spi_message_init(&msg);
182 spi_message_add_tail(&xfer, &msg); 175 spi_message_add_tail(&xfer, &msg);
@@ -185,6 +178,8 @@ static void tsc2005_write(struct tsc2005 *ts, u8 reg, u16 value)
185 178
186static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last) 179static void tsc2005_setup_read(struct tsc2005_spi_rd *rd, u8 reg, bool last)
187{ 180{
181 memset(rd, 0, sizeof(*rd));
182
188 rd->spi_tx = (reg | TSC2005_REG_READ) << 16; 183 rd->spi_tx = (reg | TSC2005_REG_READ) << 16;
189 rd->spi_xfer.tx_buf = &rd->spi_tx; 184 rd->spi_xfer.tx_buf = &rd->spi_tx;
190 rd->spi_xfer.rx_buf = &rd->spi_rx; 185 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 190
196static void tsc2005_read(struct tsc2005 *ts, u8 reg, u16 *value) 191static void tsc2005_read(struct tsc2005 *ts, u8 reg, u16 *value)
197{ 192{
193 struct tsc2005_spi_rd spi_rd;
198 struct spi_message msg; 194 struct spi_message msg;
199 struct tsc2005_spi_rd spi_rd = { { 0 }, 0, 0 };
200 195
201 tsc2005_setup_read(&spi_rd, reg, true); 196 tsc2005_setup_read(&spi_rd, reg, true);
202 197
203 spi_message_init(&msg); 198 spi_message_init(&msg);
204 spi_message_add_tail(&spi_rd.spi_xfer, &msg); 199 spi_message_add_tail(&spi_rd.spi_xfer, &msg);
205 spi_sync(ts->spi, &msg); 200 spi_sync(ts->spi, &msg);
201
206 *value = spi_rd.spi_rx; 202 *value = spi_rd.spi_rx;
207} 203}
208 204