summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-sch311x.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2014-04-15 10:15:27 +0800
committerLinus Walleij <linus.walleij@linaro.org>2014-04-28 12:35:09 -0700
commit7e9fcc9d62626c752e38d5eeb78687d006fc24cf (patch)
treec8f52d668e46d26145cacc2a52def7f1c72b1118 /drivers/gpio/gpio-sch311x.c
parentf604cf0919b806bdedef5f53dd1f43796166997c (diff)
downloadlinux-7e9fcc9d62626c752e38d5eeb78687d006fc24cf.tar.gz
linux-7e9fcc9d62626c752e38d5eeb78687d006fc24cf.tar.bz2
linux-7e9fcc9d62626c752e38d5eeb78687d006fc24cf.zip
gpio: sch311x: Slightly refactor sch311x_detect for better readability
Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-sch311x.c')
-rw-r--r--drivers/gpio/gpio-sch311x.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
index 0357387b3645..f942b80ee403 100644
--- a/drivers/gpio/gpio-sch311x.c
+++ b/drivers/gpio/gpio-sch311x.c
@@ -327,14 +327,22 @@ static int __init sch311x_detect(int sio_config_port, unsigned short *addr)
if (err)
return err;
- /* Check device ID. We currently know about:
- * SCH3112 (0x7c), SCH3114 (0x7d), and SCH3116 (0x7f). */
+ /* Check device ID. */
reg = sch311x_sio_inb(sio_config_port, 0x20);
- if (!(reg == 0x7c || reg == 0x7d || reg == 0x7f)) {
+ switch (reg) {
+ case 0x7c: /* SCH3112 */
+ dev_id = 2;
+ break;
+ case 0x7d: /* SCH3114 */
+ dev_id = 4;
+ break;
+ case 0x7f: /* SCH3116 */
+ dev_id = 6;
+ break;
+ default:
err = -ENODEV;
goto exit;
}
- dev_id = reg == 0x7c ? 2 : reg == 0x7d ? 4 : 6;
/* Select logical device A (runtime registers) */
sch311x_sio_outb(sio_config_port, 0x07, 0x0a);