summaryrefslogtreecommitdiff
path: root/drivers/gpio
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut@gmail.com>2018-12-12 02:39:52 +0100
committerLinus Walleij <linus.walleij@linaro.org>2018-12-14 15:18:53 +0100
commit028a219ae5b4661ccc400d7f182766853275f0eb (patch)
tree15c3b678b76f832dfa3c0e4cf0c86ce7fa4f3eef /drivers/gpio
parent8958262af3fb832c9817e50f599c5552957ceaba (diff)
gpio: pca953x: Unify pca95{3,7}x_write_regs_16()
At this point, these two functions only differ in whether they do or do not set the address increment bit on PCA9575. Merge these two functions together to simplify the code a bit. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpio-pca953x.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 479fa376bd18..2e02b3a9ac48 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -208,14 +208,11 @@ static int pca953x_write_regs_8(struct pca953x_chip *chip, int reg, u8 *val)
static int pca953x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
{
- u16 word = get_unaligned((u16 *)val);
+ u32 regaddr = (reg << 1);
- return i2c_smbus_write_word_data(chip->client, reg << 1, word);
-}
-
-static int pca957x_write_regs_16(struct pca953x_chip *chip, int reg, u8 *val)
-{
- u32 regaddr = (reg << 1) | REG_ADDR_AI;
+ /* PCA9575 needs address-increment on multi-byte writes */
+ if (PCA_CHIP_TYPE(chip->driver_data) == PCA957X_TYPE)
+ regaddr |= REG_ADDR_AI;
return i2c_smbus_write_i2c_block_data(chip->client, regaddr,
NBANK(chip), val);
@@ -892,10 +889,7 @@ static int pca953x_probe(struct i2c_client *client,
chip->write_regs = pca953x_write_regs_24;
chip->read_regs = pca953x_read_regs_24;
} else {
- if (PCA_CHIP_TYPE(chip->driver_data) == PCA953X_TYPE)
- chip->write_regs = pca953x_write_regs_16;
- else
- chip->write_regs = pca957x_write_regs_16;
+ chip->write_regs = pca953x_write_regs_16;
chip->read_regs = pca953x_read_regs_16;
}