All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: sch311x: Slightly refactor sch311x_detect for better readability
@ 2014-04-15  2:15 Axel Lin
  2014-04-22 15:09 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2014-04-15  2:15 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Bruno Randolf, Alexandre Courbot, linux-gpio

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-sch311x.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-sch311x.c b/drivers/gpio/gpio-sch311x.c
index 0357387..f942b80 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);
-- 
1.8.3.2




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpio: sch311x: Slightly refactor sch311x_detect for better readability
  2014-04-15  2:15 [PATCH] gpio: sch311x: Slightly refactor sch311x_detect for better readability Axel Lin
@ 2014-04-22 15:09 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2014-04-22 15:09 UTC (permalink / raw)
  To: Axel Lin; +Cc: Bruno Randolf, Alexandre Courbot, linux-gpio

On Tue, Apr 15, 2014 at 4:15 AM, Axel Lin <axel.lin@ingics.com> wrote:

> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Thanks Axel, this was a very nice patch, the old code was completely
unreadable.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-04-22 15:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15  2:15 [PATCH] gpio: sch311x: Slightly refactor sch311x_detect for better readability Axel Lin
2014-04-22 15:09 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.