nubus: Clean up printk calls

Some long forgotten changes from the linux-mac68k CVS:

Fix swapped DrvrSW and DrvrHW values in printk message.
Suppress debug printk messages.
Avoid console_loglevel misuse.

The original commits are these:

http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.22.2.1&r2=1.22.2.2&pathrev=linux-2_2
http://linux-mac68k.cvs.sourceforge.net/viewvc/linux-mac68k/linux-mac68k/drivers/nubus/nubus.c?r1=1.21&r2=1.22&pathrev=linux-2_2

The CVS commits fell short of removing all of the misuse of
console_loglevel in nubus_add_board() so I finished the job.
I've also added some missing message severity levels and converted
a printk loop to the MAC address "%pM" format specifier.

Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
This commit is contained in:
David Huggins-Daines 2017-04-08 19:51:15 -04:00 committed by Geert Uytterhoeven
parent e36b9913e0
commit 71ae40e4cf

View File

@ -103,7 +103,7 @@ static void nubus_rewind(unsigned char **ptr, int len, int map)
/* Sanity check */ /* Sanity check */
if(len > 65536) if(len > 65536)
printk(KERN_ERR "rewind of 0x%08x!\n", len); pr_err("rewind of 0x%08x!\n", len);
while(len) while(len)
{ {
do do
@ -120,7 +120,7 @@ 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)
printk(KERN_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))
@ -375,14 +375,14 @@ static int __init nubus_show_display_resource(struct nubus_dev* dev,
{ {
switch (ent->type) { switch (ent->type) {
case NUBUS_RESID_GAMMADIR: case NUBUS_RESID_GAMMADIR:
printk(KERN_INFO " gamma directory offset: 0x%06x\n", ent->data); pr_info(" gamma directory offset: 0x%06x\n", ent->data);
break; break;
case 0x0080 ... 0x0085: case 0x0080 ... 0x0085:
printk(KERN_INFO " mode %02X info offset: 0x%06x\n", pr_info(" mode %02X info offset: 0x%06x\n",
ent->type, ent->data); ent->type, ent->data);
break; break;
default: default:
printk(KERN_INFO " unknown resource %02X, data 0x%06x\n", pr_info(" unknown resource %02X, data 0x%06x\n",
ent->type, ent->data); ent->type, ent->data);
} }
return 0; return 0;
@ -395,18 +395,13 @@ static int __init nubus_show_network_resource(struct nubus_dev* dev,
case NUBUS_RESID_MAC_ADDRESS: case NUBUS_RESID_MAC_ADDRESS:
{ {
char addr[6]; char addr[6];
int i;
nubus_get_rsrc_mem(addr, ent, 6); nubus_get_rsrc_mem(addr, ent, 6);
printk(KERN_INFO " MAC address: "); pr_info(" MAC address: %pM\n", addr);
for (i = 0; i < 6; i++)
printk("%02x%s", addr[i] & 0xff,
i == 5 ? "" : ":");
printk("\n");
break; break;
} }
default: default:
printk(KERN_INFO " unknown resource %02X, data 0x%06x\n", pr_info(" unknown resource %02X, data 0x%06x\n",
ent->type, ent->data); ent->type, ent->data);
} }
return 0; return 0;
@ -420,7 +415,7 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev,
{ {
unsigned long meminfo[2]; unsigned long meminfo[2];
nubus_get_rsrc_mem(&meminfo, ent, 8); nubus_get_rsrc_mem(&meminfo, ent, 8);
printk(KERN_INFO " memory: [ 0x%08lx 0x%08lx ]\n", pr_info(" memory: [ 0x%08lx 0x%08lx ]\n",
meminfo[0], meminfo[1]); meminfo[0], meminfo[1]);
break; break;
} }
@ -428,12 +423,12 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev,
{ {
unsigned long rominfo[2]; unsigned long rominfo[2];
nubus_get_rsrc_mem(&rominfo, ent, 8); nubus_get_rsrc_mem(&rominfo, ent, 8);
printk(KERN_INFO " ROM: [ 0x%08lx 0x%08lx ]\n", pr_info(" ROM: [ 0x%08lx 0x%08lx ]\n",
rominfo[0], rominfo[1]); rominfo[0], rominfo[1]);
break; break;
} }
default: default:
printk(KERN_INFO " unknown resource %02X, data 0x%06x\n", pr_info(" unknown resource %02X, data 0x%06x\n",
ent->type, ent->data); ent->type, ent->data);
} }
return 0; return 0;
@ -453,7 +448,7 @@ static int __init nubus_show_private_resource(struct nubus_dev* dev,
nubus_show_cpu_resource(dev, ent); nubus_show_cpu_resource(dev, ent);
break; break;
default: default:
printk(KERN_INFO " unknown resource %02X, data 0x%06x\n", pr_info(" unknown resource %02X, data 0x%06x\n",
ent->type, ent->data); ent->type, ent->data);
} }
return 0; return 0;
@ -468,16 +463,15 @@ static struct nubus_dev* __init
struct nubus_dirent ent; struct nubus_dirent ent;
struct nubus_dev* dev; struct nubus_dev* dev;
printk(KERN_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);
/* Apple seems to have botched the ROM on the IIx */ /* Apple seems to have botched the ROM on the IIx */
if (slot == 0 && (unsigned long)dir.base % 2) if (slot == 0 && (unsigned long)dir.base % 2)
dir.base += 1; dir.base += 1;
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) pr_debug("%s: parent is 0x%p, dir is 0x%p\n",
printk(KERN_DEBUG "nubus_get_functional_resource: parent is 0x%p, dir is 0x%p\n", __func__, parent->base, dir.base);
parent->base, dir.base);
/* Actually we should probably panic if this fails */ /* Actually we should probably panic if this fails */
if ((dev = kzalloc(sizeof(*dev), GFP_ATOMIC)) == NULL) if ((dev = kzalloc(sizeof(*dev), GFP_ATOMIC)) == NULL)
@ -498,14 +492,14 @@ static struct nubus_dev* __init
dev->type = nbtdata[1]; dev->type = nbtdata[1];
dev->dr_sw = nbtdata[2]; dev->dr_sw = nbtdata[2];
dev->dr_hw = nbtdata[3]; dev->dr_hw = nbtdata[3];
printk(KERN_INFO " type: [cat 0x%x type 0x%x hw 0x%x sw 0x%x]\n", pr_info(" type: [cat 0x%x type 0x%x sw 0x%x hw 0x%x]\n",
nbtdata[0], nbtdata[1], nbtdata[2], nbtdata[3]); nbtdata[0], nbtdata[1], nbtdata[2], nbtdata[3]);
break; break;
} }
case NUBUS_RESID_NAME: case NUBUS_RESID_NAME:
{ {
nubus_get_rsrc_str(dev->name, &ent, 64); nubus_get_rsrc_str(dev->name, &ent, 64);
printk(KERN_INFO " name: %s\n", dev->name); pr_info(" name: %s\n", dev->name);
break; break;
} }
case NUBUS_RESID_DRVRDIR: case NUBUS_RESID_DRVRDIR:
@ -517,8 +511,7 @@ static struct nubus_dev* __init
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);
printk(KERN_INFO " driver at: 0x%p\n", pr_info(" driver at: 0x%p\n", dev->driver);
dev->driver);
break; break;
} }
case NUBUS_RESID_MINOR_BASEOS: case NUBUS_RESID_MINOR_BASEOS:
@ -526,22 +519,20 @@ static struct nubus_dev* __init
multiple framebuffers. It might be handy multiple framebuffers. It might be handy
for Ethernet as well */ for Ethernet as well */
nubus_get_rsrc_mem(&dev->iobase, &ent, 4); nubus_get_rsrc_mem(&dev->iobase, &ent, 4);
printk(KERN_INFO " memory offset: 0x%08lx\n", pr_info(" memory offset: 0x%08lx\n", dev->iobase);
dev->iobase);
break; break;
case NUBUS_RESID_MINOR_LENGTH: case NUBUS_RESID_MINOR_LENGTH:
/* Ditto */ /* Ditto */
nubus_get_rsrc_mem(&dev->iosize, &ent, 4); nubus_get_rsrc_mem(&dev->iosize, &ent, 4);
printk(KERN_INFO " memory length: 0x%08lx\n", pr_info(" memory length: 0x%08lx\n", dev->iosize);
dev->iosize);
break; break;
case NUBUS_RESID_FLAGS: case NUBUS_RESID_FLAGS:
dev->flags = ent.data; dev->flags = ent.data;
printk(KERN_INFO " flags: 0x%06x\n", dev->flags); pr_info(" flags: 0x%06x\n", dev->flags);
break; break;
case NUBUS_RESID_HWDEVID: case NUBUS_RESID_HWDEVID:
dev->hwdevid = ent.data; dev->hwdevid = ent.data;
printk(KERN_INFO " hwdevid: 0x%06x\n", dev->hwdevid); pr_info(" hwdevid: 0x%06x\n", dev->hwdevid);
break; break;
default: default:
/* Local/Private resources have their own /* Local/Private resources have their own
@ -568,11 +559,10 @@ static int __init nubus_get_vidnames(struct nubus_board* board,
char name[32]; char name[32];
}; };
printk(KERN_INFO " video modes supported:\n"); pr_info(" video modes supported:\n");
nubus_get_subdir(parent, &dir); nubus_get_subdir(parent, &dir);
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) pr_debug("%s: parent is 0x%p, dir is 0x%p\n",
printk(KERN_DEBUG "nubus_get_vidnames: parent is 0x%p, dir is 0x%p\n", __func__, parent->base, dir.base);
parent->base, dir.base);
while(nubus_readdir(&dir, &ent) != -1) while(nubus_readdir(&dir, &ent) != -1)
{ {
@ -587,7 +577,7 @@ static int __init nubus_get_vidnames(struct nubus_board* board,
size = sizeof(mode) - 1; size = sizeof(mode) - 1;
memset(&mode, 0, sizeof(mode)); memset(&mode, 0, sizeof(mode));
nubus_get_rsrc_mem(&mode, &ent, size); nubus_get_rsrc_mem(&mode, &ent, size);
printk (KERN_INFO " %02X: (%02X) %s\n", ent.type, pr_info(" %02X: (%02X) %s\n", ent.type,
mode.id, mode.name); mode.id, mode.name);
} }
return 0; return 0;
@ -602,21 +592,21 @@ static int __init nubus_get_icon(struct nubus_board* board,
int x, y; int x, y;
nubus_get_rsrc_mem(&icon, ent, 128); nubus_get_rsrc_mem(&icon, ent, 128);
printk(KERN_INFO " icon:\n"); pr_info(" icon:\n");
/* We should actually plot these somewhere in the framebuffer /* We should actually plot these somewhere in the framebuffer
init. This is just to demonstrate that they do, in fact, init. This is just to demonstrate that they do, in fact,
exist */ exist */
for (y = 0; y < 32; y++) { for (y = 0; y < 32; y++) {
printk(KERN_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)))
printk("*"); pr_cont("*");
else else
printk(" "); pr_cont(" ");
} }
printk("\n"); pr_cont("\n");
} }
return 0; return 0;
} }
@ -629,11 +619,10 @@ static int __init nubus_get_vendorinfo(struct nubus_board* board,
static char* vendor_fields[6] = {"ID", "serial", "revision", static char* vendor_fields[6] = {"ID", "serial", "revision",
"part", "date", "unknown field"}; "part", "date", "unknown field"};
printk(KERN_INFO " vendor info:\n"); pr_info(" vendor info:\n");
nubus_get_subdir(parent, &dir); nubus_get_subdir(parent, &dir);
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) pr_debug("%s: parent is 0x%p, dir is 0x%p\n",
printk(KERN_DEBUG "nubus_get_vendorinfo: parent is 0x%p, dir is 0x%p\n", __func__, parent->base, dir.base);
parent->base, dir.base);
while(nubus_readdir(&dir, &ent) != -1) while(nubus_readdir(&dir, &ent) != -1)
{ {
@ -643,8 +632,7 @@ static int __init nubus_get_vendorinfo(struct nubus_board* board,
nubus_get_rsrc_str(name, &ent, 64); nubus_get_rsrc_str(name, &ent, 64);
if (ent.type > 5) if (ent.type > 5)
ent.type = 5; ent.type = 5;
printk(KERN_INFO " %s: %s\n", pr_info(" %s: %s\n", vendor_fields[ent.type - 1], name);
vendor_fields[ent.type-1], name);
} }
return 0; return 0;
} }
@ -656,9 +644,8 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot,
struct nubus_dirent ent; struct nubus_dirent ent;
nubus_get_subdir(parent, &dir); nubus_get_subdir(parent, &dir);
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) pr_debug("%s: parent is 0x%p, dir is 0x%p\n",
printk(KERN_DEBUG "nubus_get_board_resource: parent is 0x%p, dir is 0x%p\n", __func__, parent->base, dir.base);
parent->base, dir.base);
while(nubus_readdir(&dir, &ent) != -1) while(nubus_readdir(&dir, &ent) != -1)
{ {
@ -670,38 +657,37 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot,
useful except insofar as it tells us that useful except insofar as it tells us that
we really are looking at a board resource. */ we really are looking at a board resource. */
nubus_get_rsrc_mem(nbtdata, &ent, 8); nubus_get_rsrc_mem(nbtdata, &ent, 8);
printk(KERN_INFO " type: [cat 0x%x type 0x%x hw 0x%x sw 0x%x]\n", pr_info(" type: [cat 0x%x type 0x%x sw 0x%x hw 0x%x]\n",
nbtdata[0], nbtdata[1], nbtdata[2], nbtdata[0], nbtdata[1], nbtdata[2], nbtdata[3]);
nbtdata[3]);
if (nbtdata[0] != 1 || nbtdata[1] != 0 || if (nbtdata[0] != 1 || nbtdata[1] != 0 ||
nbtdata[2] != 0 || nbtdata[3] != 0) nbtdata[2] != 0 || nbtdata[3] != 0)
printk(KERN_ERR "this sResource is not a board resource!\n"); pr_err("this sResource is not a board resource!\n");
break; break;
} }
case NUBUS_RESID_NAME: case NUBUS_RESID_NAME:
nubus_get_rsrc_str(board->name, &ent, 64); nubus_get_rsrc_str(board->name, &ent, 64);
printk(KERN_INFO " name: %s\n", board->name); pr_info(" name: %s\n", board->name);
break; break;
case NUBUS_RESID_ICON: case NUBUS_RESID_ICON:
nubus_get_icon(board, &ent); nubus_get_icon(board, &ent);
break; break;
case NUBUS_RESID_BOARDID: case NUBUS_RESID_BOARDID:
printk(KERN_INFO " board id: 0x%x\n", ent.data); pr_info(" board id: 0x%x\n", ent.data);
break; break;
case NUBUS_RESID_PRIMARYINIT: case NUBUS_RESID_PRIMARYINIT:
printk(KERN_INFO " primary init offset: 0x%06x\n", ent.data); pr_info(" primary init offset: 0x%06x\n", ent.data);
break; break;
case NUBUS_RESID_VENDORINFO: case NUBUS_RESID_VENDORINFO:
nubus_get_vendorinfo(board, &ent); nubus_get_vendorinfo(board, &ent);
break; break;
case NUBUS_RESID_FLAGS: case NUBUS_RESID_FLAGS:
printk(KERN_INFO " flags: 0x%06x\n", ent.data); pr_info(" flags: 0x%06x\n", ent.data);
break; break;
case NUBUS_RESID_HWDEVID: case NUBUS_RESID_HWDEVID:
printk(KERN_INFO " hwdevid: 0x%06x\n", ent.data); pr_info(" hwdevid: 0x%06x\n", ent.data);
break; break;
case NUBUS_RESID_SECONDINIT: case NUBUS_RESID_SECONDINIT:
printk(KERN_INFO " secondary init offset: 0x%06x\n", ent.data); pr_info(" secondary init offset: 0x%06x\n", ent.data);
break; break;
/* WTF isn't this in the functional resources? */ /* WTF isn't this in the functional resources? */
case NUBUS_RESID_VIDNAMES: case NUBUS_RESID_VIDNAMES:
@ -709,11 +695,11 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot,
break; break;
/* Same goes for this */ /* Same goes for this */
case NUBUS_RESID_VIDMODES: case NUBUS_RESID_VIDMODES:
printk(KERN_INFO " video mode parameter directory offset: 0x%06x\n", pr_info(" video mode parameter directory offset: 0x%06x\n",
ent.data); ent.data);
break; break;
default: default:
printk(KERN_INFO " unknown resource %02X, data 0x%06x\n", pr_info(" unknown resource %02X, data 0x%06x\n",
ent.type, ent.data); ent.type, ent.data);
} }
} }
@ -818,21 +804,17 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
board->fblock = rp; board->fblock = rp;
/* Dump the format block for debugging purposes */ /* Dump the format block for debugging purposes */
if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) { pr_debug("Slot %X, format block at 0x%p:\n", slot, rp);
int i; pr_debug("%02lx\n", nubus_get_rom(&rp, 1, bytelanes));
printk(KERN_DEBUG "Slot %X, format block at 0x%p\n", pr_debug("%02lx\n", nubus_get_rom(&rp, 1, bytelanes));
slot, rp); pr_debug("%08lx\n", nubus_get_rom(&rp, 4, bytelanes));
printk(KERN_DEBUG "Format block: "); pr_debug("%02lx\n", nubus_get_rom(&rp, 1, bytelanes));
for (i = 0; i < FORMAT_BLOCK_SIZE; i += 4) { pr_debug("%02lx\n", nubus_get_rom(&rp, 1, bytelanes));
unsigned short foo, bar; pr_debug("%08lx\n", nubus_get_rom(&rp, 4, bytelanes));
foo = nubus_get_rom(&rp, 2, bytelanes); pr_debug("%08lx\n", nubus_get_rom(&rp, 4, bytelanes));
bar = nubus_get_rom(&rp, 2, bytelanes); pr_debug("%08lx\n", nubus_get_rom(&rp, 4, bytelanes));
printk("%04x %04x ", foo, bar); rp = board->fblock;
}
printk("\n");
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);
@ -850,10 +832,10 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
/* Directory offset should be small and negative... */ /* Directory offset should be small and negative... */
if(!(board->doffset & 0x00FF0000)) if(!(board->doffset & 0x00FF0000))
printk(KERN_WARNING "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)
printk(KERN_WARNING "Wrong test pattern %08lx!\n", dpat); pr_warn("Wrong test pattern %08lx!\n", dpat);
/* /*
* I wonder how the CRC is meant to work - * I wonder how the CRC is meant to work -
@ -867,7 +849,7 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
nubus_get_root_dir(board, &dir); nubus_get_root_dir(board, &dir);
/* We're ready to rock */ /* We're ready to rock */
printk(KERN_INFO "Slot %X:\n", slot); pr_info("Slot %X:\n", slot);
/* Each slot should have one board resource and any number of /* Each slot should have one board resource and any number of
functional resources. So we'll fill in some fields in the functional resources. So we'll fill in some fields in the
@ -876,10 +858,10 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
for each of them. */ for each of them. */
if (nubus_readdir(&dir, &ent) == -1) { if (nubus_readdir(&dir, &ent) == -1) {
/* We can't have this! */ /* We can't have this! */
printk(KERN_ERR "Board resource not found!\n"); pr_err("Board resource not found!\n");
return NULL; return NULL;
} else { } else {
printk(KERN_INFO " Board resource:\n"); pr_info(" Board resource:\n");
nubus_get_board_resource(board, slot, &ent); nubus_get_board_resource(board, slot, &ent);
} }
@ -929,7 +911,6 @@ void __init nubus_probe_slot(int slot)
if (!card_present) if (!card_present)
continue; continue;
printk(KERN_DEBUG "Now probing slot %X at %p\n", slot, rp);
dp = *rp; dp = *rp;
if(dp == 0) if(dp == 0)
continue; continue;
@ -984,7 +965,7 @@ static int __init nubus_init(void)
#endif #endif
/* And probe */ /* And probe */
printk("NuBus: Scanning NuBus slots.\n"); pr_info("NuBus: Scanning NuBus slots.\n");
nubus_devices = NULL; nubus_devices = NULL;
nubus_boards = NULL; nubus_boards = NULL;
nubus_scan_bus(); nubus_scan_bus();