Commit cb31f898 authored by Dmitry Torokhov's avatar Dmitry Torokhov

Input: mma8450 - silence some 'uninitialized variable' warnings

Sometimes GCC is not smart enough to recognize that x, y and z are
always used properly initialized in mma8450_poll(). Let's rearrange
the code a bit to help GCC.
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent 626af861
...@@ -88,13 +88,13 @@ static int mma8450_write(struct mma8450 *m, unsigned off, u8 v) ...@@ -88,13 +88,13 @@ static int mma8450_write(struct mma8450 *m, unsigned off, u8 v)
return 0; return 0;
} }
static int mma8450_read_xyz(struct mma8450 *m, int *x, int *y, int *z) static int mma8450_read_block(struct mma8450 *m, unsigned off,
u8 *buf, size_t size)
{ {
struct i2c_client *c = m->client; struct i2c_client *c = m->client;
u8 buff[6];
int err; int err;
err = i2c_smbus_read_i2c_block_data(c, MMA8450_OUT_X_LSB, 6, buff); err = i2c_smbus_read_i2c_block_data(c, off, size, buf);
if (err < 0) { if (err < 0) {
dev_err(&c->dev, dev_err(&c->dev,
"failed to read block data at 0x%02x, error %d\n", "failed to read block data at 0x%02x, error %d\n",
...@@ -102,10 +102,6 @@ static int mma8450_read_xyz(struct mma8450 *m, int *x, int *y, int *z) ...@@ -102,10 +102,6 @@ static int mma8450_read_xyz(struct mma8450 *m, int *x, int *y, int *z)
return err; return err;
} }
*x = ((buff[1] << 4) & 0xff0) | (buff[0] & 0xf);
*y = ((buff[3] << 4) & 0xff0) | (buff[2] & 0xf);
*z = ((buff[5] << 4) & 0xff0) | (buff[4] & 0xf);
return 0; return 0;
} }
...@@ -114,7 +110,7 @@ static void mma8450_poll(struct input_polled_dev *dev) ...@@ -114,7 +110,7 @@ static void mma8450_poll(struct input_polled_dev *dev)
struct mma8450 *m = dev->private; struct mma8450 *m = dev->private;
int x, y, z; int x, y, z;
int ret; int ret;
int err; u8 buf[6];
ret = mma8450_read(m, MMA8450_STATUS); ret = mma8450_read(m, MMA8450_STATUS);
if (ret < 0) if (ret < 0)
...@@ -123,10 +119,14 @@ static void mma8450_poll(struct input_polled_dev *dev) ...@@ -123,10 +119,14 @@ static void mma8450_poll(struct input_polled_dev *dev)
if (!(ret & MMA8450_STATUS_ZXYDR)) if (!(ret & MMA8450_STATUS_ZXYDR))
return; return;
err = mma8450_read_xyz(m, &x, &y, &z); ret = mma8450_read_block(m, MMA8450_OUT_X_LSB, buf, sizeof(buf));
if (err) if (ret < 0)
return; return;
x = ((buf[1] << 4) & 0xff0) | (buf[0] & 0xf);
y = ((buf[3] << 4) & 0xff0) | (buf[2] & 0xf);
z = ((buf[5] << 4) & 0xff0) | (buf[4] & 0xf);
input_report_abs(dev->input, ABS_X, x); input_report_abs(dev->input, ABS_X, x);
input_report_abs(dev->input, ABS_Y, y); input_report_abs(dev->input, ABS_Y, y);
input_report_abs(dev->input, ABS_Z, z); input_report_abs(dev->input, ABS_Z, z);
......
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