freebsd compat. layer: another go at multiple MII module support.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21100 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -360,6 +360,30 @@ device_add_child(device_t dev, const char *name, int order)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
driver_t *
|
||||||
|
__haiku_probe_miibus(device_t dev, driver_t *drivers[], int count)
|
||||||
|
{
|
||||||
|
driver_t *selected = NULL;
|
||||||
|
int i, selcost = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++) {
|
||||||
|
device_probe_t *probe = (device_probe_t *)
|
||||||
|
_resolve_method(drivers[i], "device_probe");
|
||||||
|
if (probe) {
|
||||||
|
int result = probe(dev);
|
||||||
|
if (result >= 0) {
|
||||||
|
if (selected == NULL || result > selcost) {
|
||||||
|
selected = drivers[i];
|
||||||
|
selcost = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
bus_generic_attach(device_t dev)
|
bus_generic_attach(device_t dev)
|
||||||
{
|
{
|
||||||
@@ -369,26 +393,7 @@ bus_generic_attach(device_t dev)
|
|||||||
child; child = list_get_next_item(&dev->children, child)) {
|
child; child = list_get_next_item(&dev->children, child)) {
|
||||||
if (child->driver == NULL) {
|
if (child->driver == NULL) {
|
||||||
if (dev->driver == &miibus_driver) {
|
if (dev->driver == &miibus_driver) {
|
||||||
int i, driver_count, driver_cost = INT_MIN;
|
driver_t *driver = __haiku_select_miibus_driver(child);
|
||||||
driver_t **drivers, *driver = NULL;
|
|
||||||
|
|
||||||
drivers = __haiku_get_miibus_drivers(&driver_count);
|
|
||||||
|
|
||||||
for (i = 0; i < driver_count; i++) {
|
|
||||||
device_probe_t *probe = (device_probe_t *)
|
|
||||||
_resolve_method(drivers[i], "device_probe");
|
|
||||||
|
|
||||||
if (probe) {
|
|
||||||
/* XXX this kinda reverses the original logic */
|
|
||||||
int result = probe(child);
|
|
||||||
if (result >= 0) {
|
|
||||||
if (driver == NULL || result > driver_cost) {
|
|
||||||
driver = drivers[i];
|
|
||||||
driver_cost = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (driver)
|
if (driver)
|
||||||
device_set_driver(child, driver);
|
device_set_driver(child, driver);
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ status_t _fbsd_init_driver(driver_t *);
|
|||||||
void _fbsd_uninit_driver(driver_t *);
|
void _fbsd_uninit_driver(driver_t *);
|
||||||
|
|
||||||
extern const char gDriverName[];
|
extern const char gDriverName[];
|
||||||
driver_t **__haiku_get_miibus_drivers(int *count);
|
driver_t *__haiku_select_miibus_driver(device_t dev);
|
||||||
|
driver_t *__haiku_probe_miibus(device_t dev, driver_t *drivers[], int count);
|
||||||
|
|
||||||
/* we define the driver methods with HAIKU_FBSD_DRIVER_GLUE to
|
/* we define the driver methods with HAIKU_FBSD_DRIVER_GLUE to
|
||||||
* force the rest of the stuff to be linked back with the driver.
|
* force the rest of the stuff to be linked back with the driver.
|
||||||
@@ -80,11 +81,10 @@ driver_t **__haiku_get_miibus_drivers(int *count);
|
|||||||
device_hooks *find_device(const char *name) \
|
device_hooks *find_device(const char *name) \
|
||||||
{ return &gDeviceHooks; }
|
{ return &gDeviceHooks; }
|
||||||
|
|
||||||
#define HAIKU_FBSD_RETURN_MII_DRIVER(drivers, driver_count) \
|
#define HAIKU_FBSD_RETURN_MII_DRIVER(drivers, count) \
|
||||||
driver_t **__haiku_get_miibus_drivers(int *count) \
|
driver_t *__haiku_select_miibus_driver(device_t dev) \
|
||||||
{ \
|
{ \
|
||||||
(*count) = (driver_count); \
|
return __haiku_probe_miibus(dev, drivers, count); \
|
||||||
return (drivers); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HAIKU_FBSD_MII_DRIVER(name) \
|
#define HAIKU_FBSD_MII_DRIVER(name) \
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <sys/haiku-module.h>
|
#include <sys/haiku-module.h>
|
||||||
#include <sys/module.h>
|
#include <sys/module.h>
|
||||||
|
#include <sys/errno.h>
|
||||||
|
|
||||||
#define hz 1000000LL
|
#define hz 1000000LL
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user