diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2016-11-07 08:53:14 -0800 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2016-11-08 09:37:32 +0100 |
commit | 310cdfa0097a94d8cc3c0c314d64d6eb1cc69bf8 (patch) | |
tree | 18e08746eae4085c4f677736e5a6f2c86625328a /drivers/pinctrl/pinctrl-sx150x.c | |
parent | 9af2ca82b33f82dfb015706696a9cdf55b8feaa0 (diff) | |
download | linux-stable-310cdfa0097a94d8cc3c0c314d64d6eb1cc69bf8.tar.gz linux-stable-310cdfa0097a94d8cc3c0c314d64d6eb1cc69bf8.tar.bz2 linux-stable-310cdfa0097a94d8cc3c0c314d64d6eb1cc69bf8.zip |
pinctrl-sx150x: Move some code out of sx150x_init_hw
Move the code configuring explicit IRQ acking into a standalone function
to declutter sx150x_init_hw a bit and make that code somewhat less
repetitious.
Tested-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-sx150x.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-sx150x.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c index 0e3e1daeeb72..27194e700d2f 100644 --- a/drivers/pinctrl/pinctrl-sx150x.c +++ b/drivers/pinctrl/pinctrl-sx150x.c @@ -924,6 +924,31 @@ static int sx150x_reset(struct sx150x_pinctrl *pctl) return err; } +static int sx150x_init_misc(struct sx150x_pinctrl *pctl) +{ + u8 reg, value; + + switch (pctl->data->model) { + case SX150X_789: + reg = pctl->data->pri.x789.reg_misc; + value = SX150X_789_REG_MISC_AUTOCLEAR_OFF; + break; + case SX150X_456: + reg = pctl->data->pri.x456.reg_advance; + value = 0x00; + break; + case SX150X_123: + reg = pctl->data->pri.x123.reg_advance; + value = 0x00; + break; + default: + WARN(1, "Unknown chip model %d\n", pctl->data->model); + return -EINVAL; + } + + return sx150x_i2c_write(pctl->client, reg, value); +} + static int sx150x_init_hw(struct sx150x_pinctrl *pctl) { int err; @@ -935,18 +960,7 @@ static int sx150x_init_hw(struct sx150x_pinctrl *pctl) return err; } - if (pctl->data->model == SX150X_789) - err = sx150x_i2c_write(pctl->client, - pctl->data->pri.x789.reg_misc, - SX150X_789_REG_MISC_AUTOCLEAR_OFF); - else if (pctl->data->model == SX150X_456) - err = sx150x_i2c_write(pctl->client, - pctl->data->pri.x456.reg_advance, - 0x00); - else - err = sx150x_i2c_write(pctl->client, - pctl->data->pri.x123.reg_advance, - 0x00); + err = sx150x_init_misc(pctl); if (err < 0) return err; |