acpi: remove 'magic' ivar

o acpi_hpet: auto-added 'wildcard' devices can be identified by
  non-NULL handle attribute.
o acpi_ec: auto-add 'wildcard' devices can be identified by
  unset (NULL) private attribute.
o acpi_cpu: use private instead of magic to store cpu id.

Reviewed by:	jhb
Silence from:	acpi@
MFC after:	2 weeks
X-MFC-Note:	perhaps the ivar should stay for ABI stability
This commit is contained in:
Andriy Gapon 2009-11-07 11:46:38 +00:00
parent ede807c429
commit f6eb382c79
5 changed files with 10 additions and 24 deletions

View File

@ -900,9 +900,6 @@ acpi_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
case ACPI_IVAR_HANDLE: case ACPI_IVAR_HANDLE:
*(ACPI_HANDLE *)result = ad->ad_handle; *(ACPI_HANDLE *)result = ad->ad_handle;
break; break;
case ACPI_IVAR_MAGIC:
*(uintptr_t *)result = ad->ad_magic;
break;
case ACPI_IVAR_PRIVATE: case ACPI_IVAR_PRIVATE:
*(void **)result = ad->ad_private; *(void **)result = ad->ad_private;
break; break;
@ -938,9 +935,6 @@ acpi_write_ivar(device_t dev, device_t child, int index, uintptr_t value)
case ACPI_IVAR_HANDLE: case ACPI_IVAR_HANDLE:
ad->ad_handle = (ACPI_HANDLE)value; ad->ad_handle = (ACPI_HANDLE)value;
break; break;
case ACPI_IVAR_MAGIC:
ad->ad_magic = (uintptr_t)value;
break;
case ACPI_IVAR_PRIVATE: case ACPI_IVAR_PRIVATE:
ad->ad_private = (void *)value; ad->ad_private = (void *)value;
break; break;

View File

@ -255,7 +255,7 @@ acpi_cpu_probe(device_t dev)
/* Mark this processor as in-use and save our derived id for attach. */ /* Mark this processor as in-use and save our derived id for attach. */
cpu_softc[cpu_id] = (void *)1; cpu_softc[cpu_id] = (void *)1;
acpi_set_magic(dev, cpu_id); acpi_set_private(dev, (void*)(intptr_t)cpu_id);
device_set_desc(dev, "ACPI CPU"); device_set_desc(dev, "ACPI CPU");
return (0); return (0);
@ -286,7 +286,7 @@ acpi_cpu_attach(device_t dev)
sc = device_get_softc(dev); sc = device_get_softc(dev);
sc->cpu_dev = dev; sc->cpu_dev = dev;
sc->cpu_handle = acpi_get_handle(dev); sc->cpu_handle = acpi_get_handle(dev);
cpu_id = acpi_get_magic(dev); cpu_id = (int)(intptr_t)acpi_get_private(dev);
cpu_softc[cpu_id] = sc; cpu_softc[cpu_id] = sc;
pcpu_data = pcpu_find(cpu_id); pcpu_data = pcpu_find(cpu_id);
pcpu_data->pc_device = dev; pcpu_data->pc_device = dev;

View File

@ -129,9 +129,6 @@ struct acpi_ec_params {
int uid; int uid;
}; };
/* Indicate that this device has already been probed via ECDT. */
#define DEV_ECDT(x) (acpi_get_magic(x) == (uintptr_t)&acpi_ec_devclass)
/* /*
* Driver softc. * Driver softc.
*/ */
@ -332,7 +329,6 @@ acpi_ec_ecdt_probe(device_t parent)
params->uid = ecdt->Uid; params->uid = ecdt->Uid;
acpi_GetInteger(h, "_GLK", &params->glk); acpi_GetInteger(h, "_GLK", &params->glk);
acpi_set_private(child, params); acpi_set_private(child, params);
acpi_set_magic(child, (uintptr_t)&acpi_ec_devclass);
/* Finish the attach process. */ /* Finish the attach process. */
if (device_probe_and_attach(child) != 0) if (device_probe_and_attach(child) != 0)
@ -348,6 +344,7 @@ acpi_ec_probe(device_t dev)
ACPI_STATUS status; ACPI_STATUS status;
device_t peer; device_t peer;
char desc[64]; char desc[64];
int ecdt;
int ret; int ret;
struct acpi_ec_params *params; struct acpi_ec_params *params;
static char *ec_ids[] = { "PNP0C09", NULL }; static char *ec_ids[] = { "PNP0C09", NULL };
@ -362,11 +359,12 @@ acpi_ec_probe(device_t dev)
* duplicate probe. * duplicate probe.
*/ */
ret = ENXIO; ret = ENXIO;
params = NULL; ecdt = 0;
buf.Pointer = NULL; buf.Pointer = NULL;
buf.Length = ACPI_ALLOCATE_BUFFER; buf.Length = ACPI_ALLOCATE_BUFFER;
if (DEV_ECDT(dev)) { params = acpi_get_private(dev);
params = acpi_get_private(dev); if (params != NULL) {
ecdt = 1;
ret = 0; ret = 0;
} else if (!acpi_disabled("ec") && } else if (!acpi_disabled("ec") &&
ACPI_ID_PROBE(device_get_parent(dev), dev, ec_ids)) { ACPI_ID_PROBE(device_get_parent(dev), dev, ec_ids)) {
@ -439,7 +437,7 @@ acpi_ec_probe(device_t dev)
if (ret == 0) { if (ret == 0) {
snprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s", snprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s",
params->gpe_bit, (params->glk) ? ", GLK" : "", params->gpe_bit, (params->glk) ? ", GLK" : "",
DEV_ECDT(dev) ? ", ECDT" : ""); ecdt ? ", ECDT" : "");
device_set_desc_copy(dev, desc); device_set_desc_copy(dev, desc);
} }

