diff options
author | Takanori Watanabe <takawata@FreeBSD.org> | 2018-10-26 00:05:46 +0000 |
---|---|---|
committer | Takanori Watanabe <takawata@FreeBSD.org> | 2018-10-26 00:05:46 +0000 |
commit | 5efca36fbda65afe7726d685dcc43a707ef76447 (patch) | |
tree | 582c853f814a4acc5c72bf510ec4ba7b180e75c3 | |
parent | fef4815e9af171e64f6156bf7b97bb7424b8a22b (diff) |
Notes
35 files changed, 250 insertions, 177 deletions
diff --git a/sys/dev/acpi_support/acpi_asus.c b/sys/dev/acpi_support/acpi_asus.c index 86cd8b7bf69b9..5111146b0a3e5 100644 --- a/sys/dev/acpi_support/acpi_asus.c +++ b/sys/dev/acpi_support/acpi_asus.c @@ -549,15 +549,16 @@ acpi_asus_probe(device_t dev) ACPI_OBJECT Arg, *Obj; ACPI_OBJECT_LIST Args; static char *asus_ids[] = { "ATK0100", "ASUS010", NULL }; + int rv; char *rstr; ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); if (acpi_disabled("asus")) return (ENXIO); - rstr = ACPI_ID_PROBE(device_get_parent(dev), dev, asus_ids); - if (rstr == NULL) { - return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, asus_ids, &rstr); + if (rv > 0) { + return (rv); } sc = device_get_softc(dev); @@ -595,7 +596,7 @@ acpi_asus_probe(device_t dev) sc->model = &acpi_samsung_models[0]; device_set_desc(dev, "Samsung P30 Laptop Extras"); AcpiOsFree(Buf.Pointer); - return (0); + return (rv); } /* EeePC */ @@ -603,7 +604,7 @@ acpi_asus_probe(device_t dev) sc->model = &acpi_eeepc_models[0]; device_set_desc(dev, "ASUS EeePC"); AcpiOsFree(Buf.Pointer); - return (0); + return (rv); } } @@ -627,7 +628,7 @@ good: sbuf_delete(sb); AcpiOsFree(Buf.Pointer); - return (0); + return (rv); } /* diff --git a/sys/dev/acpi_support/acpi_fujitsu.c b/sys/dev/acpi_support/acpi_fujitsu.c index 6f96bc5ce4434..98fd1fe0e36a7 100644 --- a/sys/dev/acpi_support/acpi_fujitsu.c +++ b/sys/dev/acpi_support/acpi_fujitsu.c @@ -228,16 +228,15 @@ acpi_fujitsu_probe(device_t dev) { char *name; char buffer[64]; + int rv; - name = ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids); - if (acpi_disabled("fujitsu") || name == NULL || - device_get_unit(dev) > 1) + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, fujitsu_ids, &name); + if (acpi_disabled("fujitsu") || rv > 0 || device_get_unit(dev) > 1) return (ENXIO); - sprintf(buffer, "Fujitsu Function Hotkeys %s", name); device_set_desc_copy(dev, buffer); - return (0); + return (rv); } static int diff --git a/sys/dev/acpi_support/acpi_ibm.c b/sys/dev/acpi_support/acpi_ibm.c index d5f77475d81e4..c6e7c3c75969e 100644 --- a/sys/dev/acpi_support/acpi_ibm.c +++ b/sys/dev/acpi_support/acpi_ibm.c @@ -411,14 +411,17 @@ acpi_ibm_mic_led_set (struct acpi_ibm_softc *sc, int arg) static int acpi_ibm_probe(device_t dev) { + int rv; + if (acpi_disabled("ibm") || - ACPI_ID_PROBE(device_get_parent(dev), dev, ibm_ids) == NULL || device_get_unit(dev) != 0) return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, ibm_ids, NULL); - device_set_desc(dev, "IBM ThinkPad ACPI Extras"); - - return (0); + if (rv <= 0) + device_set_desc(dev, "IBM ThinkPad ACPI Extras"); + + return (rv); } static int diff --git a/sys/dev/acpi_support/acpi_panasonic.c b/sys/dev/acpi_support/acpi_panasonic.c index 4a90256e46b9b..87683aee7b47f 100644 --- a/sys/dev/acpi_support/acpi_panasonic.c +++ b/sys/dev/acpi_support/acpi_panasonic.c @@ -137,14 +137,16 @@ static int acpi_panasonic_probe(device_t dev) { static char *mat_ids[] = { "MAT0019", NULL }; - + int rv; + if (acpi_disabled("panasonic") || - ACPI_ID_PROBE(device_get_parent(dev), dev, mat_ids) == NULL || device_get_unit(dev) != 0) return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, mat_ids, NULL); - device_set_desc(dev, "Panasonic Notebook Hotkeys"); - return (0); + if (rv <= 0) + device_set_desc(dev, "Panasonic Notebook Hotkeys"); + return (rv); } static int diff --git a/sys/dev/acpi_support/acpi_rapidstart.c b/sys/dev/acpi_support/acpi_rapidstart.c index f28414cef3717..4b896338db80e 100644 --- a/sys/dev/acpi_support/acpi_rapidstart.c +++ b/sys/dev/acpi_support/acpi_rapidstart.c @@ -62,14 +62,16 @@ static char *rapidstart_ids[] = {"INT3392", NULL}; static int acpi_rapidstart_probe(device_t dev) { + int rv; + if (acpi_disabled("rapidstart") || - ACPI_ID_PROBE(device_get_parent(dev), dev, rapidstart_ids) == NULL || device_get_unit(dev) != 0) return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, rapidstart_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "Intel Rapid Start ACPI device"); - device_set_desc(dev, "Intel Rapid Start ACPI device"); - - return (0); + return (rv); } diff --git a/sys/dev/acpi_support/acpi_sony.c b/sys/dev/acpi_support/acpi_sony.c index fc5c6519e4b52..97c35d58f412c 100644 --- a/sys/dev/acpi_support/acpi_sony.c +++ b/sys/dev/acpi_support/acpi_sony.c @@ -114,11 +114,11 @@ static char *sny_id[] = {"SNY5001", NULL}; static int acpi_sony_probe(device_t dev) { - int ret = ENXIO; + int ret; - if (ACPI_ID_PROBE(device_get_parent(dev), dev, sny_id)) { + ret = ACPI_ID_PROBE(device_get_parent(dev), dev, sny_id, NULL); + if (ret <= 0) { device_set_desc(dev, "Sony notebook controller"); - ret = 0; } return (ret); } diff --git a/sys/dev/acpi_support/acpi_toshiba.c b/sys/dev/acpi_support/acpi_toshiba.c index 8d5a9cef535de..612a12ea621d9 100644 --- a/sys/dev/acpi_support/acpi_toshiba.c +++ b/sys/dev/acpi_support/acpi_toshiba.c @@ -220,14 +220,15 @@ static int acpi_toshiba_probe(device_t dev) { static char *tosh_ids[] = { "TOS6200", "TOS6207", "TOS6208", NULL }; + int rv; if (acpi_disabled("toshiba") || - ACPI_ID_PROBE(device_get_parent(dev), dev, tosh_ids) == NULL || device_get_unit(dev) != 0) return (ENXIO); - - device_set_desc(dev, "Toshiba HCI Extras"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, tosh_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "Toshiba HCI Extras"); + return (rv); } static int @@ -543,15 +544,17 @@ static int acpi_toshiba_video_probe(device_t dev) { static char *vid_ids[] = { "TOS6201", NULL }; + int rv; if (acpi_disabled("toshiba") || - ACPI_ID_PROBE(device_get_parent(dev), dev, vid_ids) == NULL || device_get_unit(dev) != 0) return (ENXIO); device_quiet(dev); - device_set_desc(dev, "Toshiba Video"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, vid_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "Toshiba Video"); + return (rv); } static int diff --git a/sys/dev/acpi_support/acpi_wmi.c b/sys/dev/acpi_support/acpi_wmi.c index d8185b9f067e8..bda7137881a73 100644 --- a/sys/dev/acpi_support/acpi_wmi.c +++ b/sys/dev/acpi_support/acpi_wmi.c @@ -208,12 +208,15 @@ static char *wmi_ids[] = {"PNP0C14", NULL}; static int acpi_wmi_probe(device_t dev) { - if (acpi_disabled("wmi") || - ACPI_ID_PROBE(device_get_parent(dev), dev, wmi_ids) == NULL) + int rv; + + if (acpi_disabled("wmi")) return (ENXIO); - device_set_desc(dev, "ACPI-WMI mapping"); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, wmi_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "ACPI-WMI mapping"); - return (0); + return (rv); } /* diff --git a/sys/dev/acpi_support/atk0110.c b/sys/dev/acpi_support/atk0110.c index ee6abd15716d8..e6dd8e86cf536 100644 --- a/sys/dev/acpi_support/atk0110.c +++ b/sys/dev/acpi_support/atk0110.c @@ -122,11 +122,13 @@ static char* aibs_hids[] = { static int aibs_probe(device_t dev) { - if (acpi_disabled("aibs") || - ACPI_ID_PROBE(device_get_parent(dev), dev, aibs_hids) == NULL) - return (ENXIO); + int rv; - device_set_desc(dev, "ASUSTeK AI Booster (ACPI ASOC ATK0110)"); + if (acpi_disabled("aibs")) + return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, aibs_hids, NULL); + if (rv <= 0 ) + device_set_desc(dev, "ASUSTeK AI Booster (ACPI ASOC ATK0110)"); return (0); } diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index bed7ecd411c76..45ebf2e9eae9b 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -140,7 +140,7 @@ static void acpi_delete_resource(device_t bus, device_t child, int type, int rid); static uint32_t acpi_isa_get_logicalid(device_t dev); static int acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count); -static char *acpi_device_id_probe(device_t bus, device_t dev, char **ids); +static int acpi_device_id_probe(device_t bus, device_t dev, char **ids, char **match); static ACPI_STATUS acpi_device_eval_obj(device_t bus, device_t dev, ACPI_STRING pathname, ACPI_OBJECT_LIST *parameters, ACPI_BUFFER *ret); @@ -1183,7 +1183,7 @@ acpi_sysres_alloc(device_t dev) if (device_get_children(dev, &children, &child_count) != 0) return (ENXIO); for (i = 0; i < child_count; i++) { - if (ACPI_ID_PROBE(dev, children[i], sysres_ids) != NULL) + if (ACPI_ID_PROBE(dev, children[i], sysres_ids, NULL) <= 0) device_probe_and_attach(children[i]); } free(children, M_TEMP); @@ -1242,7 +1242,7 @@ acpi_reserve_resources(device_t dev) rl = &ad->ad_rl; /* Don't reserve system resources. */ - if (ACPI_ID_PROBE(dev, children[i], sysres_ids) != NULL) + if (ACPI_ID_PROBE(dev, children[i], sysres_ids, NULL) <= 0) continue; STAILQ_FOREACH(rle, rl, link) { @@ -1292,7 +1292,8 @@ acpi_set_resource(device_t dev, device_t child, int type, int rid, rman_res_t end; /* Ignore IRQ resources for PCI link devices. */ - if (type == SYS_RES_IRQ && ACPI_ID_PROBE(dev, child, pcilink_ids) != NULL) + if (type == SYS_RES_IRQ && + ACPI_ID_PROBE(dev, child, pcilink_ids, NULL) <= 0) return (0); /* @@ -1335,7 +1336,7 @@ acpi_set_resource(device_t dev, device_t child, int type, int rid, return (0); /* Don't reserve system resources. */ - if (ACPI_ID_PROBE(dev, child, sysres_ids) != NULL) + if (ACPI_ID_PROBE(dev, child, sysres_ids, NULL) <= 0) return (0); /* @@ -1640,26 +1641,34 @@ acpi_isa_get_compatid(device_t dev, uint32_t *cids, int count) return_VALUE (valid); } -static char * -acpi_device_id_probe(device_t bus, device_t dev, char **ids) +static int +acpi_device_id_probe(device_t bus, device_t dev, char **ids, char **match) { ACPI_HANDLE h; ACPI_OBJECT_TYPE t; + int rv; int i; h = acpi_get_handle(dev); if (ids == NULL || h == NULL) - return (NULL); + return (ENXIO); t = acpi_get_type(dev); if (t != ACPI_TYPE_DEVICE && t != ACPI_TYPE_PROCESSOR) - return (NULL); + return (ENXIO); /* Try to match one of the array of IDs with a HID or CID. */ for (i = 0; ids[i] != NULL; i++) { - if (acpi_MatchHid(h, ids[i])) - return (ids[i]); + rv = acpi_MatchHid(h, ids[i]); + if (rv == ACPI_MATCHHID_NOMATCH) + continue; + + if (match != NULL) { + *match = ids[i]; + } + return ((rv == ACPI_MATCHHID_HID)? + BUS_PROBE_DEFAULT : BUS_PROBE_LOW_PRIORITY); } - return (NULL); + return (ENXIO); } static ACPI_STATUS @@ -2285,8 +2294,11 @@ acpi_has_hid(ACPI_HANDLE h) /* * Match a HID string against a handle + * returns ACPI_MATCHHID_HID if _HID match + * ACPI_MATCHHID_CID if _CID match and not _HID match. + * ACPI_MATCHHID_NOMATCH=0 if no match. */ -BOOLEAN +int acpi_MatchHid(ACPI_HANDLE h, const char *hid) { ACPI_DEVICE_INFO *devinfo; @@ -2295,16 +2307,16 @@ acpi_MatchHid(ACPI_HANDLE h, const char *hid) if (hid == NULL || h == NULL || ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo))) - return (FALSE); + return (ACPI_MATCHHID_NOMATCH); ret = FALSE; if ((devinfo->Valid & ACPI_VALID_HID) != 0 && strcmp(hid, devinfo->HardwareId.String) == 0) - ret = TRUE; + ret = ACPI_MATCHHID_HID; else if ((devinfo->Valid & ACPI_VALID_CID) != 0) for (i = 0; i < devinfo->CompatibleIdList.Count; i++) { if (strcmp(hid, devinfo->CompatibleIdList.Ids[i].String) == 0) { - ret = TRUE; + ret = ACPI_MATCHHID_CID; break; } } diff --git a/sys/dev/acpica/acpi_acad.c b/sys/dev/acpica/acpi_acad.c index 4c9dc19e95a7d..18a36013809ff 100644 --- a/sys/dev/acpica/acpi_acad.c +++ b/sys/dev/acpica/acpi_acad.c @@ -142,13 +142,14 @@ static int acpi_acad_probe(device_t dev) { static char *acad_ids[] = { "ACPI0003", NULL }; + int rv; - if (acpi_disabled("acad") || - ACPI_ID_PROBE(device_get_parent(dev), dev, acad_ids) == NULL) + if (acpi_disabled("acad")) return (ENXIO); - - device_set_desc(dev, "AC Adapter"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, acad_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "AC Adapter"); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_button.c b/sys/dev/acpica/acpi_button.c index 72bf5b1945cb9..2e9e21e471ecf 100644 --- a/sys/dev/acpica/acpi_button.c +++ b/sys/dev/acpica/acpi_button.c @@ -98,11 +98,14 @@ acpi_button_probe(device_t dev) { struct acpi_button_softc *sc; char *str; + int rv; - if (acpi_disabled("button") || - (str = ACPI_ID_PROBE(device_get_parent(dev), dev, btn_ids)) == NULL) + if (acpi_disabled("button")) return (ENXIO); - + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, btn_ids, &str); + if (rv > 0) + return (ENXIO); + sc = device_get_softc(dev); if (strcmp(str, "PNP0C0C") == 0) { device_set_desc(dev, "Power Button"); @@ -120,7 +123,7 @@ acpi_button_probe(device_t dev) sc->fixed = 1; } - return (0); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_cmbat.c b/sys/dev/acpica/acpi_cmbat.c index b4835bb66cda8..a029a2c7b4734 100644 --- a/sys/dev/acpica/acpi_cmbat.c +++ b/sys/dev/acpica/acpi_cmbat.c @@ -116,13 +116,14 @@ static int acpi_cmbat_probe(device_t dev) { static char *cmbat_ids[] = { "PNP0C0A", NULL }; - - if (acpi_disabled("cmbat") || - ACPI_ID_PROBE(device_get_parent(dev), dev, cmbat_ids) == NULL) + int rv; + + if (acpi_disabled("cmbat")) return (ENXIO); - - device_set_desc(dev, "ACPI Control Method Battery"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, cmbat_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "ACPI Control Method Battery"); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_container.c b/sys/dev/acpica/acpi_container.c index 26855bd732d75..0a4b123c5303c 100644 --- a/sys/dev/acpica/acpi_container.c +++ b/sys/dev/acpica/acpi_container.c @@ -98,13 +98,14 @@ static int acpi_syscont_probe(device_t dev) { static char *syscont_ids[] = { "ACPI0004", "PNP0A05", "PNP0A06", NULL }; + int rv; - if (acpi_disabled("syscontainer") || - ACPI_ID_PROBE(device_get_parent(dev), dev, syscont_ids) == NULL) + if (acpi_disabled("syscontainer")) return (ENXIO); - - device_set_desc(dev, "System Container"); - return (BUS_PROBE_DEFAULT); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, syscont_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "System Container"); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 4d7573d9b7d28..46972630d5855 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -252,7 +252,7 @@ acpi_cpu_probe(device_t dev) if (type != ACPI_TYPE_PROCESSOR && type != ACPI_TYPE_DEVICE) return (ENXIO); if (type == ACPI_TYPE_DEVICE && - ACPI_ID_PROBE(device_get_parent(dev), dev, cpudev_ids) == NULL) + ACPI_ID_PROBE(device_get_parent(dev), dev, cpudev_ids, NULL) >= 0) return (ENXIO); handle = acpi_get_handle(dev); diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index 48a347d29e3a4..199aa8be31dff 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -362,7 +362,10 @@ acpi_ec_probe(device_t dev) if (params != NULL) { ecdt = 1; ret = 0; - } else if (ACPI_ID_PROBE(device_get_parent(dev), dev, ec_ids)) { + } else { + ret = ACPI_ID_PROBE(device_get_parent(dev), dev, ec_ids, NULL); + if (ret > 0) + goto out; params = malloc(sizeof(struct acpi_ec_params), M_TEMP, M_WAITOK | M_ZERO); h = acpi_get_handle(dev); @@ -422,14 +425,14 @@ acpi_ec_probe(device_t dev) * this device. */ peer = devclass_get_device(acpi_ec_devclass, params->uid); - if (peer == NULL || !device_is_alive(peer)) - ret = 0; - else + if (peer != NULL && device_is_alive(peer)){ + ret = ENXIO; device_disable(dev); + } } out: - if (ret == 0) { + if (ret <= 0) { snprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s", params->gpe_bit, (params->glk) ? ", GLK" : "", ecdt ? ", ECDT" : ""); diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index 305a55f9f3edf..4fca980f8c3bd 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -450,16 +450,15 @@ hpet_identify(driver_t *driver, device_t parent) static int hpet_probe(device_t dev) { - ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__); + int rv; + ACPI_FUNCTION_TRACE((char *)(uintptr_t) __func__); if (acpi_disabled("hpet") || acpi_hpet_disabled) return (ENXIO); - if (acpi_get_handle(dev) != NULL && - ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids) == NULL) - return (ENXIO); - - device_set_desc(dev, "High Precision Event Timer"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, hpet_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "High Precision Event Timer"); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_if.m b/sys/dev/acpica/acpi_if.m index f0a68e3870d8d..041e71754d7c2 100644 --- a/sys/dev/acpica/acpi_if.m +++ b/sys/dev/acpica/acpi_if.m @@ -78,12 +78,19 @@ CODE { # # char **ids: array of ID strings to consider # -# Returns: ID string matched or NULL if no match +# char **match: Pointer to store ID string matched or NULL if no match +# pass NULL if not needed. # -METHOD char * id_probe { +# Returns: BUS_PROBE_DEFAULT if _HID match +# BUS_PROBE_LOW_PRIORITY if _CID match and not _HID match +# ENXIO if no match. +# + +METHOD int id_probe { device_t bus; device_t dev; char **ids; + char **match; } DEFAULT acpi_generic_id_probe; # diff --git a/sys/dev/acpica/acpi_isab.c b/sys/dev/acpica/acpi_isab.c index 3febea7ed76bd..f37a55cd5dc90 100644 --- a/sys/dev/acpica/acpi_isab.c +++ b/sys/dev/acpica/acpi_isab.c @@ -92,14 +92,15 @@ static int acpi_isab_probe(device_t dev) { static char *isa_ids[] = { "PNP0A05", "PNP0A06", NULL }; - + int rv; + if (acpi_disabled("isab") || - ACPI_ID_PROBE(device_get_parent(dev), dev, isa_ids) == NULL || devclass_get_device(isab_devclass, 0) != dev) return (ENXIO); - - device_set_desc(dev, "ACPI Generic ISA bridge"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, isa_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "ACPI Generic ISA bridge"); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_lid.c b/sys/dev/acpica/acpi_lid.c index 9ffd1a3a36aa7..b7e6699214adc 100644 --- a/sys/dev/acpica/acpi_lid.c +++ b/sys/dev/acpica/acpi_lid.c @@ -88,13 +88,14 @@ static int acpi_lid_probe(device_t dev) { static char *lid_ids[] = { "PNP0C0D", NULL }; + int rv; - if (acpi_disabled("lid") || - ACPI_ID_PROBE(device_get_parent(dev), dev, lid_ids) == NULL) + if (acpi_disabled("lid")) return (ENXIO); - - device_set_desc(dev, "Control Method Lid Switch"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, lid_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "Control Method Lid Switch"); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_pci_link.c b/sys/dev/acpica/acpi_pci_link.c index 3b853b6583849..2ce7e691d266e 100644 --- a/sys/dev/acpica/acpi_pci_link.c +++ b/sys/dev/acpica/acpi_pci_link.c @@ -146,15 +146,18 @@ static int acpi_pci_link_probe(device_t dev) { char descr[28], name[12]; + int rv; /* * We explicitly do not check _STA since not all systems set it to * sensible values. */ - if (acpi_disabled("pci_link") || - ACPI_ID_PROBE(device_get_parent(dev), dev, pci_link_ids) == NULL) - return (ENXIO); - + if (acpi_disabled("pci_link")) + return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, pci_link_ids, NULL); + if (rv > 0) + return (rv); + if (ACPI_SUCCESS(acpi_short_name(acpi_get_handle(dev), name, sizeof(name)))) { snprintf(descr, sizeof(descr), "ACPI PCI Link %s", name); @@ -162,7 +165,7 @@ acpi_pci_link_probe(device_t dev) } else device_set_desc(dev, "ACPI PCI Link"); device_quiet(dev); - return (0); + return (rv); } static ACPI_STATUS diff --git a/sys/dev/acpica/acpi_resource.c b/sys/dev/acpica/acpi_resource.c index ca98875e3ec17..2ea79565bb623 100644 --- a/sys/dev/acpica/acpi_resource.c +++ b/sys/dev/acpica/acpi_resource.c @@ -696,14 +696,17 @@ static int acpi_sysres_probe(device_t dev) { static char *sysres_ids[] = { "PNP0C01", "PNP0C02", NULL }; + int rv; - if (acpi_disabled("sysresource") || - ACPI_ID_PROBE(device_get_parent(dev), dev, sysres_ids) == NULL) + if (acpi_disabled("sysresource")) return (ENXIO); - + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, sysres_ids, NULL); + if (rv > 0){ + return (rv); + } device_set_desc(dev, "System Resource"); device_quiet(dev); - return (BUS_PROBE_DEFAULT); + return (rv); } static int diff --git a/sys/dev/acpica/acpi_smbat.c b/sys/dev/acpica/acpi_smbat.c index af09f383b8435..718dc9f49f8fe 100644 --- a/sys/dev/acpica/acpi_smbat.c +++ b/sys/dev/acpica/acpi_smbat.c @@ -107,16 +107,18 @@ acpi_smbat_probe(device_t dev) { static char *smbat_ids[] = {"ACPI0001", "ACPI0005", NULL}; ACPI_STATUS status; + int rv; - if (acpi_disabled("smbat") || - ACPI_ID_PROBE(device_get_parent(dev), dev, smbat_ids) == NULL) + if (acpi_disabled("smbat")) return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, smbat_ids, NULL); + if (rv > 0) + return (rv); status = AcpiEvaluateObject(acpi_get_handle(dev), "_EC", NULL, NULL); if (ACPI_FAILURE(status)) return (ENXIO); - device_set_desc(dev, "ACPI Smart Battery"); - return (0); + return (rv); } static int diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 7e0f6cebd5fc0..15f00c4a08a06 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -371,7 +371,11 @@ int acpi_bus_alloc_gas(device_t dev, int *type, int *rid, u_int flags); void acpi_walk_subtables(void *first, void *end, acpi_subtable_handler *handler, void *arg); -BOOLEAN acpi_MatchHid(ACPI_HANDLE h, const char *hid); +int acpi_MatchHid(ACPI_HANDLE h, const char *hid); +#define ACPI_MATCHHID_NOMATCH 0 +#define ACPI_MATCHHID_HID 1 +#define ACPI_MATCHHID_CID 2 + struct acpi_parse_resource_set { void (*set_init)(device_t dev, void *arg, void **context); diff --git a/sys/dev/amdgpio/amdgpio.c b/sys/dev/amdgpio/amdgpio.c index bbcf9e8b663e8..eba571551ce5e 100644 --- a/sys/dev/amdgpio/amdgpio.c +++ b/sys/dev/amdgpio/amdgpio.c @@ -344,13 +344,16 @@ static int amdgpio_probe(device_t dev) { static char *gpio_ids[] = { "AMD0030", "AMDI0030", NULL }; - - if (acpi_disabled("gpio") || - ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids) == NULL) - return (ENXIO); - - device_set_desc(dev, "AMD GPIO Controller"); - return (0); + int rv; + + if (acpi_disabled("gpio")) + return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids, NULL); + + if (rv <= 0) + device_set_desc(dev, "AMD GPIO Controller"); + + return (rv); } static int diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c index 88e485fdeb97d..8f657ac1972b8 100644 --- a/sys/dev/asmc/asmc.c +++ b/sys/dev/asmc/asmc.c @@ -374,11 +374,13 @@ static int asmc_probe(device_t dev) { struct asmc_model *model; + int rv; if (resource_disabled("asmc", 0)) return (ENXIO); - if (ACPI_ID_PROBE(device_get_parent(dev), dev, asmc_ids) == NULL) - return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, asmc_ids, NULL); + if (rv > 0) + return (rv); model = asmc_match(dev); if (!model) { @@ -387,7 +389,7 @@ asmc_probe(device_t dev) } device_set_desc(dev, model->smc_desc); - return (BUS_PROBE_DEFAULT); + return (rv); } static int diff --git a/sys/dev/fdc/fdc_acpi.c b/sys/dev/fdc/fdc_acpi.c index 1adebe845304b..6da5bf135b4a1 100644 --- a/sys/dev/fdc/fdc_acpi.c +++ b/sys/dev/fdc/fdc_acpi.c @@ -81,16 +81,18 @@ fdc_acpi_probe(device_t dev) { device_t bus; static char *fdc_ids[] = { "PNP0700", "PNP0701", NULL }; + int rv; bus = device_get_parent(dev); - if (ACPI_ID_PROBE(bus, dev, fdc_ids) == NULL) - return (ENXIO); + rv = ACPI_ID_PROBE(bus, dev, fdc_ids, NULL); + if (rv > 0) + return (rv); if (ACPI_SUCCESS(ACPI_EVALUATE_OBJECT(bus, dev, "_FDE", NULL, NULL))) device_set_desc(dev, "floppy drive controller (FDE)"); else device_set_desc(dev, "floppy drive controller"); - return (0); + return (rv); } static int diff --git a/sys/dev/gpio/bytgpio.c b/sys/dev/gpio/bytgpio.c index 2da58defffc42..0727f767c9206 100644 --- a/sys/dev/gpio/bytgpio.c +++ b/sys/dev/gpio/bytgpio.c @@ -541,13 +541,14 @@ static int bytgpio_probe(device_t dev) { static char *gpio_ids[] = { "INT33FC", NULL }; + int rv; - if (acpi_disabled("gpio") || - ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids) == NULL) - return (ENXIO); - - device_set_desc(dev, "Intel Baytrail GPIO Controller"); - return (0); + if (acpi_disabled("gpio")) + return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "Intel Baytrail GPIO Controller"); + return (rv); } static int diff --git a/sys/dev/gpio/chvgpio.c b/sys/dev/gpio/chvgpio.c index ed682abdd91fd..7b82036873222 100644 --- a/sys/dev/gpio/chvgpio.c +++ b/sys/dev/gpio/chvgpio.c @@ -343,12 +343,14 @@ static char *chvgpio_hids[] = { static int chvgpio_probe(device_t dev) { - if (acpi_disabled("chvgpio") || - ACPI_ID_PROBE(device_get_parent(dev), dev, chvgpio_hids) == NULL) + int rv; + + if (acpi_disabled("chvgpio")) return (ENXIO); - - device_set_desc(dev, "Intel Cherry View GPIO"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, chvgpio_hids, NULL); + if (rv <= 0) + device_set_desc(dev, "Intel Cherry View GPIO"); + return (rv); } static int diff --git a/sys/dev/hyperv/vmbus/vmbus_res.c b/sys/dev/hyperv/vmbus/vmbus_res.c index 164ebeb9175ed..fba5a732ca588 100644 --- a/sys/dev/hyperv/vmbus/vmbus_res.c +++ b/sys/dev/hyperv/vmbus/vmbus_res.c @@ -73,14 +73,15 @@ static int vmbus_res_probe(device_t dev) { char *id[] = { "VMBUS", NULL }; - - if (ACPI_ID_PROBE(device_get_parent(dev), dev, id) == NULL || - device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV || + int rv; + + if (device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV || (hyperv_features & CPUID_HV_MSR_SYNIC) == 0) return (ENXIO); - - device_set_desc(dev, "Hyper-V Vmbus Resource"); - return (BUS_PROBE_DEFAULT); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, id, NULL); + if (rv <= 0) + device_set_desc(dev, "Hyper-V Vmbus Resource"); + return (rv); } static int diff --git a/sys/dev/ichiic/ig4_acpi.c b/sys/dev/ichiic/ig4_acpi.c index 2a2e633cc3a8f..56b0df6f3fbdd 100644 --- a/sys/dev/ichiic/ig4_acpi.c +++ b/sys/dev/ichiic/ig4_acpi.c @@ -70,21 +70,23 @@ ig4iic_acpi_probe(device_t dev) { ig4iic_softc_t *sc; char *hid; - + int rv; sc = device_get_softc(dev); if (acpi_disabled("ig4iic")) return (ENXIO); - - hid = ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids); - if (hid == NULL) - return (ENXIO); - - if (strcmp("AMDI0010", hid) == 0) - sc->access_intr_mask = 1; - - device_set_desc(dev, "Designware I2C Controller"); - return (0); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, ig4iic_ids, &hid); + if (rv > 0){ + return (rv); + } + + if (strcmp("AMDI0010", hid) == 0) + sc->access_intr_mask = 1; + + + if (rv <= 0) + device_set_desc(dev, "Designware I2C Controller"); + return (rv); } static int diff --git a/sys/dev/intel/spi.c b/sys/dev/intel/spi.c index e9b9bfc46fb0c..b11fa468c0567 100644 --- a/sys/dev/intel/spi.c +++ b/sys/dev/intel/spi.c @@ -423,13 +423,14 @@ static int intelspi_probe(device_t dev) { static char *gpio_ids[] = { "80860F0E", NULL }; - - if (acpi_disabled("spi") || - ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids) == NULL) - return (ENXIO); - - device_set_desc(dev, "Intel SPI Controller"); - return (0); + int rv; + + if (acpi_disabled("spi") ) + return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, gpio_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "Intel SPI Controller"); + return (rv); } static int diff --git a/sys/dev/ipmi/ipmi_acpi.c b/sys/dev/ipmi/ipmi_acpi.c index c00d782dc9744..7c34f49075aff 100644 --- a/sys/dev/ipmi/ipmi_acpi.c +++ b/sys/dev/ipmi/ipmi_acpi.c @@ -61,17 +61,18 @@ int ipmi_acpi_probe(device_t dev) { static char *ipmi_ids[] = {"IPI0001", NULL}; + int rv; if (ipmi_attached) return (EBUSY); - if (acpi_disabled("ipmi") || - ACPI_ID_PROBE(device_get_parent(dev), dev, ipmi_ids) == NULL) + if (acpi_disabled("ipmi")) return (ENXIO); + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, ipmi_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "IPMI System Interface"); - device_set_desc(dev, "IPMI System Interface"); - - return (0); + return (rv); } static int diff --git a/sys/dev/sdhci/sdhci_acpi.c b/sys/dev/sdhci/sdhci_acpi.c index c202ba054cfcf..39dac3e5d890d 100644 --- a/sys/dev/sdhci/sdhci_acpi.c +++ b/sys/dev/sdhci/sdhci_acpi.c @@ -192,13 +192,14 @@ sdhci_acpi_write_multi_4(device_t dev, struct sdhci_slot *slot __unused, static const struct sdhci_acpi_device * sdhci_acpi_find_device(device_t dev) { - const char *hid; + char *hid; int i, uid; ACPI_HANDLE handle; ACPI_STATUS status; + int rv; - hid = ACPI_ID_PROBE(device_get_parent(dev), dev, sdhci_ids); - if (hid == NULL) + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, sdhci_ids, &hid); + if (rv > 0) return (NULL); handle = acpi_get_handle(dev); diff --git a/sys/dev/tpm/tpm_acpi.c b/sys/dev/tpm/tpm_acpi.c index b16dd234b3dfb..496d0e8173e3d 100644 --- a/sys/dev/tpm/tpm_acpi.c +++ b/sys/dev/tpm/tpm_acpi.c @@ -52,12 +52,13 @@ char *tpm_ids[] = {"ATM1200", "BCM0102", "INTC0102", "SNO3504", "WEC1000", static int tpm_acpi_probe(device_t dev) { - if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpm_ids) != NULL) { - device_set_desc(dev, "Trusted Platform Module"); - return BUS_PROBE_DEFAULT; - } + int rv; - return ENXIO; + rv = ACPI_ID_PROBE(device_get_parent(dev), dev, tpm_ids, NULL); + if (rv <= 0) + device_set_desc(dev, "Trusted Platform Module"); + + return (rv); } static device_method_t tpm_acpi_methods[] = { |