Commit f42e5550 authored by Finn Thain's avatar Finn Thain Committed by Geert Uytterhoeven

nubus: Clean up whitespace

Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
[geert: rebased]
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
parent 71ae40e4
...@@ -44,8 +44,8 @@ extern void oss_nubus_init(void); ...@@ -44,8 +44,8 @@ extern void oss_nubus_init(void);
/* Globals */ /* Globals */
struct nubus_dev* nubus_devices; struct nubus_dev *nubus_devices;
struct nubus_board* nubus_boards; struct nubus_board *nubus_boards;
/* Meaning of "bytelanes": /* Meaning of "bytelanes":
...@@ -72,9 +72,10 @@ struct nubus_board* nubus_boards; ...@@ -72,9 +72,10 @@ struct nubus_board* nubus_boards;
static inline int not_useful(void *p, int map) static inline int not_useful(void *p, int map)
{ {
unsigned long pv=(unsigned long)p; unsigned long pv = (unsigned long)p;
pv &= 3; pv &= 3;
if(map & (1<<pv)) if (map & (1 << pv))
return 0; return 0;
return 1; return 1;
} }
...@@ -85,10 +86,9 @@ static unsigned long nubus_get_rom(unsigned char **ptr, int len, int map) ...@@ -85,10 +86,9 @@ static unsigned long nubus_get_rom(unsigned char **ptr, int len, int map)
unsigned long v = 0; unsigned long v = 0;
unsigned char *p = *ptr; unsigned char *p = *ptr;
while(len) while (len) {
{
v <<= 8; v <<= 8;
while(not_useful(p,map)) while (not_useful(p, map))
p++; p++;
v |= *p++; v |= *p++;
len--; len--;
...@@ -99,31 +99,28 @@ static unsigned long nubus_get_rom(unsigned char **ptr, int len, int map) ...@@ -99,31 +99,28 @@ static unsigned long nubus_get_rom(unsigned char **ptr, int len, int map)
static void nubus_rewind(unsigned char **ptr, int len, int map) static void nubus_rewind(unsigned char **ptr, int len, int map)
{ {
unsigned char *p=*ptr; unsigned char *p = *ptr;
/* Sanity check */ /* Sanity check */
if(len > 65536) if (len > 65536)
pr_err("rewind of 0x%08x!\n", len); pr_err("rewind of 0x%08x!\n", len);
while(len) while (len) {
{ do {
do
{
p--; p--;
} } while (not_useful(p, map));
while(not_useful(p, map));
len--; len--;
} }
*ptr=p; *ptr = p;
} }
static void nubus_advance(unsigned char **ptr, int len, int map) static void nubus_advance(unsigned char **ptr, int len, int map)
{ {
unsigned char *p = *ptr; unsigned char *p = *ptr;
if(len>65536)
if (len > 65536)
pr_err("advance of 0x%08x!\n", len); pr_err("advance of 0x%08x!\n", len);
while(len) while (len) {
{ while (not_useful(p, map))
while(not_useful(p,map))
p++; p++;
p++; p++;
len--; len--;
...@@ -133,9 +130,9 @@ static void nubus_advance(unsigned char **ptr, int len, int map) ...@@ -133,9 +130,9 @@ static void nubus_advance(unsigned char **ptr, int len, int map)
static void nubus_move(unsigned char **ptr, int len, int map) static void nubus_move(unsigned char **ptr, int len, int map)
{ {
if(len > 0) if (len > 0)
nubus_advance(ptr, len, map); nubus_advance(ptr, len, map);
else if(len < 0) else if (len < 0)
nubus_rewind(ptr, -len, map); nubus_rewind(ptr, -len, map);
} }
...@@ -148,7 +145,7 @@ static void nubus_move(unsigned char **ptr, int len, int map) ...@@ -148,7 +145,7 @@ static void nubus_move(unsigned char **ptr, int len, int map)
static inline long nubus_expand32(long foo) static inline long nubus_expand32(long foo)
{ {
if(foo & 0x00800000) /* 24bit negative */ if (foo & 0x00800000) /* 24bit negative */
foo |= 0xFF000000; foo |= 0xFF000000;
return foo; return foo;
} }
...@@ -159,12 +156,13 @@ static inline void *nubus_rom_addr(int slot) ...@@ -159,12 +156,13 @@ static inline void *nubus_rom_addr(int slot)
* Returns the first byte after the card. We then walk * Returns the first byte after the card. We then walk
* backwards to get the lane register and the config * backwards to get the lane register and the config
*/ */
return (void *)(0xF1000000+(slot<<24)); return (void *)(0xF1000000 + (slot << 24));
} }
static unsigned char *nubus_dirptr(const struct nubus_dirent *nd) static unsigned char *nubus_dirptr(const struct nubus_dirent *nd)
{ {
unsigned char *p = nd->base; unsigned char *p = nd->base;
/* Essentially, just step over the bytelanes using whatever /* Essentially, just step over the bytelanes using whatever
offset we might have found */ offset we might have found */
nubus_move(&p, nubus_expand32(nd->data), nd->mask); nubus_move(&p, nubus_expand32(nd->data), nd->mask);
...@@ -175,36 +173,36 @@ static unsigned char *nubus_dirptr(const struct nubus_dirent *nd) ...@@ -175,36 +173,36 @@ static unsigned char *nubus_dirptr(const struct nubus_dirent *nd)
/* These two are for pulling resource data blocks (i.e. stuff that's /* These two are for pulling resource data blocks (i.e. stuff that's
pointed to with offsets) out of the card ROM. */ pointed to with offsets) out of the card ROM. */
void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent* dirent, void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent,
int len) int len)
{ {
unsigned char *t = (unsigned char *)dest; unsigned char *t = (unsigned char *)dest;
unsigned char *p = nubus_dirptr(dirent); unsigned char *p = nubus_dirptr(dirent);
while(len)
{ while (len) {
*t++ = nubus_get_rom(&p, 1, dirent->mask); *t++ = nubus_get_rom(&p, 1, dirent->mask);
len--; len--;
} }
} }
EXPORT_SYMBOL(nubus_get_rsrc_mem); EXPORT_SYMBOL(nubus_get_rsrc_mem);
void nubus_get_rsrc_str(void *dest, const struct nubus_dirent* dirent, void nubus_get_rsrc_str(void *dest, const struct nubus_dirent *dirent,
int len) int len)
{ {
unsigned char *t=(unsigned char *)dest; unsigned char *t = (unsigned char *)dest;
unsigned char *p = nubus_dirptr(dirent); unsigned char *p = nubus_dirptr(dirent);
while(len)
{ while (len) {
*t = nubus_get_rom(&p, 1, dirent->mask); *t = nubus_get_rom(&p, 1, dirent->mask);
if(!*t++) if (!*t++)
break; break;
len--; len--;
} }
} }
EXPORT_SYMBOL(nubus_get_rsrc_str); EXPORT_SYMBOL(nubus_get_rsrc_str);
int nubus_get_root_dir(const struct nubus_board* board, int nubus_get_root_dir(const struct nubus_board *board,
struct nubus_dir* dir) struct nubus_dir *dir)
{ {
dir->ptr = dir->base = board->directory; dir->ptr = dir->base = board->directory;
dir->done = 0; dir->done = 0;
...@@ -214,8 +212,8 @@ int nubus_get_root_dir(const struct nubus_board* board, ...@@ -214,8 +212,8 @@ int nubus_get_root_dir(const struct nubus_board* board,
EXPORT_SYMBOL(nubus_get_root_dir); EXPORT_SYMBOL(nubus_get_root_dir);
/* This is a slyly renamed version of the above */ /* This is a slyly renamed version of the above */
int nubus_get_func_dir(const struct nubus_dev* dev, int nubus_get_func_dir(const struct nubus_dev *dev,
struct nubus_dir* dir) struct nubus_dir *dir)
{ {
dir->ptr = dir->base = dev->directory; dir->ptr = dir->base = dev->directory;
dir->done = 0; dir->done = 0;
...@@ -224,8 +222,8 @@ int nubus_get_func_dir(const struct nubus_dev* dev, ...@@ -224,8 +222,8 @@ int nubus_get_func_dir(const struct nubus_dev* dev,
} }
EXPORT_SYMBOL(nubus_get_func_dir); EXPORT_SYMBOL(nubus_get_func_dir);
int nubus_get_board_dir(const struct nubus_board* board, int nubus_get_board_dir(const struct nubus_board *board,
struct nubus_dir* dir) struct nubus_dir *dir)
{ {
struct nubus_dirent ent; struct nubus_dirent ent;
...@@ -256,6 +254,7 @@ EXPORT_SYMBOL(nubus_get_subdir); ...@@ -256,6 +254,7 @@ EXPORT_SYMBOL(nubus_get_subdir);
int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent) int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent)
{ {
u32 resid; u32 resid;
if (nd->done) if (nd->done)
return -1; return -1;
...@@ -266,8 +265,7 @@ int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent) ...@@ -266,8 +265,7 @@ int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent)
resid = nubus_get_rom(&nd->ptr, 4, nd->mask); resid = nubus_get_rom(&nd->ptr, 4, nd->mask);
/* EOL marker, as per the Apple docs */ /* EOL marker, as per the Apple docs */
if((resid&0xff000000) == 0xff000000) if ((resid & 0xff000000) == 0xff000000) {
{
/* Mark it as done */ /* Mark it as done */
nd->done = 1; nd->done = 1;
return -1; return -1;
...@@ -282,11 +280,10 @@ int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent) ...@@ -282,11 +280,10 @@ int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent)
} }
EXPORT_SYMBOL(nubus_readdir); EXPORT_SYMBOL(nubus_readdir);
int nubus_rewinddir(struct nubus_dir* dir) int nubus_rewinddir(struct nubus_dir *dir)
{ {
dir->ptr = dir->base; dir->ptr = dir->base;
dir->done = 0; dir->done = 0;
return 0; return 0;
} }
EXPORT_SYMBOL(nubus_rewinddir); EXPORT_SYMBOL(nubus_rewinddir);
...@@ -294,20 +291,15 @@ EXPORT_SYMBOL(nubus_rewinddir); ...@@ -294,20 +291,15 @@ EXPORT_SYMBOL(nubus_rewinddir);
/* Driver interface functions, more or less like in pci.c */ /* Driver interface functions, more or less like in pci.c */
struct nubus_dev* struct nubus_dev*
nubus_find_device(unsigned short category, nubus_find_device(unsigned short category, unsigned short type,
unsigned short type, unsigned short dr_hw, unsigned short dr_sw,
unsigned short dr_hw, const struct nubus_dev *from)
unsigned short dr_sw,
const struct nubus_dev* from)
{ {
struct nubus_dev* itor = struct nubus_dev *itor = from ? from->next : nubus_devices;
from ? from->next : nubus_devices;
while (itor) { while (itor) {
if (itor->category == category if (itor->category == category && itor->type == type &&
&& itor->type == type itor->dr_hw == dr_hw && itor->dr_sw == dr_sw)
&& itor->dr_hw == dr_hw
&& itor->dr_sw == dr_sw)
return itor; return itor;
itor = itor->next; itor = itor->next;
} }
...@@ -316,16 +308,13 @@ nubus_find_device(unsigned short category, ...@@ -316,16 +308,13 @@ nubus_find_device(unsigned short category,
EXPORT_SYMBOL(nubus_find_device); EXPORT_SYMBOL(nubus_find_device);
struct nubus_dev* struct nubus_dev*
nubus_find_type(unsigned short category, nubus_find_type(unsigned short category, unsigned short type,
unsigned short type, const struct nubus_dev *from)
const struct nubus_dev* from)
{ {
struct nubus_dev* itor = struct nubus_dev *itor = from ? from->next : nubus_devices;
from ? from->next : nubus_devices;
while (itor) { while (itor) {
if (itor->category == category if (itor->category == category && itor->type == type)
&& itor->type == type)
return itor; return itor;
itor = itor->next; itor = itor->next;
} }
...@@ -334,11 +323,9 @@ nubus_find_type(unsigned short category, ...@@ -334,11 +323,9 @@ nubus_find_type(unsigned short category,
EXPORT_SYMBOL(nubus_find_type); EXPORT_SYMBOL(nubus_find_type);
struct nubus_dev* struct nubus_dev*
nubus_find_slot(unsigned int slot, nubus_find_slot(unsigned int slot, const struct nubus_dev *from)
const struct nubus_dev* from)
{ {
struct nubus_dev* itor = struct nubus_dev *itor = from ? from->next : nubus_devices;
from ? from->next : nubus_devices;
while (itor) { while (itor) {
if (itor->board->slot == slot) if (itor->board->slot == slot)
...@@ -350,8 +337,8 @@ nubus_find_slot(unsigned int slot, ...@@ -350,8 +337,8 @@ nubus_find_slot(unsigned int slot,
EXPORT_SYMBOL(nubus_find_slot); EXPORT_SYMBOL(nubus_find_slot);
int int
nubus_find_rsrc(struct nubus_dir* dir, unsigned char rsrc_type, nubus_find_rsrc(struct nubus_dir *dir, unsigned char rsrc_type,
struct nubus_dirent* ent) struct nubus_dirent *ent)
{ {
while (nubus_readdir(dir, ent) != -1) { while (nubus_readdir(dir, ent) != -1) {
if (ent->type == rsrc_type) if (ent->type == rsrc_type)
...@@ -370,8 +357,8 @@ EXPORT_SYMBOL(nubus_find_rsrc); ...@@ -370,8 +357,8 @@ EXPORT_SYMBOL(nubus_find_rsrc);
among other things. The rest of it should go in the /proc code. among other things. The rest of it should go in the /proc code.
For now, we just use it to give verbose boot logs. */ For now, we just use it to give verbose boot logs. */
static int __init nubus_show_display_resource(struct nubus_dev* dev, static int __init nubus_show_display_resource(struct nubus_dev *dev,
const struct nubus_dirent* ent) const struct nubus_dirent *ent)
{ {
switch (ent->type) { switch (ent->type) {
case NUBUS_RESID_GAMMADIR: case NUBUS_RESID_GAMMADIR:
...@@ -388,8 +375,8 @@ static int __init nubus_show_display_resource(struct nubus_dev* dev, ...@@ -388,8 +375,8 @@ static int __init nubus_show_display_resource(struct nubus_dev* dev,
return 0; return 0;
} }
static int __init nubus_show_network_resource(struct nubus_dev* dev, static int __init nubus_show_network_resource(struct nubus_dev *dev,
const struct nubus_dirent* ent) const struct nubus_dirent *ent)
{ {
switch (ent->type) { switch (ent->type) {
case NUBUS_RESID_MAC_ADDRESS: case NUBUS_RESID_MAC_ADDRESS:
...@@ -407,13 +394,14 @@ static int __init nubus_show_network_resource(struct nubus_dev* dev, ...@@ -407,13 +394,14 @@ static int __init nubus_show_network_resource(struct nubus_dev* dev,
return 0; return 0;
} }
static int __init nubus_show_cpu_resource(struct nubus_dev* dev, static int __init nubus_show_cpu_resource(struct nubus_dev *dev,
const struct nubus_dirent* ent) const struct nubus_dirent *ent)
{ {
switch (ent->type) { switch (ent->type) {
case NUBUS_RESID_MEMINFO: case NUBUS_RESID_MEMINFO:
{ {
unsigned long meminfo[2]; unsigned long meminfo[2];
nubus_get_rsrc_mem(&meminfo, ent, 8); nubus_get_rsrc_mem(&meminfo, ent, 8);
pr_info(" memory: [ 0x%08lx 0x%08lx ]\n", pr_info(" memory: [ 0x%08lx 0x%08lx ]\n",
meminfo[0], meminfo[1]); meminfo[0], meminfo[1]);
...@@ -422,6 +410,7 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev, ...@@ -422,6 +410,7 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev,
case NUBUS_RESID_ROMINFO: case NUBUS_RESID_ROMINFO:
{ {
unsigned long rominfo[2]; unsigned long rominfo[2];
nubus_get_rsrc_mem(&rominfo, ent, 8); nubus_get_rsrc_mem(&rominfo, ent, 8);
pr_info(" ROM: [ 0x%08lx 0x%08lx ]\n", pr_info(" ROM: [ 0x%08lx 0x%08lx ]\n",
rominfo[0], rominfo[1]); rominfo[0], rominfo[1]);
...@@ -434,8 +423,8 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev, ...@@ -434,8 +423,8 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev,
return 0; return 0;
} }
static int __init nubus_show_private_resource(struct nubus_dev* dev, static int __init nubus_show_private_resource(struct nubus_dev *dev,
const struct nubus_dirent* ent) const struct nubus_dirent *ent)
{ {
switch (dev->category) { switch (dev->category) {
case NUBUS_CAT_DISPLAY: case NUBUS_CAT_DISPLAY:
...@@ -454,14 +443,13 @@ static int __init nubus_show_private_resource(struct nubus_dev* dev, ...@@ -454,14 +443,13 @@ static int __init nubus_show_private_resource(struct nubus_dev* dev,
return 0; return 0;
} }
static struct nubus_dev* __init static struct nubus_dev * __init
nubus_get_functional_resource(struct nubus_board* board, nubus_get_functional_resource(struct nubus_board *board, int slot,
int slot, const struct nubus_dirent *parent)
const struct nubus_dirent* parent)
{ {
struct nubus_dir dir; struct nubus_dir dir;
struct nubus_dirent ent; struct nubus_dirent ent;
struct nubus_dev* dev; struct nubus_dev *dev;
pr_info(" Function 0x%02x:\n", parent->type); pr_info(" Function 0x%02x:\n", parent->type);
nubus_get_subdir(parent, &dir); nubus_get_subdir(parent, &dir);
...@@ -480,13 +468,12 @@ static struct nubus_dev* __init ...@@ -480,13 +468,12 @@ static struct nubus_dev* __init
dev->directory = dir.base; dev->directory = dir.base;
dev->board = board; dev->board = board;
while (nubus_readdir(&dir, &ent) != -1) while (nubus_readdir(&dir, &ent) != -1) {
{ switch (ent.type) {
switch(ent.type)
{
case NUBUS_RESID_TYPE: case NUBUS_RESID_TYPE:
{ {
unsigned short nbtdata[4]; unsigned short nbtdata[4];
nubus_get_rsrc_mem(nbtdata, &ent, 8); nubus_get_rsrc_mem(nbtdata, &ent, 8);
dev->category = nbtdata[0]; dev->category = nbtdata[0];
dev->type = nbtdata[1]; dev->type = nbtdata[1];
...@@ -508,6 +495,7 @@ static struct nubus_dev* __init ...@@ -508,6 +495,7 @@ static struct nubus_dev* __init
use this :-) */ use this :-) */
struct nubus_dir drvr_dir; struct nubus_dir drvr_dir;
struct nubus_dirent drvr_ent; struct nubus_dirent drvr_ent;
nubus_get_subdir(&ent, &drvr_dir); nubus_get_subdir(&ent, &drvr_dir);
nubus_readdir(&drvr_dir, &drvr_ent); nubus_readdir(&drvr_dir, &drvr_ent);
dev->driver = nubus_dirptr(&drvr_ent); dev->driver = nubus_dirptr(&drvr_ent);
...@@ -545,11 +533,12 @@ static struct nubus_dev* __init ...@@ -545,11 +533,12 @@ static struct nubus_dev* __init
} }
/* This is cool. */ /* This is cool. */
static int __init nubus_get_vidnames(struct nubus_board* board, static int __init nubus_get_vidnames(struct nubus_board *board,
const struct nubus_dirent* parent) const struct nubus_dirent *parent)
{ {
struct nubus_dir dir; struct nubus_dir dir;
struct nubus_dirent ent; struct nubus_dirent ent;
/* FIXME: obviously we want to put this in a header file soon */ /* FIXME: obviously we want to put this in a header file soon */
struct vidmode { struct vidmode {
u32 size; u32 size;
...@@ -564,8 +553,7 @@ static int __init nubus_get_vidnames(struct nubus_board* board, ...@@ -564,8 +553,7 @@ static int __init nubus_get_vidnames(struct nubus_board* board,
pr_debug("%s: parent is 0x%p, dir is 0x%p\n", pr_debug("%s: parent is 0x%p, dir is 0x%p\n",
__func__, parent->base, dir.base); __func__, parent->base, dir.base);
while(nubus_readdir(&dir, &ent) != -1) while (nubus_readdir(&dir, &ent) != -1) {
{
struct vidmode mode; struct vidmode mode;
u32 size; u32 size;
...@@ -584,8 +572,8 @@ static int __init nubus_get_vidnames(struct nubus_board* board, ...@@ -584,8 +572,8 @@ static int __init nubus_get_vidnames(struct nubus_board* board,
} }
/* This is *really* cool. */ /* This is *really* cool. */
static int __init nubus_get_icon(struct nubus_board* board, static int __init nubus_get_icon(struct nubus_board *board,
const struct nubus_dirent* ent) const struct nubus_dirent *ent)
{ {
/* Should be 32x32 if my memory serves me correctly */ /* Should be 32x32 if my memory serves me correctly */
unsigned char icon[128]; unsigned char icon[128];
...@@ -600,8 +588,7 @@ static int __init nubus_get_icon(struct nubus_board* board, ...@@ -600,8 +588,7 @@ static int __init nubus_get_icon(struct nubus_board* board,
for (y = 0; y < 32; y++) { for (y = 0; y < 32; y++) {
pr_info(" "); pr_info(" ");
for (x = 0; x < 32; x++) { for (x = 0; x < 32; x++) {
if (icon[y*4 + x/8] if (icon[y * 4 + x / 8] & (0x80 >> (x % 8)))
& (0x80 >> (x%8)))
pr_cont("*"); pr_cont("*");
else else
pr_cont(" "); pr_cont(" ");
...@@ -611,21 +598,20 @@ static int __init nubus_get_icon(struct nubus_board* board, ...@@ -611,21 +598,20 @@ static int __init nubus_get_icon(struct nubus_board* board,
return 0; return 0;
} }
static int __init nubus_get_vendorinfo(struct nubus_board* board, static int __init nubus_get_vendorinfo(struct nubus_board *board,
const struct nubus_dirent* parent) const struct nubus_dirent *parent)
{ {
struct nubus_dir dir; struct nubus_dir dir;
struct nubus_dirent ent; struct nubus_dirent ent;
static char* vendor_fields[6] = {"ID", "serial", "revision", static char *vendor_fields[6] = { "ID", "serial", "revision",
"part", "date", "unknown field"}; "part", "date", "unknown field" };
pr_info(" vendor info:\n"); pr_info(" vendor info:\n");
nubus_get_subdir(parent, &dir); nubus_get_subdir(parent, &dir);
pr_debug("%s: parent is 0x%p, dir is 0x%p\n", pr_debug("%s: parent is 0x%p, dir is 0x%p\n",
__func__, parent->base, dir.base); __func__, parent->base, dir.base);
while(nubus_readdir(&dir, &ent) != -1) while (nubus_readdir(&dir, &ent) != -1) {
{
char name[64]; char name[64];
/* These are all strings, we think */ /* These are all strings, we think */
...@@ -637,8 +623,8 @@ static int __init nubus_get_vendorinfo(struct nubus_board* board, ...@@ -637,8 +623,8 @@ static int __init nubus_get_vendorinfo(struct nubus_board* board,
return 0; return 0;
} }
static int __init nubus_get_board_resource(struct nubus_board* board, int slot, static int __init nubus_get_board_resource(struct nubus_board *board, int slot,
const struct nubus_dirent* parent) const struct nubus_dirent *parent)
{ {
struct nubus_dir dir; struct nubus_dir dir;
struct nubus_dirent ent; struct nubus_dirent ent;
...@@ -647,8 +633,7 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot, ...@@ -647,8 +633,7 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot,
pr_debug("%s: parent is 0x%p, dir is 0x%p\n", pr_debug("%s: parent is 0x%p, dir is 0x%p\n",
__func__, parent->base, dir.base); __func__, parent->base, dir.base);
while(nubus_readdir(&dir, &ent) != -1) while (nubus_readdir(&dir, &ent) != -1) {
{
switch (ent.type) { switch (ent.type) {
case NUBUS_RESID_TYPE: case NUBUS_RESID_TYPE:
{ {
...@@ -710,8 +695,8 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot, ...@@ -710,8 +695,8 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot,
sResources in the motherboard ROM */ sResources in the motherboard ROM */
static void __init nubus_find_rom_dir(struct nubus_board* board) static void __init nubus_find_rom_dir(struct nubus_board* board)
{ {
unsigned char* rp; unsigned char *rp;
unsigned char* romdir; unsigned char *romdir;
struct nubus_dir dir; struct nubus_dir dir;
struct nubus_dirent ent; struct nubus_dirent ent;
...@@ -784,11 +769,10 @@ static void __init nubus_find_rom_dir(struct nubus_board* board) ...@@ -784,11 +769,10 @@ static void __init nubus_find_rom_dir(struct nubus_board* board)
} }
/* Add a board (might be many devices) to the list */ /* Add a board (might be many devices) to the list */
static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) static struct nubus_board * __init nubus_add_board(int slot, int bytelanes)
{ {
struct nubus_board* board; struct nubus_board *board;
struct nubus_board** boardp; struct nubus_board **boardp;
unsigned char *rp; unsigned char *rp;
unsigned long dpat; unsigned long dpat;
struct nubus_dir dir; struct nubus_dir dir;
...@@ -816,7 +800,7 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) ...@@ -816,7 +800,7 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
rp = board->fblock; rp = board->fblock;
board->slot = slot; board->slot = slot;
board->slot_addr = (unsigned long) nubus_slot_addr(slot); board->slot_addr = (unsigned long)nubus_slot_addr(slot);
board->doffset = nubus_get_rom(&rp, 4, bytelanes); board->doffset = nubus_get_rom(&rp, 4, bytelanes);
/* rom_length is *supposed* to be the total length of the /* rom_length is *supposed* to be the total length of the
* ROM. In practice it is the "amount of ROM used to compute * ROM. In practice it is the "amount of ROM used to compute
...@@ -827,14 +811,14 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) ...@@ -827,14 +811,14 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
board->rom_length = nubus_get_rom(&rp, 4, bytelanes); board->rom_length = nubus_get_rom(&rp, 4, bytelanes);
board->crc = nubus_get_rom(&rp, 4, bytelanes); board->crc = nubus_get_rom(&rp, 4, bytelanes);
board->rev = nubus_get_rom(&rp, 1, bytelanes); board->rev = nubus_get_rom(&rp, 1, bytelanes);
board->format = nubus_get_rom(&rp,1, bytelanes); board->format = nubus_get_rom(&rp, 1, bytelanes);
board->lanes = bytelanes; board->lanes = bytelanes;
/* Directory offset should be small and negative... */ /* Directory offset should be small and negative... */
if(!(board->doffset & 0x00FF0000)) if (!(board->doffset & 0x00FF0000))
pr_warn("Dodgy doffset!\n"); pr_warn("Dodgy doffset!\n");
dpat = nubus_get_rom(&rp, 4, bytelanes); dpat = nubus_get_rom(&rp, 4, bytelanes);
if(dpat != NUBUS_TEST_PATTERN) if (dpat != NUBUS_TEST_PATTERN)
pr_warn("Wrong test pattern %08lx!\n", dpat); pr_warn("Wrong test pattern %08lx!\n", dpat);
/* /*
...@@ -869,8 +853,9 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) ...@@ -869,8 +853,9 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
resources. I have no idea WTF to do about this. */ resources. I have no idea WTF to do about this. */
while (nubus_readdir(&dir, &ent) != -1) { while (nubus_readdir(&dir, &ent) != -1) {
struct nubus_dev* dev; struct nubus_dev *dev;
struct nubus_dev** devp; struct nubus_dev **devp;
dev = nubus_get_functional_resource(board, slot, &ent); dev = nubus_get_functional_resource(board, slot, &ent);
if (dev == NULL) if (dev == NULL)
continue; continue;
...@@ -880,14 +865,16 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) ...@@ -880,14 +865,16 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
board->first_dev = dev; board->first_dev = dev;
/* Put it on the global NuBus device chain. Keep entries in order. */ /* Put it on the global NuBus device chain. Keep entries in order. */
for (devp=&nubus_devices; *devp!=NULL; devp=&((*devp)->next)) for (devp = &nubus_devices; *devp != NULL;
devp = &((*devp)->next))
/* spin */; /* spin */;
*devp = dev; *devp = dev;
dev->next = NULL; dev->next = NULL;
} }
/* Put it on the global NuBus board chain. Keep entries in order. */ /* Put it on the global NuBus board chain. Keep entries in order. */
for (boardp=&nubus_boards; *boardp!=NULL; boardp=&((*boardp)->next)) for (boardp = &nubus_boards; *boardp != NULL;
boardp = &((*boardp)->next))
/* spin */; /* spin */;
*boardp = board; *boardp = board;
board->next = NULL; board->next = NULL;
...@@ -898,12 +885,11 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) ...@@ -898,12 +885,11 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
void __init nubus_probe_slot(int slot) void __init nubus_probe_slot(int slot)
{ {
unsigned char dp; unsigned char dp;
unsigned char* rp; unsigned char *rp;
int i; int i;
rp = nubus_rom_addr(slot); rp = nubus_rom_addr(slot);
for(i = 4; i; i--) for (i = 4; i; i--) {
{
int card_present; int card_present;
rp--; rp--;
...@@ -918,11 +904,11 @@ void __init nubus_probe_slot(int slot) ...@@ -918,11 +904,11 @@ void __init nubus_probe_slot(int slot)
/* The last byte of the format block consists of two /* The last byte of the format block consists of two
nybbles which are "mirror images" of each other. nybbles which are "mirror images" of each other.
These show us the valid bytelanes */ These show us the valid bytelanes */
if ((((dp>>4) ^ dp) & 0x0F) != 0x0F) if ((((dp >> 4) ^ dp) & 0x0F) != 0x0F)
continue; continue;
/* Check that this value is actually *on* one of the /* Check that this value is actually *on* one of the
bytelanes it claims are valid! */ bytelanes it claims are valid! */
if ((dp & 0x0F) >= (1<<i)) if ((dp & 0x0F) >= (1 << i))
continue; continue;
/* Looks promising. Let's put it on the list. */ /* Looks promising. Let's put it on the list. */
...@@ -935,12 +921,12 @@ void __init nubus_probe_slot(int slot) ...@@ -935,12 +921,12 @@ void __init nubus_probe_slot(int slot)
void __init nubus_scan_bus(void) void __init nubus_scan_bus(void)
{ {
int slot; int slot;
/* This might not work on your machine */ /* This might not work on your machine */
#ifdef I_WANT_TO_PROBE_SLOT_ZERO #ifdef I_WANT_TO_PROBE_SLOT_ZERO
nubus_probe_slot(0); nubus_probe_slot(0);
#endif #endif
for(slot = 9; slot < 15; slot++) for (slot = 9; slot < 15; slot++) {
{
nubus_probe_slot(slot); nubus_probe_slot(slot);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment