Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/i2c Use iic_compatible_lookup() in ssdfb_i2c_attach().



details:   https://anonhg.NetBSD.org/src/rev/46f5f2e54781
branches:  trunk
changeset: 1018262:46f5f2e54781
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jan 28 14:42:45 2021 +0000

description:
Use iic_compatible_lookup() in ssdfb_i2c_attach().

diffstat:

 sys/dev/i2c/ssdfb_i2c.c |  28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)

diffs (58 lines):

diff -r 447cde96b271 -r 46f5f2e54781 sys/dev/i2c/ssdfb_i2c.c
--- a/sys/dev/i2c/ssdfb_i2c.c   Thu Jan 28 14:35:11 2021 +0000
+++ b/sys/dev/i2c/ssdfb_i2c.c   Thu Jan 28 14:42:45 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ssdfb_i2c.c,v 1.8 2021/01/27 02:29:48 thorpej Exp $ */
+/* $NetBSD: ssdfb_i2c.c,v 1.9 2021/01/28 14:42:45 thorpej Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.8 2021/01/27 02:29:48 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ssdfb_i2c.c,v 1.9 2021/01/28 14:42:45 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -67,8 +67,12 @@
     ssdfb_i2c_match, ssdfb_i2c_attach, ssdfb_i2c_detach, NULL);
 
 static const struct device_compatible_entry compat_data[] = {
-       { .compat = "solomon,ssd1306fb-i2c" },
-       { .compat = "sino,sh1106fb-i2c" },
+       { .compat = "solomon,ssd1306fb-i2c",
+         .value = SSDFB_PRODUCT_SSD1306_GENERIC },
+
+       { .compat = "sino,sh1106fb-i2c",
+         .value = SSDFB_PRODUCT_SH1106_GENERIC },
+
        DEVICE_COMPAT_EOL
 };
 
@@ -97,20 +101,12 @@
        struct cfdata *cf = device_cfdata(self);
        struct i2c_attach_args *ia = aux;
        int flags = cf->cf_flags;
-       int i;
 
        if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) == SSDFB_PRODUCT_UNKNOWN) {
-               for (i = 0; i < ia->ia_ncompat; i++) {
-                       if (strncmp("solomon,ssd1306", ia->ia_compat[i], 15)
-                           == 0) {
-                               flags |= SSDFB_PRODUCT_SSD1306_GENERIC;
-                               break;
-                       }
-                       else if (strncmp("sino,sh1106", ia->ia_compat[i], 11)
-                           == 0) {
-                               flags |= SSDFB_PRODUCT_SH1106_GENERIC;
-                               break;
-                       }
+               const struct device_compatible_entry *dce =
+                   iic_compatible_lookup(ia, compat_data);
+               if (dce != NULL) {
+                       flags |= (int)dce->value;
                }
        }
        if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) == SSDFB_PRODUCT_UNKNOWN)



Home | Main Index | Thread Index | Old Index