From 4629a173aa10a5044597a15c6d9690be78969f5b Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sat, 8 Apr 2017 19:51:15 -0400 Subject: m68k/mac: IOP - Modernize printing of kernel messages - Introduce helpers for printing debug messages, incl. dummies for validating format strings when debugging is disabled, - Convert from printk() to pr_*(), - Add missing continuations, - Drop superfluous casts. Signed-off-by: Geert Uytterhoeven [FT: Renamed pr_iop* macros, adjusted log message severity and eliminated DEBUG_IOP] Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/iop.c | 74 +++++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 45 deletions(-) (limited to 'arch/m68k') diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c index 7990b6f50105..1746cfc758a0 100644 --- a/arch/m68k/mac/iop.c +++ b/arch/m68k/mac/iop.c @@ -115,7 +115,17 @@ #include #include -/*#define DEBUG_IOP*/ +#ifdef DEBUG +#define iop_pr_debug(fmt, ...) \ + printk(KERN_DEBUG "%s: " fmt, __func__, ##__VA_ARGS__) +#define iop_pr_cont(fmt, ...) \ + printk(KERN_CONT fmt, ##__VA_ARGS__) +#else +#define iop_pr_debug(fmt, ...) \ + no_printk(KERN_DEBUG "%s: " fmt, __func__, ##__VA_ARGS__) +#define iop_pr_cont(fmt, ...) \ + no_printk(KERN_CONT fmt, ##__VA_ARGS__) +#endif /* Non-zero if the IOPs are present */ @@ -268,10 +278,10 @@ void __init iop_init(void) int i; if (iop_scc_present) { - printk("IOP: detected SCC IOP at %p\n", iop_base[IOP_NUM_SCC]); + pr_info("IOP: detected SCC IOP at %p\n", iop_base[IOP_NUM_SCC]); } if (iop_ism_present) { - printk("IOP: detected ISM IOP at %p\n", iop_base[IOP_NUM_ISM]); + pr_info("IOP: detected ISM IOP at %p\n", iop_base[IOP_NUM_ISM]); iop_start(iop_base[IOP_NUM_ISM]); iop_alive(iop_base[IOP_NUM_ISM]); /* clears the alive flag */ } @@ -310,9 +320,9 @@ void __init iop_register_interrupts(void) pr_err("Couldn't register ISM IOP interrupt\n"); } if (!iop_alive(iop_base[IOP_NUM_ISM])) { - printk("IOP: oh my god, they killed the ISM IOP!\n"); + pr_warn("IOP: oh my god, they killed the ISM IOP!\n"); } else { - printk("IOP: the ISM IOP seems to be alive.\n"); + pr_warn("IOP: the ISM IOP seems to be alive.\n"); } } } @@ -349,9 +359,8 @@ void iop_complete_message(struct iop_msg *msg) int chan = msg->channel; int i,offset; -#ifdef DEBUG_IOP - printk("iop_complete(%p): iop %d chan %d\n", msg, msg->iop_num, msg->channel); -#endif + iop_pr_debug("msg %p iop_num %d channel %d\n", msg, msg->iop_num, + msg->channel); offset = IOP_ADDR_RECV_MSG + (msg->channel * IOP_MSG_LEN); @@ -397,9 +406,7 @@ static void iop_handle_send(uint iop_num, uint chan) struct iop_msg *msg,*msg2; int i,offset; -#ifdef DEBUG_IOP - printk("iop_handle_send: iop %d channel %d\n", iop_num, chan); -#endif + iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); iop_writeb(iop, IOP_ADDR_SEND_STATE + chan, IOP_MSG_IDLE); @@ -430,9 +437,7 @@ static void iop_handle_recv(uint iop_num, uint chan) int i,offset; struct iop_msg *msg; -#ifdef DEBUG_IOP - printk("iop_handle_recv: iop %d channel %d\n", iop_num, chan); -#endif + iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); msg = iop_alloc_msg(); msg->iop_num = iop_num; @@ -454,14 +459,9 @@ static void iop_handle_recv(uint iop_num, uint chan) if (msg->handler) { (*msg->handler)(msg); } else { -#ifdef DEBUG_IOP - printk("iop_handle_recv: unclaimed message on iop %d channel %d\n", iop_num, chan); - printk("iop_handle_recv:"); - for (i = 0 ; i < IOP_MSG_LEN ; i++) { - printk(" %02X", (uint) msg->message[i]); - } - printk("\n"); -#endif + iop_pr_debug("unclaimed message on iop_num %d chan %d\n", + iop_num, chan); + iop_pr_debug("%*ph\n", IOP_MSG_LEN, msg->message); iop_complete_message(msg); } } @@ -574,50 +574,34 @@ irqreturn_t iop_ism_irq(int irq, void *dev_id) volatile struct mac_iop *iop = iop_base[iop_num]; int i,state; -#ifdef DEBUG_IOP - printk("iop_ism_irq: status = %02X\n", (uint) iop->status_ctrl); -#endif + iop_pr_debug("status %02X\n", iop->status_ctrl); /* INT0 indicates a state change on an outgoing message channel */ if (iop->status_ctrl & IOP_INT0) { iop->status_ctrl = IOP_INT0 | IOP_RUN | IOP_AUTOINC; -#ifdef DEBUG_IOP - printk("iop_ism_irq: new status = %02X, send states", - (uint) iop->status_ctrl); -#endif + iop_pr_debug("new status %02X, send states", iop->status_ctrl); for (i = 0 ; i < NUM_IOP_CHAN ; i++) { state = iop_readb(iop, IOP_ADDR_SEND_STATE + i); -#ifdef DEBUG_IOP - printk(" %02X", state); -#endif + iop_pr_cont(" %02X", state); if (state == IOP_MSG_COMPLETE) { iop_handle_send(iop_num, i); } } -#ifdef DEBUG_IOP - printk("\n"); -#endif + iop_pr_cont("\n"); } if (iop->status_ctrl & IOP_INT1) { /* INT1 for incoming msgs */ iop->status_ctrl = IOP_INT1 | IOP_RUN | IOP_AUTOINC; -#ifdef DEBUG_IOP - printk("iop_ism_irq: new status = %02X, recv states", - (uint) iop->status_ctrl); -#endif + iop_pr_debug("new status %02X, recv states", iop->status_ctrl); for (i = 0 ; i < NUM_IOP_CHAN ; i++) { state = iop_readb(iop, IOP_ADDR_RECV_STATE + i); -#ifdef DEBUG_IOP - printk(" %02X", state); -#endif + iop_pr_cont(" %02X", state); if (state == IOP_MSG_NEW) { iop_handle_recv(iop_num, i); } } -#ifdef DEBUG_IOP - printk("\n"); -#endif + iop_pr_cont("\n"); } return IRQ_HANDLED; } -- cgit v1.2.3 From 889121b404d9e313fb9ebeb99b25ff4a24e6a7f7 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Sat, 8 Apr 2017 19:51:15 -0400 Subject: m68k/mac: Modernize printing of kernel messages Convert from printk() to pr_*(). Signed-off-by: Geert Uytterhoeven [FT: Adjusted log message severity levels and retained bootinfo log] Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/config.c | 12 +++++------- arch/m68k/mac/misc.c | 23 +++++++++-------------- 2 files changed, 14 insertions(+), 21 deletions(-) (limited to 'arch/m68k') diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 9dc65a4c28d2..661892d57f79 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -150,7 +150,7 @@ static void mac_cache_card_flush(int writeback) void __init config_mac(void) { if (!MACH_IS_MAC) - printk(KERN_ERR "ERROR: no Mac, but config_mac() called!!\n"); + pr_err("ERROR: no Mac, but config_mac() called!!\n"); mach_sched_init = mac_sched_init; mach_init_IRQ = mac_init_IRQ; @@ -837,8 +837,7 @@ static void __init mac_identify(void) /* no bootinfo model id -> NetBSD booter was used! */ /* XXX FIXME: breaks for model > 31 */ model = (mac_bi_data.cpuid >> 2) & 63; - printk(KERN_WARNING "No bootinfo model ID, using cpuid instead " - "(obsolete bootloader?)\n"); + pr_warn("No bootinfo model ID, using cpuid instead (obsolete bootloader?)\n"); } macintosh_config = mac_data_table; @@ -880,14 +879,13 @@ static void __init mac_identify(void) */ iop_preinit(); - printk(KERN_INFO "Detected Macintosh model: %d\n", model); + pr_info("Detected Macintosh model: %d\n", model); /* * Report booter data: */ printk(KERN_DEBUG " Penguin bootinfo data:\n"); - printk(KERN_DEBUG " Video: addr 0x%lx " - "row 0x%lx depth %lx dimensions %ld x %ld\n", + printk(KERN_DEBUG " Video: addr 0x%lx row 0x%lx depth %lx dimensions %ld x %ld\n", mac_bi_data.videoaddr, mac_bi_data.videorow, mac_bi_data.videodepth, mac_bi_data.dimensions & 0xFFFF, mac_bi_data.dimensions >> 16); @@ -912,7 +910,7 @@ static void __init mac_identify(void) static void __init mac_report_hardware(void) { - printk(KERN_INFO "Apple Macintosh %s\n", macintosh_config->name); + pr_info("Apple Macintosh %s\n", macintosh_config->name); } static void mac_get_model(char *str) diff --git a/arch/m68k/mac/misc.c b/arch/m68k/mac/misc.c index 5b01704c85eb..8aa8792e3174 100644 --- a/arch/m68k/mac/misc.c +++ b/arch/m68k/mac/misc.c @@ -281,8 +281,7 @@ static long via_read_time(void) last_result.idata = result.idata; } - pr_err("via_read_time: failed to read a stable value; " - "got 0x%08lx then 0x%08lx\n", + pr_err("via_read_time: failed to read a stable value; got 0x%08lx then 0x%08lx\n", last_result.idata, result.idata); return 0; @@ -465,7 +464,7 @@ void mac_poweroff(void) #endif } local_irq_enable(); - printk("It is now safe to turn off your Macintosh.\n"); + pr_crit("It is now safe to turn off your Macintosh.\n"); while(1); } @@ -556,7 +555,7 @@ void mac_reset(void) /* should never get here */ local_irq_enable(); - printk ("Restart failed. Please restart manually.\n"); + pr_crit("Restart failed. Please restart manually.\n"); while(1); } @@ -661,17 +660,13 @@ int mac_hwclk(int op, struct rtc_time *t) unmktime(now, 0, &t->tm_year, &t->tm_mon, &t->tm_mday, &t->tm_hour, &t->tm_min, &t->tm_sec); -#if 0 - printk("mac_hwclk: read %04d-%02d-%-2d %02d:%02d:%02d\n", - t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); -#endif + pr_debug("%s: read %04d-%02d-%-2d %02d:%02d:%02d\n", + __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); } else { /* write */ -#if 0 - printk("mac_hwclk: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n", - t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); -#endif + pr_debug("%s: tried to write %04d-%02d-%-2d %02d:%02d:%02d\n", + __func__, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); now = mktime(t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec); -- cgit v1.2.3 From a9373f40ac3a5aac4b9a199a15331708616e8947 Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Sat, 8 Apr 2017 19:51:15 -0400 Subject: m68k/mac: Adopt platform_device_register_simple() These changes save 1014 bytes according to scripts/bloat-o-meter. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/config.c | 49 ++++++++++++------------------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) (limited to 'arch/m68k') diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c index 661892d57f79..22123f7e8f75 100644 --- a/arch/m68k/mac/config.c +++ b/arch/m68k/mac/config.c @@ -919,15 +919,6 @@ static void mac_get_model(char *str) strcat(str, macintosh_config->name); } -static struct resource swim_rsrc = { .flags = IORESOURCE_MEM }; - -static struct platform_device swim_pdev = { - .name = "swim", - .id = -1, - .num_resources = 1, - .resource = &swim_rsrc, -}; - static const struct resource mac_scsi_iifx_rsrc[] __initconst = { { .flags = IORESOURCE_IRQ, @@ -992,26 +983,6 @@ static const struct resource mac_scsi_ccl_rsrc[] __initconst = { }, }; -static struct platform_device esp_0_pdev = { - .name = "mac_esp", - .id = 0, -}; - -static struct platform_device esp_1_pdev = { - .name = "mac_esp", - .id = 1, -}; - -static struct platform_device sonic_pdev = { - .name = "macsonic", - .id = -1, -}; - -static struct platform_device mace_pdev = { - .name = "macmace", - .id = -1, -}; - int __init mac_platform_init(void) { u8 *swim_base; @@ -1043,9 +1014,13 @@ int __init mac_platform_init(void) } if (swim_base) { - swim_rsrc.start = (resource_size_t) swim_base, - swim_rsrc.end = (resource_size_t) swim_base + 0x2000, - platform_device_register(&swim_pdev); + struct resource swim_rsrc = { + .flags = IORESOURCE_MEM, + .start = (resource_size_t)swim_base, + .end = (resource_size_t)swim_base + 0x2000, + }; + + platform_device_register_simple("swim", -1, &swim_rsrc, 1); } /* @@ -1055,13 +1030,13 @@ int __init mac_platform_init(void) switch (macintosh_config->scsi_type) { case MAC_SCSI_QUADRA: case MAC_SCSI_QUADRA3: - platform_device_register(&esp_0_pdev); + platform_device_register_simple("mac_esp", 0, NULL, 0); break; case MAC_SCSI_QUADRA2: - platform_device_register(&esp_0_pdev); + platform_device_register_simple("mac_esp", 0, NULL, 0); if ((macintosh_config->ident == MAC_MODEL_Q900) || (macintosh_config->ident == MAC_MODEL_Q950)) - platform_device_register(&esp_1_pdev); + platform_device_register_simple("mac_esp", 1, NULL, 0); break; case MAC_SCSI_IIFX: /* Addresses from The Guide to Mac Family Hardware. @@ -1127,10 +1102,10 @@ int __init mac_platform_init(void) switch (macintosh_config->ether_type) { case MAC_ETHER_SONIC: - platform_device_register(&sonic_pdev); + platform_device_register_simple("macsonic", -1, NULL, 0); break; case MAC_ETHER_MACE: - platform_device_register(&mace_pdev); + platform_device_register_simple("macmace", -1, NULL, 0); break; } -- cgit v1.2.3 From af2325024fe2dcbb9722d1b4c253a377076b1eed Mon Sep 17 00:00:00 2001 From: Finn Thain Date: Sat, 8 Apr 2017 19:51:15 -0400 Subject: m68k/mac: Clarify IOP message alloc/free confusion The alloc/free metaphor used for IOP messages is misleading and can cause mistakes like the pointless msg2 temporary variable. Use a more meaningful name to help simplify the code. Signed-off-by: Finn Thain Signed-off-by: Geert Uytterhoeven --- arch/m68k/mac/iop.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'arch/m68k') diff --git a/arch/m68k/mac/iop.c b/arch/m68k/mac/iop.c index 1746cfc758a0..4c1e606e7d03 100644 --- a/arch/m68k/mac/iop.c +++ b/arch/m68k/mac/iop.c @@ -210,7 +210,7 @@ static int iop_alive(volatile struct mac_iop *iop) return retval; } -static struct iop_msg *iop_alloc_msg(void) +static struct iop_msg *iop_get_unused_msg(void) { int i; unsigned long flags; @@ -229,11 +229,6 @@ static struct iop_msg *iop_alloc_msg(void) return NULL; } -static void iop_free_msg(struct iop_msg *msg) -{ - msg->status = IOP_MSGSTATUS_UNUSED; -} - /* * This is called by the startup code before anything else. Its purpose * is to find and initialize the IOPs early in the boot sequence, so that @@ -372,7 +367,7 @@ void iop_complete_message(struct iop_msg *msg) IOP_ADDR_RECV_STATE + chan, IOP_MSG_COMPLETE); iop_interrupt(iop_base[msg->iop_num]); - iop_free_msg(msg); + msg->status = IOP_MSGSTATUS_UNUSED; } /* @@ -403,7 +398,7 @@ static void iop_do_send(struct iop_msg *msg) static void iop_handle_send(uint iop_num, uint chan) { volatile struct mac_iop *iop = iop_base[iop_num]; - struct iop_msg *msg,*msg2; + struct iop_msg *msg; int i,offset; iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); @@ -418,10 +413,8 @@ static void iop_handle_send(uint iop_num, uint chan) msg->reply[i] = iop_readb(iop, offset); } if (msg->handler) (*msg->handler)(msg); - msg2 = msg; + msg->status = IOP_MSGSTATUS_UNUSED; msg = msg->next; - iop_free_msg(msg2); - iop_send_queue[iop_num][chan] = msg; if (msg) iop_do_send(msg); } @@ -439,7 +432,7 @@ static void iop_handle_recv(uint iop_num, uint chan) iop_pr_debug("iop_num %d chan %d\n", iop_num, chan); - msg = iop_alloc_msg(); + msg = iop_get_unused_msg(); msg->iop_num = iop_num; msg->channel = chan; msg->status = IOP_MSGSTATUS_UNSOL; @@ -484,7 +477,7 @@ int iop_send_message(uint iop_num, uint chan, void *privdata, if (chan >= NUM_IOP_CHAN) return -EINVAL; if (msg_len > IOP_MSG_LEN) return -EINVAL; - msg = iop_alloc_msg(); + msg = iop_get_unused_msg(); if (!msg) return -ENOMEM; msg->next = NULL; -- cgit v1.2.3