Module Name: src
Committed By: thorpej
Date: Mon Sep 13 14:47:28 UTC 2021
Modified Files:
src/sys/arch/macppc/dev [thorpej-i2c-spi-conf2]: cuda.c
src/sys/arch/sandpoint/sandpoint [thorpej-i2c-spi-conf2]: autoconf.c
src/sys/arch/sparc64/sparc64 [thorpej-i2c-spi-conf2]: ofw_patch.c
src/sys/dev/i2c [thorpej-i2c-spi-conf2]: i2c.c i2cvar.h
Added Files:
src/sys/dev/i2c [thorpej-i2c-spi-conf2]: i2c_enum.h
Log Message:
Move the i2c enumeration helpers to their own header file to detangle
it from reliance on "iic" being configured into the kernel.
To generate a diff of this commit:
cvs rdiff -u -r1.29.2.5 -r1.29.2.6 src/sys/arch/macppc/dev/cuda.c
cvs rdiff -u -r1.29.16.4 -r1.29.16.5 \
src/sys/arch/sandpoint/sandpoint/autoconf.c
cvs rdiff -u -r1.7.14.7 -r1.7.14.8 src/sys/arch/sparc64/sparc64/ofw_patch.c
cvs rdiff -u -r1.80.2.7 -r1.80.2.8 src/sys/dev/i2c/i2c.c
cvs rdiff -u -r0 -r1.1.2.1 src/sys/dev/i2c/i2c_enum.h
cvs rdiff -u -r1.24.12.3 -r1.24.12.4 src/sys/dev/i2c/i2cvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/macppc/dev/cuda.c
diff -u src/sys/arch/macppc/dev/cuda.c:1.29.2.5 src/sys/arch/macppc/dev/cuda.c:1.29.2.6
--- src/sys/arch/macppc/dev/cuda.c:1.29.2.5 Sat Sep 11 17:22:35 2021
+++ src/sys/arch/macppc/dev/cuda.c Mon Sep 13 14:47:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cuda.c,v 1.29.2.5 2021/09/11 17:22:35 thorpej Exp $ */
+/* $NetBSD: cuda.c,v 1.29.2.6 2021/09/13 14:47:28 thorpej Exp $ */
/*-
* Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.29.2.5 2021/09/11 17:22:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.29.2.6 2021/09/13 14:47:28 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: cuda.c,v 1.2
#include <machine/pio.h>
#include <dev/clock_subr.h>
#include <dev/i2c/i2cvar.h>
+#include <dev/i2c/i2c_enum.h>
#include <macppc/dev/viareg.h>
#include <macppc/dev/cudavar.h>
Index: src/sys/arch/sandpoint/sandpoint/autoconf.c
diff -u src/sys/arch/sandpoint/sandpoint/autoconf.c:1.29.16.4 src/sys/arch/sandpoint/sandpoint/autoconf.c:1.29.16.5
--- src/sys/arch/sandpoint/sandpoint/autoconf.c:1.29.16.4 Sat Sep 11 01:03:18 2021
+++ src/sys/arch/sandpoint/sandpoint/autoconf.c Mon Sep 13 14:47:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: autoconf.c,v 1.29.16.4 2021/09/11 01:03:18 thorpej Exp $ */
+/* $NetBSD: autoconf.c,v 1.29.16.5 2021/09/13 14:47:28 thorpej Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29.16.4 2021/09/11 01:03:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.29.16.5 2021/09/13 14:47:28 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -44,7 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v
#include <dev/cons.h>
#include <dev/pci/pcivar.h>
-#include <dev/i2c/i2cvar.h>
+
+#include <dev/i2c/i2c_enum.h>
#include <net/if.h>
#include <net/if_ether.h>
Index: src/sys/arch/sparc64/sparc64/ofw_patch.c
diff -u src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7.14.7 src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7.14.8
--- src/sys/arch/sparc64/sparc64/ofw_patch.c:1.7.14.7 Sun Sep 12 19:23:27 2021
+++ src/sys/arch/sparc64/sparc64/ofw_patch.c Mon Sep 13 14:47:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ofw_patch.c,v 1.7.14.7 2021/09/12 19:23:27 thorpej Exp $ */
+/* $NetBSD: ofw_patch.c,v 1.7.14.8 2021/09/13 14:47:28 thorpej Exp $ */
/*-
* Copyright (c) 2020, 2021 The NetBSD Foundation, Inc.
@@ -29,12 +29,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.7.14.7 2021/09/12 19:23:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_patch.c,v 1.7.14.8 2021/09/13 14:47:28 thorpej Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
-#include <dev/i2c/i2cvar.h>
+#include <dev/i2c/i2c_enum.h>
+
#include <dev/scsipi/scsipiconf.h>
#include <machine/autoconf.h>
Index: src/sys/dev/i2c/i2c.c
diff -u src/sys/dev/i2c/i2c.c:1.80.2.7 src/sys/dev/i2c/i2c.c:1.80.2.8
--- src/sys/dev/i2c/i2c.c:1.80.2.7 Sun Sep 12 22:02:19 2021
+++ src/sys/dev/i2c/i2c.c Mon Sep 13 14:47:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: i2c.c,v 1.80.2.7 2021/09/12 22:02:19 thorpej Exp $ */
+/* $NetBSD: i2c.c,v 1.80.2.8 2021/09/13 14:47:28 thorpej Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.80.2.7 2021/09/12 22:02:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.80.2.8 2021/09/13 14:47:28 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -631,41 +631,6 @@ iic_enumerate_devices_callback(device_t
return true; /* keep enumerating */
}
-/*
- * i2c_enumerate_deventries:
- *
- * Helper for enumerating known i2c devices that can be used
- * by a platform's i2c-emumerate-devices device call if needed.
- */
-int
-i2c_enumerate_deventries(device_t dev, devhandle_t call_handle,
- struct i2c_enumerate_devices_args *args,
- const struct i2c_deventry *entries, unsigned int nentries)
-{
- unsigned int i;
- bool cbrv;
-
- for (i = 0; i < nentries; i++) {
- args->ia->ia_addr = entries[i].addr;
- args->ia->ia_name = entries[i].name;
- args->ia->ia_clist = entries[i].compat;
- args->ia->ia_clist_size =
- entries[i].compat != NULL ? strlen(entries[i].compat) + 1
- : 0;
-
- /* no devhandle for child devices. */
- devhandle_invalidate(&args->ia->ia_devhandle);
-
- cbrv = args->callback(dev, args);
-
- if (!cbrv) {
- break;
- }
- }
-
- return 0;
-}
-
static int
iic_match(device_t parent, cfdata_t cf, void *aux)
{
Index: src/sys/dev/i2c/i2cvar.h
diff -u src/sys/dev/i2c/i2cvar.h:1.24.12.3 src/sys/dev/i2c/i2cvar.h:1.24.12.4
--- src/sys/dev/i2c/i2cvar.h:1.24.12.3 Sat Sep 11 01:03:18 2021
+++ src/sys/dev/i2c/i2cvar.h Mon Sep 13 14:47:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: i2cvar.h,v 1.24.12.3 2021/09/11 01:03:18 thorpej Exp $ */
+/* $NetBSD: i2cvar.h,v 1.24.12.4 2021/09/13 14:47:28 thorpej Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -175,19 +175,6 @@ struct i2c_enumerate_devices_args {
};
/*
- * Helpers for enumerating known i2c devices, that can be used from
- * the i2c-enumerate-devices device call.
- */
-struct i2c_deventry {
- const char *name;
- const char *compat;
- i2c_addr_t addr;
-};
-int i2c_enumerate_deventries(device_t, devhandle_t,
- struct i2c_enumerate_devices_args *,
- const struct i2c_deventry *, unsigned int);
-
-/*
* API presented to i2c controllers.
*/
int iicbus_print(void *, const char *);
Added files:
Index: src/sys/dev/i2c/i2c_enum.h
diff -u /dev/null src/sys/dev/i2c/i2c_enum.h:1.1.2.1
--- /dev/null Mon Sep 13 14:47:28 2021
+++ src/sys/dev/i2c/i2c_enum.h Mon Sep 13 14:47:28 2021
@@ -0,0 +1,76 @@
+/* $NetBSD: i2c_enum.h,v 1.1.2.1 2021/09/13 14:47:28 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_I2C_I2C_ENUM_H_
+#define _DEV_I2C_I2C_ENUM_H_
+
+#include <dev/i2c/i2cvar.h>
+
+/*
+ * Helpers for enumerating known i2c devices, that can be used from
+ * the i2c-enumerate-devices device call.
+ */
+struct i2c_deventry {
+ const char *name;
+ const char *compat;
+ i2c_addr_t addr;
+};
+
+static inline int __unused
+i2c_enumerate_deventries(device_t dev, devhandle_t call_handle,
+ struct i2c_enumerate_devices_args *args,
+ const struct i2c_deventry *entries, unsigned int nentries)
+{
+ unsigned int i;
+ bool cbrv;
+
+ for (i = 0; i < nentries; i++) {
+ args->ia->ia_addr = entries[i].addr;
+ args->ia->ia_name = entries[i].name;
+ args->ia->ia_clist = entries[i].compat;
+ args->ia->ia_clist_size =
+ entries[i].compat != NULL ? strlen(entries[i].compat) + 1
+ : 0;
+
+ /* no devhandle for child devices. */
+ devhandle_invalidate(&args->ia->ia_devhandle);
+
+ cbrv = args->callback(dev, args);
+
+ if (!cbrv) {
+ break;
+ }
+ }
+
+ return 0;
+}
+
+#endif /* _DEV_I2C_I2C_ENUM_H_ */