Module Name:    src
Committed By:   thorpej
Date:           Sat May  8 15:44:12 UTC 2021

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

Log Message:
Rather than using the "cookie" from the i2c_attach_args, use the
device handle that's already associated with our device_t.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.19.2.1 src/sys/dev/i2c/ihidev.c
cvs rdiff -u -r1.4 -r1.4.10.1 src/sys/dev/i2c/ihidev.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/dev/i2c/ihidev.c
diff -u src/sys/dev/i2c/ihidev.c:1.19 src/sys/dev/i2c/ihidev.c:1.19.2.1
--- src/sys/dev/i2c/ihidev.c:1.19	Sat Apr 24 23:36:54 2021
+++ src/sys/dev/i2c/ihidev.c	Sat May  8 15:44:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.c,v 1.19 2021/04/24 23:36:54 thorpej Exp $ */
+/* $NetBSD: ihidev.c,v 1.19.2.1 2021/05/08 15:44:12 thorpej Exp $ */
 /* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */
 
 /*-
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.19 2021/04/24 23:36:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.19.2.1 2021/05/08 15:44:12 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -162,8 +162,7 @@ ihidev_attach(device_t parent, device_t 
 	sc->sc_addr = ia->ia_addr;
 	mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_VM);
 
-	sc->sc_phandle = ia->ia_cookie;
-	if (ia->ia_cookietype != I2C_COOKIE_ACPI) {
+	if (devhandle_type(device_handle(self)) != DEVHANDLE_TYPE_ACPI) {
 		aprint_error(": unsupported device tree type\n");
 		return;
 	}
@@ -651,7 +650,7 @@ static bool
 ihiddev_intr_init(struct ihidev_softc *sc)
 {
 #if NACPICA > 0
-	ACPI_HANDLE hdl = (void *)(uintptr_t)sc->sc_phandle;
+	ACPI_HANDLE hdl = devhandle_to_acpi(device_handle(sc->sc_dev));
 	struct acpi_resources res;
 	ACPI_STATUS rv;
 	char buf[100];
@@ -675,7 +674,7 @@ ihiddev_intr_init(struct ihidev_softc *s
 
 	acpi_resource_cleanup(&res);
 
-	sc->sc_ih = acpi_intr_establish(sc->sc_dev, sc->sc_phandle, IPL_TTY,
+	sc->sc_ih = acpi_intr_establish(sc->sc_dev, (uint64_t)hdl, IPL_TTY,
 	    false, ihidev_intr, sc, device_xname(sc->sc_dev));
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(sc->sc_dev, "can't establish interrupt\n");
@@ -977,7 +976,7 @@ ihidev_set_report(struct device *dev, in
 static bool
 ihidev_acpi_get_info(struct ihidev_softc *sc)
 {               
-	ACPI_HANDLE hdl = (void *)(uintptr_t)sc->sc_phandle;
+	ACPI_HANDLE hdl = devhandle_to_acpi(device_handle(sc->sc_dev));
 	ACPI_STATUS status;
 	ACPI_INTEGER val;
 

Index: src/sys/dev/i2c/ihidev.h
diff -u src/sys/dev/i2c/ihidev.h:1.4 src/sys/dev/i2c/ihidev.h:1.4.10.1
--- src/sys/dev/i2c/ihidev.h:1.4	Thu Jan  9 04:04:01 2020
+++ src/sys/dev/i2c/ihidev.h	Sat May  8 15:44:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ihidev.h,v 1.4 2020/01/09 04:04:01 thorpej Exp $ */
+/* $NetBSD: ihidev.h,v 1.4.10.1 2021/05/08 15:44:12 thorpej Exp $ */
 /* $OpenBSD ihidev.h,v 1.4 2016/01/31 18:24:35 jcs Exp $ */
 
 /*-
@@ -97,7 +97,6 @@ struct ihidev_softc {
 	device_t	sc_dev;
 	i2c_tag_t	sc_tag;
 	i2c_addr_t	sc_addr;
-	uint64_t	sc_phandle;
 
 	void *		sc_ih;
 	void *		sc_sih;

Reply via email to