Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269492
b: refs/heads/master
c: cb31f89
h: refs/heads/master
v: v3
  • Loading branch information
Dmitry Torokhov committed Oct 7, 2011
1 parent 42ebd01 commit 044dc8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 626af8611211c55595cd316103abd2419cd4d861
refs/heads/master: cb31f898cc0dac9585f7665945bb50fc442c2109
20 changes: 10 additions & 10 deletions trunk/drivers/input/misc/mma8450.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,20 @@ 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",
MMA8450_OUT_X_LSB, 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;
}

Expand All @@ -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)
Expand All @@ -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);
Expand Down

0 comments on commit 044dc8d

Please sign in to comment.