Re: CFR: ACPI Dock driver

From: Mitsuru IWASAKI <iwasaki_at_jp.FreeBSD.org>
Date: Thu, 13 Apr 2006 01:21:56 +0900 (JST)
Hi, Thanks for your comments.  Patches for acpi_dock.c are attached.

One thing,

> * There also might be an acpi_GetReference() helper function to use.  (I 
> think I wrote one)

Sorry, I can't get this.  Could you point this out in detail?

Thanks!



--- acpi_dock.c.20060410	Mon Apr 10 03:34:35 2006
+++ acpi_dock.c	Thu Apr 13 01:06:04 2006
_at__at_ -143,36 +143,21 _at__at_
 acpi_dock_execute_lck(device_t dev, int lock)
 {
 	ACPI_HANDLE	h;
-	ACPI_OBJECT	argobj;
-	ACPI_OBJECT_LIST args;
-	ACPI_STATUS	status;
 
 	h = acpi_get_handle(dev);
-
-	argobj.Type = ACPI_TYPE_INTEGER;
-	argobj.Integer.Value = lock;
-	args.Count = 1;
-	args.Pointer = &argobj;
-	status = AcpiEvaluateObject(h, "_LCK", &args, NULL);
+	acpi_SetInteger(h, "_LCK", lock);
 }
 
 static int
 acpi_dock_execute_ejx(device_t dev, int eject, int state)
 {
 	ACPI_HANDLE	h;
-	ACPI_OBJECT	argobj;
-	ACPI_OBJECT_LIST args;
 	ACPI_STATUS	status;
 	char		ejx[5];
 
 	h = acpi_get_handle(dev);
-
-	argobj.Type = ACPI_TYPE_INTEGER;
-	argobj.Integer.Value = eject;
-	args.Count = 1;
-	args.Pointer = &argobj;
 	snprintf(ejx, sizeof(ejx), "_EJ%d", state);
-	status = AcpiEvaluateObject(h, ejx, &args, NULL);
+	status = acpi_SetInteger(h, ejx, eject);
 
 	if (ACPI_SUCCESS(status)) {
 		return (0);
_at__at_ -228,7 +213,9 _at__at_
 		device_enable(dev);
 	}
 
+	mtx_lock(&Giant);
 	device_probe_and_attach(dev);
+	mtx_unlock(&Giant);
 }
 
 static ACPI_STATUS
_at__at_ -247,7 +234,15 _at__at_
 	ACPI_VPRINT(dock_dev, acpi_device_get_parent_softc(dock_dev),
 		    "inserting device for %s\n", acpi_name(handle));
 
-#if (ACPI_CA_VERSION <= 0x20041119)
+#if 0
+	/*
+	 * If the system boot up w/o Docking, the devices under the dock
+	 * still un-initialized, also control methods such as _INI, _STA
+	 * are not executed.
+	 * Normal devices are initialized at booting by calling
+	 * AcpiInitializeObjects(), however the devices under the dock
+	 * need to be initialized here on the scheme of ACPICA.
+	 */
 	ACPI_INIT_WALK_INFO	Info;
 
 	AcpiNsWalkNamespace(ACPI_TYPE_ANY, handle,
_at__at_ -262,7 +257,7 _at__at_
 		goto out;
 	}
 
-	timeout(acpi_dock_attach_later, (caddr_t)dev, hz*3);
+	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_dock_attach_later, dev);
 
 out:
 	return (AE_OK);
_at__at_ -285,6 +280,8 _at__at_
 	struct acpi_dock_softc *sc;
 	ACPI_HANDLE	h;
 
+	ACPI_SERIAL_ASSERT(dock);
+
 	sc = device_get_softc(dev);
 	h = acpi_get_handle(dev);
 
_at__at_ -313,8 +310,6 _at__at_
 {
 	device_t	dock_dev, dev;
 	ACPI_HANDLE	dock_handle;
-	ACPI_OBJECT	argobj;
-	ACPI_OBJECT_LIST args;
 
 	dock_dev = *(device_t *)context;
 	dock_handle = acpi_get_handle(dock_dev);
_at__at_ -333,12 +328,7 _at__at_
 		mtx_unlock(&Giant);
 	}
 
-	argobj.Type = ACPI_TYPE_INTEGER;
-	argobj.Integer.Value = 0;
-	args.Count = 1;
-	args.Pointer = &argobj;
-	AcpiEvaluateObject(handle, "_EJ0", &args, NULL);
-
+	acpi_SetInteger(handle, "_EJ0", 0);
 out:
 	return (AE_OK);
 }
_at__at_ -359,6 +349,8 _at__at_
 {
 	struct acpi_dock_softc *sc;
 
+	ACPI_SERIAL_ASSERT(dock);
+
 	sc = device_get_softc(dev);
 	if (acpi_dock_status == ACPI_DOCK_STATUS_DOCKED ||
 	    acpi_dock_status == ACPI_DOCK_STATUS_UNKNOWN) {
_at__at_ -392,6 +384,8 _at__at_
 {
 	struct acpi_dock_softc *sc;
 
+	ACPI_SERIAL_ASSERT(dock);
+
 	sc = device_get_softc(dev);
 	acpi_dock_get_info(dev);
 
_at__at_ -399,7 +393,7 _at__at_
 	 * If the _STA indicates 'present' and 'functioning',
 	 * the system is docked.
 	 */
-	if (sc->_sta & 0x9) {
+	if (ACPI_DEVICE_PRESENT(sc->_sta)) {
 		acpi_dock_insert(dev);
 	}
 	if (sc->_sta == 0x0) {
_at__at_ -420,6 +414,7 _at__at_
 	ACPI_VPRINT(dev, acpi_device_get_parent_softc(dev),
 		    "got notification %#x\n", notify);
 
+	ACPI_SERIAL_BEGIN(dock);
 	switch (notify) {
 	case ACPI_DOCK_NOTIFY_BUS_CHECK:
 	case ACPI_DOCK_NOTIFY_DEVICE_CHECK:
_at__at_ -434,6 +429,7 _at__at_
 		device_printf(dev, "unknown notify %#x\n", notify);
 		break;
 	}
+	ACPI_SERIAL_END(dock);
 }
 
 /*
_at__at_ -530,9 +526,10 _at__at_
 	sc->status = ACPI_DOCK_STATUS_UNKNOWN;
 
 	AcpiEvaluateObject(h, "_INI", NULL, NULL);
-	acpi_dock_device_check(dev);
 
 	ACPI_SERIAL_BEGIN(dock);
+
+	acpi_dock_device_check(dev);
 
         /* Get the sysctl tree */
 	sc->sysctl_ctx = device_get_sysctl_ctx(dev);
Received on Wed Apr 12 2006 - 14:21:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:54 UTC