Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/spi m25p: add compatible entry for "jedec,spi-nor" a...



details:   https://anonhg.NetBSD.org/src/rev/95599b117a6c
branches:  trunk
changeset: 1002750:95599b117a6c
user:      tnn <tnn%NetBSD.org@localhost>
date:      Tue Aug 13 17:11:32 2019 +0000

description:
m25p: add compatible entry for "jedec,spi-nor" and match on it

diffstat:

 sys/dev/spi/m25p.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r 8ac11c9129dd -r 95599b117a6c sys/dev/spi/m25p.c
--- a/sys/dev/spi/m25p.c        Tue Aug 13 17:03:10 2019 +0000
+++ b/sys/dev/spi/m25p.c        Tue Aug 13 17:11:32 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: m25p.c,v 1.10 2019/08/04 22:13:24 tnn Exp $ */
+/* $NetBSD: m25p.c,v 1.11 2019/08/13 17:11:32 tnn Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.10 2019/08/04 22:13:24 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.11 2019/08/13 17:11:32 tnn Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -114,16 +114,26 @@
        { 0 }
 };
 
+static const struct device_compatible_entry compat_data[] = {
+       { "jedec,spi-nor",      0 },
+       { NULL,                 0 }
+};
+
 static int
 m25p_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct spi_attach_args *sa = aux;
+       int res;
+
+       res = spi_compatible_match(sa, cf, compat_data);
+       if (!res)
+               return res;
 
        /* configure for 20MHz, which is the max for normal reads */
        if (spi_configure(sa->sa_handle, SPI_MODE_0, 20000000))
-               return 0;
+               res = 0;
 
-       return 1;
+       return res;
 }
 
 static void



Home | Main Index | Thread Index | Old Index