diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-10-06 18:26:50 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-10-06 22:41:57 -0400 |
commit | cb31f898cc0dac9585f7665945bb50fc442c2109 (patch) | |
tree | 953f464b4d9b2fa6546435645e8d1bcb70dbe42d /drivers/input/misc | |
parent | 626af8611211c55595cd316103abd2419cd4d861 (diff) |
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>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r-- | drivers/input/misc/mma8450.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/input/misc/mma8450.c b/drivers/input/misc/mma8450.c index 0794778295fc..4d60080bb5d5 100644 --- a/drivers/input/misc/mma8450.c +++ b/drivers/input/misc/mma8450.c | |||
@@ -88,13 +88,13 @@ static int mma8450_write(struct mma8450 *m, unsigned off, u8 v) | |||
88 | return 0; | 88 | return 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | static int mma8450_read_xyz(struct mma8450 *m, int *x, int *y, int *z) | 91 | static int mma8450_read_block(struct mma8450 *m, unsigned off, |
92 | u8 *buf, size_t size) | ||
92 | { | 93 | { |
93 | struct i2c_client *c = m->client; | 94 | struct i2c_client *c = m->client; |
94 | u8 buff[6]; | ||
95 | int err; | 95 | int err; |
96 | 96 | ||
97 | err = i2c_smbus_read_i2c_block_data(c, MMA8450_OUT_X_LSB, 6, buff); | 97 | err = i2c_smbus_read_i2c_block_data(c, off, size, buf); |
98 | if (err < 0) { | 98 | if (err < 0) { |
99 | dev_err(&c->dev, | 99 | dev_err(&c->dev, |
100 | "failed to read block data at 0x%02x, error %d\n", | 100 | "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 | return err; | 102 | return err; |
103 | } | 103 | } |
104 | 104 | ||
105 | *x = ((buff[1] << 4) & 0xff0) | (buff[0] & 0xf); | ||
106 | *y = ((buff[3] << 4) & 0xff0) | (buff[2] & 0xf); | ||
107 | *z = ((buff[5] << 4) & 0xff0) | (buff[4] & 0xf); | ||
108 | |||
109 | return 0; | 105 | return 0; |
110 | } | 106 | } |
111 | 107 | ||
@@ -114,7 +110,7 @@ static void mma8450_poll(struct input_polled_dev *dev) | |||
114 | struct mma8450 *m = dev->private; | 110 | struct mma8450 *m = dev->private; |
115 | int x, y, z; | 111 | int x, y, z; |
116 | int ret; | 112 | int ret; |
117 | int err; | 113 | u8 buf[6]; |
118 | 114 | ||
119 | ret = mma8450_read(m, MMA8450_STATUS); | 115 | ret = mma8450_read(m, MMA8450_STATUS); |
120 | if (ret < 0) | 116 | if (ret < 0) |
@@ -123,10 +119,14 @@ static void mma8450_poll(struct input_polled_dev *dev) | |||
123 | if (!(ret & MMA8450_STATUS_ZXYDR)) | 119 | if (!(ret & MMA8450_STATUS_ZXYDR)) |
124 | return; | 120 | return; |
125 | 121 | ||
126 | err = mma8450_read_xyz(m, &x, &y, &z); | 122 | ret = mma8450_read_block(m, MMA8450_OUT_X_LSB, buf, sizeof(buf)); |
127 | if (err) | 123 | if (ret < 0) |
128 | return; | 124 | return; |
129 | 125 | ||
126 | x = ((buf[1] << 4) & 0xff0) | (buf[0] & 0xf); | ||
127 | y = ((buf[3] << 4) & 0xff0) | (buf[2] & 0xf); | ||
128 | z = ((buf[5] << 4) & 0xff0) | (buf[4] & 0xf); | ||
129 | |||
130 | input_report_abs(dev->input, ABS_X, x); | 130 | input_report_abs(dev->input, ABS_X, x); |
131 | input_report_abs(dev->input, ABS_Y, y); | 131 | input_report_abs(dev->input, ABS_Y, y); |
132 | input_report_abs(dev->input, ABS_Z, z); | 132 | input_report_abs(dev->input, ABS_Z, z); |