mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
nubus: Adopt standard linked list implementation
This increases code re-use and improves readability. Cc: "David S. Miller" <[email protected]> Cc: Bartlomiej Zolnierkiewicz <[email protected]> Acked-by: Bartlomiej Zolnierkiewicz <[email protected]> Tested-by: Stan Johnson <[email protected]> Signed-off-by: Finn Thain <[email protected]> Signed-off-by: Geert Uytterhoeven <[email protected]>
This commit is contained in:
parent
189e19e8cb
commit
41b848160e
7 changed files with 40 additions and 60 deletions
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
/* Globals */
|
||||
|
||||
struct nubus_rsrc *nubus_func_rsrcs;
|
||||
LIST_HEAD(nubus_func_rsrcs);
|
||||
struct nubus_board *nubus_boards;
|
||||
|
||||
/* Meaning of "bytelanes":
|
||||
|
|
@ -305,33 +305,20 @@ EXPORT_SYMBOL(nubus_rewinddir);
|
|||
|
||||
/* Driver interface functions, more or less like in pci.c */
|
||||
|
||||
struct nubus_rsrc *nubus_find_type(unsigned short category, unsigned short type,
|
||||
const struct nubus_rsrc *from)
|
||||
struct nubus_rsrc *nubus_first_rsrc_or_null(void)
|
||||
{
|
||||
struct nubus_rsrc *itor = from ? from->next : nubus_func_rsrcs;
|
||||
|
||||
while (itor) {
|
||||
if (itor->category == category && itor->type == type)
|
||||
return itor;
|
||||
itor = itor->next;
|
||||
}
|
||||
return NULL;
|
||||
return list_first_entry_or_null(&nubus_func_rsrcs, struct nubus_rsrc,
|
||||
list);
|
||||
}
|
||||
EXPORT_SYMBOL(nubus_find_type);
|
||||
EXPORT_SYMBOL(nubus_first_rsrc_or_null);
|
||||
|
||||
struct nubus_rsrc *nubus_find_slot(unsigned int slot,
|
||||
const struct nubus_rsrc *from)
|
||||
struct nubus_rsrc *nubus_next_rsrc_or_null(struct nubus_rsrc *from)
|
||||
{
|
||||
struct nubus_rsrc *itor = from ? from->next : nubus_func_rsrcs;
|
||||
|
||||
while (itor) {
|
||||
if (itor->board->slot == slot)
|
||||
return itor;
|
||||
itor = itor->next;
|
||||
}
|
||||
return NULL;
|
||||
if (list_is_last(&from->list, &nubus_func_rsrcs))
|
||||
return NULL;
|
||||
return list_next_entry(from, list);
|
||||
}
|
||||
EXPORT_SYMBOL(nubus_find_slot);
|
||||
EXPORT_SYMBOL(nubus_next_rsrc_or_null);
|
||||
|
||||
int
|
||||
nubus_find_rsrc(struct nubus_dir *dir, unsigned char rsrc_type,
|
||||
|
|
@ -819,7 +806,6 @@ static struct nubus_board * __init nubus_add_board(int slot, int bytelanes)
|
|||
|
||||
while (nubus_readdir(&dir, &ent) != -1) {
|
||||
struct nubus_rsrc *fres;
|
||||
struct nubus_rsrc **fresp;
|
||||
|
||||
fres = nubus_get_functional_resource(board, slot, &ent);
|
||||
if (fres == NULL)
|
||||
|
|
@ -834,16 +820,7 @@ static struct nubus_board * __init nubus_add_board(int slot, int bytelanes)
|
|||
}
|
||||
prev_resid = fres->resid;
|
||||
|
||||
/* We zeroed this out above */
|
||||
if (board->first_func_rsrc == NULL)
|
||||
board->first_func_rsrc = fres;
|
||||
|
||||
/* Put it on the func. resource list. Keep entries in order. */
|
||||
for (fresp = &nubus_func_rsrcs; *fresp != NULL;
|
||||
fresp = &((*fresp)->next))
|
||||
/* spin */;
|
||||
*fresp = fres;
|
||||
fres->next = NULL;
|
||||
list_add_tail(&fres->list, &nubus_func_rsrcs);
|
||||
}
|
||||
|
||||
/* Put it on the global NuBus board chain. Keep entries in order. */
|
||||
|
|
|
|||
|
|
@ -36,15 +36,12 @@
|
|||
static int
|
||||
nubus_devices_proc_show(struct seq_file *m, void *v)
|
||||
{
|
||||
struct nubus_rsrc *fres = nubus_func_rsrcs;
|
||||
struct nubus_rsrc *fres;
|
||||
|
||||
while (fres) {
|
||||
seq_printf(m, "%x\t%04x %04x %04x %04x",
|
||||
for_each_func_rsrc(fres)
|
||||
seq_printf(m, "%x\t%04x %04x %04x %04x\t%08lx\n",
|
||||
fres->board->slot, fres->category, fres->type,
|
||||
fres->dr_sw, fres->dr_hw);
|
||||
seq_printf(m, "\t%08lx\n", fres->board->slot_addr);
|
||||
fres = fres->next;
|
||||
}
|
||||
fres->dr_sw, fres->dr_hw, fres->board->slot_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue