mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-19 07:27:50 +00:00
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: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
626af86112
commit
cb31f898cc
@ -88,13 +88,13 @@ static int mma8450_write(struct mma8450 *m, unsigned off, u8 v)
|
||||
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;
|
||||
u8 buff[6];
|
||||
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) {
|
||||
dev_err(&c->dev,
|
||||
"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)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -114,7 +110,7 @@ static void mma8450_poll(struct input_polled_dev *dev)
|
||||
struct mma8450 *m = dev->private;
|
||||
int x, y, z;
|
||||
int ret;
|
||||
int err;
|
||||
u8 buf[6];
|
||||
|
||||
ret = mma8450_read(m, MMA8450_STATUS);
|
||||
if (ret < 0)
|
||||
@ -123,10 +119,14 @@ static void mma8450_poll(struct input_polled_dev *dev)
|
||||
if (!(ret & MMA8450_STATUS_ZXYDR))
|
||||
return;
|
||||
|
||||
err = mma8450_read_xyz(m, &x, &y, &z);
|
||||
if (err)
|
||||
ret = mma8450_read_block(m, MMA8450_OUT_X_LSB, buf, sizeof(buf));
|
||||
if (ret < 0)
|
||||
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_Y, y);
|
||||
input_report_abs(dev->input, ABS_Z, z);
|
||||
|
Loading…
Reference in New Issue
Block a user