mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-21 15:45:02 +00:00
Remove unnecessary code and make use of generic implementations for
bus_alloc_resource(), bus_release_resource() and bus_set_resource() (bus_generic_rl_alloc_resource(), bus_generic_rl_release_resource() and bus_generic_rl_set_resource() respectively). Do not print the resources for nomatch devices. Use the inherited method for bus_get_resource_list() on ofw_iicbus.c. Submitted by: jhb and Michal Meloun (D2033)
This commit is contained in:
parent
2518db8bb0
commit
1b53f6c5a3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=282702
@ -159,9 +159,7 @@ iicbus_probe_nomatch(device_t bus, device_t child)
|
||||
{
|
||||
struct iicbus_ivar *devi = IICBUS_IVAR(child);
|
||||
|
||||
device_printf(bus, "<unknown card> at addr %#x", devi->addr);
|
||||
resource_list_print_type(&devi->rl, "irq", SYS_RES_IRQ, "%ld");
|
||||
printf("\n");
|
||||
device_printf(bus, "<unknown card> at addr %#x\n", devi->addr);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -233,57 +231,6 @@ iicbus_hinted_child(device_t bus, const char *dname, int dunit)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
iicbus_set_resource(device_t dev, device_t child, int type, int rid,
|
||||
u_long start, u_long count)
|
||||
{
|
||||
struct iicbus_ivar *devi;
|
||||
struct resource_list_entry *rle;
|
||||
|
||||
devi = IICBUS_IVAR(child);
|
||||
rle = resource_list_add(&devi->rl, type, rid, start,
|
||||
start + count - 1, count);
|
||||
if (rle == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static struct resource *
|
||||
iicbus_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
{
|
||||
struct resource_list *rl;
|
||||
struct resource_list_entry *rle;
|
||||
|
||||
/* Only IRQ resources are supported. */
|
||||
if (type != SYS_RES_IRQ)
|
||||
return (NULL);
|
||||
|
||||
/*
|
||||
* Request for the default allocation with a given rid: use resource
|
||||
* list stored in the local device info.
|
||||
*/
|
||||
if ((start == 0UL) && (end == ~0UL)) {
|
||||
rl = BUS_GET_RESOURCE_LIST(bus, child);
|
||||
if (rl == NULL)
|
||||
return (NULL);
|
||||
rle = resource_list_find(rl, type, *rid);
|
||||
if (rle == NULL) {
|
||||
if (bootverbose)
|
||||
device_printf(bus, "no default resources for "
|
||||
"rid = %d, type = %d\n", *rid, type);
|
||||
return (NULL);
|
||||
}
|
||||
start = rle->start;
|
||||
end = rle->end;
|
||||
count = rle->count;
|
||||
}
|
||||
|
||||
return (bus_generic_alloc_resource(bus, child, type, rid, start, end,
|
||||
count, flags));
|
||||
}
|
||||
|
||||
static struct resource_list *
|
||||
iicbus_get_resource_list(device_t bus __unused, device_t child)
|
||||
{
|
||||
@ -368,14 +315,14 @@ static device_method_t iicbus_methods[] = {
|
||||
/* bus interface */
|
||||
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
||||
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
|
||||
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
|
||||
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
||||
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
||||
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
|
||||
DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource),
|
||||
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
|
||||
DEVMETHOD(bus_alloc_resource, iicbus_alloc_resource),
|
||||
DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource),
|
||||
DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
|
||||
DEVMETHOD(bus_get_resource_list, iicbus_get_resource_list),
|
||||
DEVMETHOD(bus_set_resource, iicbus_set_resource),
|
||||
DEVMETHOD(bus_add_child, iicbus_add_child),
|
||||
DEVMETHOD(bus_print_child, iicbus_print_child),
|
||||
DEVMETHOD(bus_probe_nomatch, iicbus_probe_nomatch),
|
||||
|
@ -50,8 +50,6 @@ static device_t ofw_iicbus_add_child(device_t dev, u_int order,
|
||||
const char *name, int unit);
|
||||
static const struct ofw_bus_devinfo *ofw_iicbus_get_devinfo(device_t bus,
|
||||
device_t dev);
|
||||
static struct resource_list *ofw_iicbus_get_resource_list(device_t bus,
|
||||
device_t child);
|
||||
|
||||
static device_method_t ofw_iicbus_methods[] = {
|
||||
/* Device interface */
|
||||
@ -59,7 +57,6 @@ static device_method_t ofw_iicbus_methods[] = {
|
||||
DEVMETHOD(device_attach, ofw_iicbus_attach),
|
||||
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_get_resource_list, ofw_iicbus_get_resource_list),
|
||||
DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str),
|
||||
DEVMETHOD(bus_add_child, ofw_iicbus_add_child),
|
||||
|
||||
@ -205,12 +202,3 @@ ofw_iicbus_get_devinfo(device_t bus, device_t dev)
|
||||
dinfo = device_get_ivars(dev);
|
||||
return (&dinfo->opd_obdinfo);
|
||||
}
|
||||
|
||||
static struct resource_list *
|
||||
ofw_iicbus_get_resource_list(device_t bus __unused, device_t child)
|
||||
{
|
||||
struct ofw_iicbus_devinfo *devi;
|
||||
|
||||
devi = device_get_ivars(child);
|
||||
return (&devi->opd_dinfo.rl);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user