Revision 81699d8a
b/hw/qdev.c | ||
---|---|---|
449 | 449 |
return NULL; |
450 | 450 |
} |
451 | 451 |
|
452 |
int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn, |
|
453 |
qbus_walkerfn *busfn, void *opaque) |
|
454 |
{ |
|
455 |
DeviceState *dev; |
|
456 |
int err; |
|
457 |
|
|
458 |
if (busfn) { |
|
459 |
err = busfn(bus, opaque); |
|
460 |
if (err) { |
|
461 |
return err; |
|
462 |
} |
|
463 |
} |
|
464 |
|
|
465 |
QLIST_FOREACH(dev, &bus->children, sibling) { |
|
466 |
err = qdev_walk_children(dev, devfn, busfn, opaque); |
|
467 |
if (err < 0) { |
|
468 |
return err; |
|
469 |
} |
|
470 |
} |
|
471 |
|
|
472 |
return 0; |
|
473 |
} |
|
474 |
|
|
475 |
int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn, |
|
476 |
qbus_walkerfn *busfn, void *opaque) |
|
477 |
{ |
|
478 |
BusState *bus; |
|
479 |
int err; |
|
480 |
|
|
481 |
if (devfn) { |
|
482 |
err = devfn(dev, opaque); |
|
483 |
if (err) { |
|
484 |
return err; |
|
485 |
} |
|
486 |
} |
|
487 |
|
|
488 |
QLIST_FOREACH(bus, &dev->child_bus, sibling) { |
|
489 |
err = qbus_walk_children(bus, devfn, busfn, opaque); |
|
490 |
if (err < 0) { |
|
491 |
return err; |
|
492 |
} |
|
493 |
} |
|
494 |
|
|
495 |
return 0; |
|
496 |
} |
|
497 |
|
|
452 | 498 |
static BusState *qbus_find_recursive(BusState *bus, const char *name, |
453 | 499 |
const BusInfo *info) |
454 | 500 |
{ |
b/hw/qdev.h | ||
---|---|---|
173 | 173 |
|
174 | 174 |
/*** BUS API. ***/ |
175 | 175 |
|
176 |
/* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */ |
|
177 |
typedef int (qbus_walkerfn)(BusState *bus, void *opaque); |
|
178 |
typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque); |
|
179 |
|
|
176 | 180 |
void qbus_create_inplace(BusState *bus, BusInfo *info, |
177 | 181 |
DeviceState *parent, const char *name); |
178 | 182 |
BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name); |
183 |
/* Returns > 0 if either devfn or busfn skip walk somewhere in cursion, |
|
184 |
* < 0 if either devfn or busfn terminate walk somewhere in cursion, |
|
185 |
* 0 otherwise. */ |
|
186 |
int qbus_walk_children(BusState *bus, qdev_walkerfn *devfn, |
|
187 |
qbus_walkerfn *busfn, void *opaque); |
|
188 |
int qdev_walk_children(DeviceState *dev, qdev_walkerfn *devfn, |
|
189 |
qbus_walkerfn *busfn, void *opaque); |
|
179 | 190 |
void qbus_free(BusState *bus); |
180 | 191 |
|
181 | 192 |
#define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev) |
Also available in: Unified diff