Sort IO resources before attempting to attach; resolves issues on ACPI

firmware that reports 0x64,0x60 instead of 0x60,0x64. Patch tested by
Greg A. Woods.
This commit is contained in:
jmcneill 2007-10-05 18:31:46 +00:00
parent 04512a3ea9
commit 02ef36ec48
1 changed files with 15 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pckbc_acpi.c,v 1.20 2007/07/09 21:00:30 ad Exp $ */
/* $NetBSD: pckbc_acpi.c,v 1.21 2007/10/05 18:31:46 jmcneill Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.20 2007/07/09 21:00:30 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: pckbc_acpi.c,v 1.21 2007/10/05 18:31:46 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -146,7 +146,7 @@ pckbc_acpi_attach(struct device *parent, struct device *self,
bus_space_handle_t ioh_d, ioh_c;
pckbc_slot_t peer;
struct acpi_resources res;
struct acpi_io *io0, *io1;
struct acpi_io *io0, *io1, *ioswap;
struct acpi_irq *irq;
ACPI_STATUS rv;
@ -188,12 +188,23 @@ pckbc_acpi_attach(struct device *parent, struct device *self,
(psc->sc_slot == PCKBC_KBD_SLOT)) {
io0 = acpi_res_io(&res, 0);
if (io0 == NULL) {
io1 = acpi_res_io(&res, 1);
if (io0 == NULL || io1 == NULL) {
aprint_error("%s: unable to find i/o resources\n",
sc->sc_dv.dv_xname);
goto out;
}
/*
* JDM: Some firmware doesn't report resources in the order we
* expect; sort IO resources here (lowest first)
*/
if (io0->ar_base > io1->ar_base) {
ioswap = io0;
io0 = io1;
io1 = ioswap;
}
if (pckbc_is_console(aa->aa_iot, io0->ar_base)) {
t = &pckbc_consdata;
ioh_d = t->t_ioh_d;
@ -201,12 +212,6 @@ pckbc_acpi_attach(struct device *parent, struct device *self,
pckbc_console_attached = 1;
/* t->t_cmdbyte was initialized by cnattach */
} else {
io1 = acpi_res_io(&res, 1);
if (io1 == NULL) {
aprint_error("%s: unable to find i/o resources\n",
sc->sc_dv.dv_xname);
goto out;
}
if (bus_space_map(aa->aa_iot, io0->ar_base,
io0->ar_length, 0, &ioh_d) ||
bus_space_map(aa->aa_iot, io1->ar_base,