Module Name:    src
Committed By:   thorpej
Date:           Wed May 19 03:34:11 UTC 2021

Modified Files:
        src/sys/dev/spi [thorpej-i2c-spi-conf]: tmp121.c

Log Message:
Use spi_compatible_match().

XXX Should support the other variants of this device.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.5.72.1 src/sys/dev/spi/tmp121.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/spi/tmp121.c
diff -u src/sys/dev/spi/tmp121.c:1.5 src/sys/dev/spi/tmp121.c:1.5.72.1
--- src/sys/dev/spi/tmp121.c:1.5	Mon Jun 20 17:31:37 2011
+++ src/sys/dev/spi/tmp121.c	Wed May 19 03:34:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tmp121.c,v 1.5 2011/06/20 17:31:37 pgoyette Exp $ */
+/* $NetBSD: tmp121.c,v 1.5.72.1 2021/05/19 03:34:11 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.5 2011/06/20 17:31:37 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.5.72.1 2021/05/19 03:34:11 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -68,16 +68,39 @@ static void	tmp121temp_refresh(struct sy
 CFATTACH_DECL_NEW(tmp121temp, sizeof(struct tmp121temp_softc),
     tmp121temp_match, tmp121temp_attach, NULL, NULL);
 
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "ti,tmp121" },
+	{ .compat = "TMP00121" },
+
+#if 0	/* We should also add support for these: */
+	{ .compat = "ti,tmp122" },
+
+	{ .compat = "ti,lm70" },
+	{ .compat = "LM000070" },
+
+	{ .compat = "ti,lm71" },
+	{ .compat = "LM000071" },
+
+	{ .compat = "ti,lm74" },
+	{ .compat = "LM000074" },
+#endif
+	DEVICE_COMPAT_EOL
+};
+
 static int
 tmp121temp_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct spi_attach_args *sa = aux;
+	int rv;
 
-	/* configure for 10MHz */
-	if (spi_configure(sa->sa_handle, SPI_MODE_0, 1000000))
-		return 0;
+	rv = spi_compatible_match(sa, cf, compat_data);
+	if (rv != 0) {
+		/* configure for 10MHz */
+		if (spi_configure(sa->sa_handle, SPI_MODE_0, 1000000))
+			return 0;
+	}
 
-	return 1;
+	return rv;
 }
 
 static void

Reply via email to