From: Peter Rosin Date: Fri, 2 Dec 2016 10:51:14 +0000 (+0100) Subject: pinctrl: sx150x: access the correct bits in the 4-bit regs of sx150[147] X-Git-Tag: v4.14-rc1~1939^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c4ef627d8c458fe8880ccd2e2cd581de0d9b42f;p=platform%2Fkernel%2Flinux-rpi.git pinctrl: sx150x: access the correct bits in the 4-bit regs of sx150[147] The code assumes 8-bit or 16-bit width registers, but three of the chips (sx1501/sx1504/sx1507) are 4-bit. So, try to handle 4-bit chips as well, they leave the high part of each register unused. Signed-off-by: Peter Rosin Signed-off-by: Linus Walleij --- diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c index 1a1c8b5..a121819 100644 --- a/drivers/pinctrl/pinctrl-sx150x.c +++ b/drivers/pinctrl/pinctrl-sx150x.c @@ -5,6 +5,7 @@ * Copyright (c) 2010, Code Aurora Forum. All rights reserved. * * Driver for Semtech SX150X I2C GPIO Expanders + * The handling of the 4-bit chips (SX1501/SX1504/SX1507) is untested. * * Author: Gregory Bean * @@ -1088,7 +1089,7 @@ static int sx150x_regmap_reg_write(void *context, unsigned int reg, val = sx150x_maybe_swizzle(pctl, reg, val); - n = width - 8; + n = (width - 1) & ~7; do { const u8 byte = (val >> n) & 0xff;