- int errno = pos->devdef.init_for(&pos->devdef, &device->dev);
- if (errno) {
- kappendf(KERROR "failed (e=%d)\n", errno);
- goto fail;
+ *more = 0;
+
+ int bind_attempted = 0;
+ int errno = 0;
+
+ struct device_def* devdef;
+ struct pci_device *pos, *n;
+ llist_for_each(pos, n, &pci_devices, dev_chain)
+ {
+ if (binded_pcidev(pos)) {
+ continue;
+ }
+
+ if (class != PCI_DEV_CLASS(pos->class_info)) {
+ continue;
+ }
+
+ int matched = (pos->device_info & devid_mask) == devid;
+
+ if (!matched) {
+ continue;
+ }
+
+ if (bind_attempted) {
+ *more = 1;
+ break;
+ }
+
+ bind_attempted = 1;
+ devdef = &pcidev_def->devdef;
+ errno = devdef->bind(devdef, &pos->dev);
+
+ if (errno) {
+ ERROR("pci_loc:%x, bind (%xh:%xh.%d) failed, e=%d",
+ pos->loc,
+ devdef->class.fn_grp,
+ devdef->class.device,
+ devdef->class.variant,
+ errno);
+ continue;
+ }
+
+ pos->binding.def = &pcidev_def->devdef;