/** * ide_acpi_hwif_get_handle - Get ACPI object handle for a given hwif * @hwif: device to locate * * Retrieves the object handle for a given hwif. * * Returns handle on success, 0 on error. */ static acpi_handle ide_acpi_hwif_get_handle(ide_hwif_t *hwif) { struct device *dev = hwif->gendev.parent; acpi_handle uninitialized_var(dev_handle); acpi_integer pcidevfn; acpi_handle chan_handle; int err; DEBPRINT("ENTER: device %s\n", hwif->name); if (!dev) { DEBPRINT("no PCI device for %s\n", hwif->name); return NULL; } err = ide_get_dev_handle(dev, &dev_handle, &pcidevfn); if (err < 0) { DEBPRINT("ide_get_dev_handle failed (%d)\n", err); return NULL; } /* get child objects of dev_handle == channel objects, * + _their_ children == drive objects */ /* channel is hwif->channel */ chan_handle = acpi_get_child(dev_handle, hwif->channel); DEBPRINT("chan adr=%d: handle=0x%p\n", hwif->channel, chan_handle); return chan_handle; }
static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) { struct usb_device *udev; struct device *parent; acpi_handle *parent_handle; if (!is_usb_device(dev)) return -ENODEV; udev = to_usb_device(dev); parent = dev->parent; parent_handle = DEVICE_ACPI_HANDLE(parent); if (!parent_handle) return -ENODEV; *handle = acpi_get_child(parent_handle, udev->portnum); if (!*handle) return -ENODEV; /* * PLD will tell us whether a port is removable to the user or * not. If we don't get an answer from PLD (it's not present * or it's malformed) then try to infer it from UPC. If a * device isn't connectable then it's probably not removable. */ if (usb_acpi_check_pld(udev, *handle) != 0) usb_acpi_check_upc(udev, *handle); return 0; }
void ata_acpi_associate_sata_port(struct ata_port *ap) { WARN_ON(!(ap->flags & ATA_FLAG_ACPI_SATA)); if (!sata_pmp_attached(ap)) { u64 adr = SATA_ADR(ap->port_no, NO_PORT_MULT); ap->link.device->acpi_handle = acpi_get_child(ap->host->acpi_handle, adr); } else { struct ata_link *link; ap->link.device->acpi_handle = NULL; ata_for_each_link(link, ap, EDGE) { u64 adr = SATA_ADR(ap->port_no, link->pmp); link->device->acpi_handle = acpi_get_child(ap->host->acpi_handle, adr); } }
/* ACPI bus type */ static int pci_acpi_find_device(struct device *dev, acpi_handle *handle) { struct pci_dev * pci_dev; acpi_integer addr; pci_dev = to_pci_dev(dev); /* Please ref to ACPI spec for the syntax of _ADR */ addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn); *handle = acpi_get_child(DEVICE_ACPI_HANDLE(dev->parent), addr); if (!*handle) return -ENODEV; return 0; }
/** * ide_acpi_drive_get_handle - Get ACPI object handle for a given drive * @drive: device to locate * * Retrieves the object handle of a given drive. According to the ACPI * spec the drive is a child of the hwif. * * Returns handle on success, 0 on error. */ static acpi_handle ide_acpi_drive_get_handle(ide_drive_t *drive) { ide_hwif_t *hwif = HWIF(drive); int port; acpi_handle drive_handle; if (!hwif->acpidata) return NULL; if (!hwif->acpidata->obj_handle) return NULL; port = hwif->channel ? drive->dn - 2: drive->dn; DEBPRINT("ENTER: %s at channel#: %d port#: %d\n", drive->name, hwif->channel, port); /* TBD: could also check ACPI object VALID bits */ drive_handle = acpi_get_child(hwif->acpidata->obj_handle, port); DEBPRINT("drive %s handle 0x%p\n", drive->name, drive_handle); return drive_handle; }
static int usb_acpi_find_device(struct device *dev, acpi_handle *handle) { struct usb_device *udev; acpi_handle *parent_handle; int port_num; /* * In the ACPI DSDT table, only usb root hub and usb ports are * acpi device nodes. The hierarchy like following. * Device (EHC1) * Device (HUBN) * Device (PR01) * Device (PR11) * Device (PR12) * Device (PR13) * ... * So all binding process is divided into two parts. binding * root hub and usb ports. */ if (is_usb_device(dev)) { udev = to_usb_device(dev); if (udev->parent) { enum usb_port_connect_type type; /* * According usb port's connect type to set usb device's * removability. */ type = usb_get_hub_port_connect_type(udev->parent, udev->portnum); switch (type) { case USB_PORT_CONNECT_TYPE_HOT_PLUG: udev->removable = USB_DEVICE_REMOVABLE; break; case USB_PORT_CONNECT_TYPE_HARD_WIRED: udev->removable = USB_DEVICE_FIXED; break; default: udev->removable = USB_DEVICE_REMOVABLE_UNKNOWN; break; } return -ENODEV; } /* root hub's parent is the usb hcd. */ parent_handle = DEVICE_ACPI_HANDLE(dev->parent); *handle = acpi_get_child(parent_handle, udev->portnum); if (!*handle) return -ENODEV; return 0; } else if (is_usb_port(dev)) { sscanf(dev_name(dev), "port%d", &port_num); /* Get the struct usb_device point of port's hub */ udev = to_usb_device(dev->parent->parent); /* * The root hub ports' parent is the root hub. The non-root-hub * ports' parent is the parent hub port which the hub is * connected to. */ if (!udev->parent) { *handle = acpi_get_child(DEVICE_ACPI_HANDLE(&udev->dev), port_num); if (!*handle) return -ENODEV; } else { parent_handle = usb_get_hub_port_acpi_handle(udev->parent, udev->portnum); if (!parent_handle) return -ENODEV; *handle = acpi_get_child(parent_handle, port_num); if (!*handle) return -ENODEV; } usb_acpi_check_port_connect_type(udev, *handle, port_num); } else return -ENODEV; return 0; }