View File

@ -61,8 +61,6 @@ static void acpi_hpet_test(struct acpi_hpet_softc *sc);
static char *hpet_ids[] = { "PNP0103", NULL }; static char *hpet_ids[] = { "PNP0103", NULL };
#define DEV_HPET(x) (acpi_get_magic(x) == (uintptr_t)&acpi_hpet_devclass)
struct timecounter hpet_timecounter = { struct timecounter hpet_timecounter = {
.tc_get_timecount = hpet_get_timecount, .tc_get_timecount = hpet_get_timecount,
.tc_counter_mask = ~0u, .tc_counter_mask = ~0u,
@ -133,8 +131,6 @@ acpi_hpet_identify(driver_t *driver, device_t parent)
return; return;
} }
/* Record a magic value so we can detect this device later. */
acpi_set_magic(child, (uintptr_t)&acpi_hpet_devclass);
bus_set_resource(child, SYS_RES_MEMORY, 0, hpet->Address.Address, bus_set_resource(child, SYS_RES_MEMORY, 0, hpet->Address.Address,
HPET_MEM_WIDTH); HPET_MEM_WIDTH);
} }
@ -146,7 +142,7 @@ acpi_hpet_probe(device_t dev)
if (acpi_disabled("hpet")) if (acpi_disabled("hpet"))
return (ENXIO); return (ENXIO);
if (!DEV_HPET(dev) && if (acpi_get_handle(dev) != NULL &&
(ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids) == NULL || (ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids) == NULL ||
device_get_unit(dev) != 0)) device_get_unit(dev) != 0))
return (ENXIO); return (ENXIO);

View File

@ -88,7 +88,6 @@ struct acpi_softc {
struct acpi_device { struct acpi_device {
/* ACPI ivars */ /* ACPI ivars */
ACPI_HANDLE ad_handle; ACPI_HANDLE ad_handle;
uintptr_t ad_magic;
void *ad_private; void *ad_private;
int ad_flags; int ad_flags;
@ -224,7 +223,7 @@ extern int acpi_quirks;
* attach to ACPI. * attach to ACPI.
*/ */
#define ACPI_IVAR_HANDLE 0x100 #define ACPI_IVAR_HANDLE 0x100
#define ACPI_IVAR_MAGIC 0x101 #define ACPI_IVAR_UNUSED 0x101 /* Unused/reserved. */
#define ACPI_IVAR_PRIVATE 0x102 #define ACPI_IVAR_PRIVATE 0x102
#define ACPI_IVAR_FLAGS 0x103 #define ACPI_IVAR_FLAGS 0x103
@ -250,7 +249,6 @@ static __inline void varp ## _set_ ## var(device_t dev, type t) \
} }
__ACPI_BUS_ACCESSOR(acpi, handle, ACPI, HANDLE, ACPI_HANDLE) __ACPI_BUS_ACCESSOR(acpi, handle, ACPI, HANDLE, ACPI_HANDLE)
__ACPI_BUS_ACCESSOR(acpi, magic, ACPI, MAGIC, uintptr_t)
__ACPI_BUS_ACCESSOR(acpi, private, ACPI, PRIVATE, void *) __ACPI_BUS_ACCESSOR(acpi, private, ACPI, PRIVATE, void *)
__ACPI_BUS_ACCESSOR(acpi, flags, ACPI, FLAGS, int) __ACPI_BUS_ACCESSOR(acpi, flags, ACPI, FLAGS, int)