Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 318441
b: refs/heads/master
c: 96b7064
h: refs/heads/master
i:
  318439: db6be59
v: v3
  • Loading branch information
Andreas Schallenberg authored and Grant Likely committed May 26, 2012
1 parent 2204b03 commit 76155b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 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: 0df2c999f748c9528f6629f45baaa86118d60cd1
refs/heads/master: 96b70641b937e99c1579cb6ebbcdb7b0af98cdd0
28 changes: 16 additions & 12 deletions trunk/drivers/gpio/gpio-pca953x.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,11 @@ static int pca953x_write_reg(struct pca953x_chip *chip, int reg, u32 val)
if (chip->gpio_chip.ngpio <= 8)
ret = i2c_smbus_write_byte_data(chip->client, reg, val);
else if (chip->gpio_chip.ngpio == 24) {
ret = i2c_smbus_write_word_data(chip->client,
cpu_to_le32s(&val);
ret = i2c_smbus_write_i2c_block_data(chip->client,
(reg << 2) | REG_ADDR_AI,
val & 0xffff);
ret = i2c_smbus_write_byte_data(chip->client,
(reg << 2) + 2,
(val & 0xff0000) >> 16);
3,
(u8 *) &val);
}
else {
switch (chip->chip_type) {
Expand Down Expand Up @@ -135,22 +134,27 @@ static int pca953x_read_reg(struct pca953x_chip *chip, int reg, u32 *val)
{
int ret;

if (chip->gpio_chip.ngpio <= 8)
if (chip->gpio_chip.ngpio <= 8) {
ret = i2c_smbus_read_byte_data(chip->client, reg);
else if (chip->gpio_chip.ngpio == 24) {
ret = i2c_smbus_read_word_data(chip->client, reg << 2);
ret |= (i2c_smbus_read_byte_data(chip->client,
(reg << 2) + 2)<<16);
*val = ret;
}
else
else if (chip->gpio_chip.ngpio == 24) {
*val = 0;
ret = i2c_smbus_read_i2c_block_data(chip->client,
(reg << 2) | REG_ADDR_AI,
3,
(u8 *) val);
le32_to_cpus(val);
} else {
ret = i2c_smbus_read_word_data(chip->client, reg << 1);
*val = ret;
}

if (ret < 0) {
dev_err(&chip->client->dev, "failed reading register\n");
return ret;
}

*val = (u32)ret;
return 0;
}

Expand Down

0 comments on commit 76155b1

Please sign in to comment.