Use resource_list_print_type() instead of duplicating the code in

nexus_print_resources().
This commit is contained in:
John Baldwin 2002-09-04 03:19:33 +00:00
parent 1d62131385
commit 34f73fbd8c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=102920
4 changed files with 12 additions and 132 deletions

View File

@ -88,8 +88,6 @@ static struct rman irq_rman, drq_rman, port_rman, mem_rman;
static int nexus_probe(device_t);
static int nexus_attach(device_t);
static int nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format);
static int nexus_print_all_resources(device_t dev);
static int nexus_print_child(device_t, device_t);
static device_t nexus_add_child(device_t bus, int order, const char *name,
@ -266,34 +264,6 @@ nexus_attach(device_t dev)
return 0;
}
static int
nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format)
{
struct resource_list_entry *rle;
int printed, retval;
printed = 0;
retval = 0;
/* Yes, this is kinda cheating */
SLIST_FOREACH(rle, rl, link) {
if (rle->type == type) {
if (printed == 0)
retval += printf(" %s ", name);
else if (printed > 0)
retval += printf(",");
printed++;
retval += printf(format, rle->start);
if (rle->count > 1) {
retval += printf("-");
retval += printf(format, rle->start +
rle->count - 1);
}
}
}
return retval;
}
static int
nexus_print_all_resources(device_t dev)
{
@ -304,9 +274,9 @@ nexus_print_all_resources(device_t dev)
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
retval += printf(" at");
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += nexus_print_resources(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += nexus_print_resources(rl, "irq", SYS_RES_IRQ, "%ld");
retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
return retval;
}

View File

@ -88,8 +88,6 @@ static struct rman irq_rman, drq_rman, port_rman, mem_rman;
static int nexus_probe(device_t);
static int nexus_attach(device_t);
static int nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format);
static int nexus_print_all_resources(device_t dev);
static int nexus_print_child(device_t, device_t);
static device_t nexus_add_child(device_t bus, int order, const char *name,
@ -266,34 +264,6 @@ nexus_attach(device_t dev)
return 0;
}
static int
nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format)
{
struct resource_list_entry *rle;
int printed, retval;
printed = 0;
retval = 0;
/* Yes, this is kinda cheating */
SLIST_FOREACH(rle, rl, link) {
if (rle->type == type) {
if (printed == 0)
retval += printf(" %s ", name);
else if (printed > 0)
retval += printf(",");
printed++;
retval += printf(format, rle->start);
if (rle->count > 1) {
retval += printf("-");
retval += printf(format, rle->start +
rle->count - 1);
}
}
}
return retval;
}
static int
nexus_print_all_resources(device_t dev)
{
@ -304,9 +274,9 @@ nexus_print_all_resources(device_t dev)
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
retval += printf(" at");
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += nexus_print_resources(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += nexus_print_resources(rl, "irq", SYS_RES_IRQ, "%ld");
retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
return retval;
}

View File

@ -88,8 +88,6 @@ static struct rman irq_rman, drq_rman, port_rman, mem_rman;
static int nexus_probe(device_t);
static int nexus_attach(device_t);
static int nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format);
static int nexus_print_all_resources(device_t dev);
static int nexus_print_child(device_t, device_t);
static device_t nexus_add_child(device_t bus, int order, const char *name,
@ -266,34 +264,6 @@ nexus_attach(device_t dev)
return 0;
}
static int
nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format)
{
struct resource_list_entry *rle;
int printed, retval;
printed = 0;
retval = 0;
/* Yes, this is kinda cheating */
SLIST_FOREACH(rle, rl, link) {
if (rle->type == type) {
if (printed == 0)
retval += printf(" %s ", name);
else if (printed > 0)
retval += printf(",");
printed++;
retval += printf(format, rle->start);
if (rle->count > 1) {
retval += printf("-");
retval += printf(format, rle->start +
rle->count - 1);
}
}
}
return retval;
}
static int
nexus_print_all_resources(device_t dev)
{
@ -304,9 +274,9 @@ nexus_print_all_resources(device_t dev)
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
retval += printf(" at");
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += nexus_print_resources(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += nexus_print_resources(rl, "irq", SYS_RES_IRQ, "%ld");
retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
return retval;
}

View File

@ -88,8 +88,6 @@ static struct rman irq_rman, drq_rman, port_rman, mem_rman;
static int nexus_probe(device_t);
static int nexus_attach(device_t);
static int nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format);
static int nexus_print_all_resources(device_t dev);
static int nexus_print_child(device_t, device_t);
static device_t nexus_add_child(device_t bus, int order, const char *name,
@ -266,34 +264,6 @@ nexus_attach(device_t dev)
return 0;
}
static int
nexus_print_resources(struct resource_list *rl, const char *name, int type,
const char *format)
{
struct resource_list_entry *rle;
int printed, retval;
printed = 0;
retval = 0;
/* Yes, this is kinda cheating */
SLIST_FOREACH(rle, rl, link) {
if (rle->type == type) {
if (printed == 0)
retval += printf(" %s ", name);
else if (printed > 0)
retval += printf(",");
printed++;
retval += printf(format, rle->start);
if (rle->count > 1) {
retval += printf("-");
retval += printf(format, rle->start +
rle->count - 1);
}
}
}
return retval;
}
static int
nexus_print_all_resources(device_t dev)
{
@ -304,9 +274,9 @@ nexus_print_all_resources(device_t dev)
if (SLIST_FIRST(rl) || ndev->nx_pcibus != -1)
retval += printf(" at");
retval += nexus_print_resources(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += nexus_print_resources(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += nexus_print_resources(rl, "irq", SYS_RES_IRQ, "%ld");
retval += resource_list_print_type(rl, "port", SYS_RES_IOPORT, "%#lx");
retval += resource_list_print_type(rl, "iomem", SYS_RES_MEMORY, "%#lx");
retval += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%ld");
return retval;
}