mirror of
https://github.com/opnsense/src.git
synced 2026-06-03 13:58:30 -04:00
bus_if: Add a default implementation of get_property
There are multiple buses that pretend to be ofw compatible, e.g ofw_pci, mii_fdt. We now need to provide an implementation of BUS_GET_PROPERTY for every one of them. Instead of modifying them one by one it's better to just provide a default implementation that simply traverses up the device tree. Remove the now unneeded BUS_GET_PROPERTY implementation in mii_fdt. Reviewed by: andrew, bz Obtained from: Semihalf MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D34031
This commit is contained in:
parent
a19acfd56c
commit
206dc82bc3
4 changed files with 21 additions and 22 deletions
|
|
@ -326,20 +326,6 @@ miibus_fdt_get_devinfo(device_t bus, device_t child)
|
|||
return (&ma->obd);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
miibus_fdt_get_property(device_t bus, device_t child, const char *propname,
|
||||
void *buf, size_t size)
|
||||
{
|
||||
struct mii_attach_args *ma;
|
||||
|
||||
ma = device_get_ivars(child);
|
||||
|
||||
if (ma->obd.obd_node == 0)
|
||||
return (-1);
|
||||
|
||||
return (OF_getencprop(ma->obd.obd_node, propname, buf, size));
|
||||
}
|
||||
|
||||
static device_method_t miibus_fdt_methods[] = {
|
||||
DEVMETHOD(device_probe, miibus_fdt_probe),
|
||||
DEVMETHOD(device_attach, miibus_fdt_attach),
|
||||
|
|
@ -362,7 +348,6 @@ static device_method_t miibus_fdt_methods[] = {
|
|||
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
|
||||
DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
|
||||
DEVMETHOD(bus_get_resource_list, miibus_fdt_get_resource_list),
|
||||
DEVMETHOD(bus_get_property, miibus_fdt_get_property),
|
||||
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
|
|
|||
|
|
@ -77,12 +77,6 @@ CODE {
|
|||
return (0);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
null_get_property(device_t dev, device_t child, const char *propname,
|
||||
void *propvalue, size_t size)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -944,7 +938,7 @@ METHOD ssize_t get_property {
|
|||
const char *_propname;
|
||||
void *_propvalue;
|
||||
size_t _size;
|
||||
} DEFAULT null_get_property;
|
||||
} DEFAULT bus_generic_get_property;
|
||||
|
||||
/**
|
||||
* @brief Gets a child's full path to the device
|
||||
|
|
|
|||
|
|
@ -4125,6 +4125,23 @@ bus_generic_write_ivar(device_t dev, device_t child, int index,
|
|||
return (ENOENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Helper function for implementing BUS_GET_PROPERTY().
|
||||
*
|
||||
* This simply calls the BUS_GET_PROPERTY of the parent of dev,
|
||||
* until a non-default implementation is found.
|
||||
*/
|
||||
ssize_t
|
||||
bus_generic_get_property(device_t dev, device_t child, const char *propname,
|
||||
void *propvalue, size_t size)
|
||||
{
|
||||
if (device_get_parent(dev) != NULL)
|
||||
return (BUS_GET_PROPERTY(device_get_parent(dev), child,
|
||||
propname, propvalue, size));
|
||||
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stub function for implementing BUS_GET_RESOURCE_LIST().
|
||||
*
|
||||
|
|
|
|||
|
|
@ -444,6 +444,9 @@ bus_dma_tag_t
|
|||
bus_space_tag_t
|
||||
bus_generic_get_bus_tag(device_t dev, device_t child);
|
||||
int bus_generic_get_domain(device_t dev, device_t child, int *domain);
|
||||
ssize_t bus_generic_get_property(device_t dev, device_t child,
|
||||
const char *propname, void *propvalue,
|
||||
size_t size);
|
||||
struct resource_list *
|
||||
bus_generic_get_resource_list(device_t, device_t);
|
||||
int bus_generic_map_resource(device_t dev, device_t child, int type,
|
||||
|
|
|
|||
Loading…
Reference in a new issue