Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 268321
b: refs/heads/master
c: 25d7315
h: refs/heads/master
i:
  268319: f22de61
v: v3
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Sep 9, 2011
1 parent 3e292d1 commit 764c6a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 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: 66e60413db488e4830286220152ae63d31c32a6a
refs/heads/master: 25d7315a19bae4c880ca25b75fe8c632b79a21b7
23 changes: 14 additions & 9 deletions trunk/drivers/staging/iio/light/isl29018.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

#define ISL29018_REG_ADD_DATA_LSB 0x02
#define ISL29018_REG_ADD_DATA_MSB 0x03
#define ISL29018_MAX_REGS ISL29018_REG_ADD_DATA_MSB
#define ISL29018_MAX_REGS (ISL29018_REG_ADD_DATA_MSB+1)

#define ISL29018_REG_TEST 0x08
#define ISL29018_TEST_SHIFT 0
Expand All @@ -70,22 +70,27 @@ struct isl29018_chip {
static int isl29018_write_data(struct i2c_client *client, u8 reg,
u8 val, u8 mask, u8 shift)
{
u8 regval;
int ret = 0;
u8 regval = val;
int ret;
struct isl29018_chip *chip = iio_priv(i2c_get_clientdata(client));

regval = chip->reg_cache[reg];
regval &= ~mask;
regval |= val << shift;
/* don't cache or mask REG_TEST */
if (reg < ISL29018_MAX_REGS) {
regval = chip->reg_cache[reg];
regval &= ~mask;
regval |= val << shift;
}

ret = i2c_smbus_write_byte_data(client, reg, regval);
if (ret) {
dev_err(&client->dev, "Write to device fails status %x\n", ret);
return ret;
} else {
/* don't update cache on err */
if (reg < ISL29018_MAX_REGS)
chip->reg_cache[reg] = regval;
}
chip->reg_cache[reg] = regval;

return 0;
return ret;
}

static int isl29018_set_range(struct i2c_client *client, unsigned long range,
Expand Down

0 comments on commit 764c6a7

Please sign in to comment.