Skip to content

Commit

Permalink
mips: unify prom_putchar() declarations
Browse files Browse the repository at this point in the history
prom_putchar() is used centrally in early printk infrastructure therefore
at least MIPS should agree on the function return type.

[paul.burton@mips.com:
  - Include linux/types.h in asm/setup.h to gain the bool typedef before
    we start include asm/setup.h elsewhere.
  - Include asm/setup.h in all files that use or define prom_putchar().
  - Also standardise on signed rather than unsigned char argument.]

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Signed-off-by: Paul Burton <paul.burton@mips.com>
Patchwork: https://patchwork.linux-mips.org/patch/19842/
Cc: linux-mips@linux-mips.org
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: James Hogan <jhogan@kernel.org>
Cc: Jonas Gorski <jonas.gorski@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Kate Stewart <kstewart@linuxfoundation.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
  • Loading branch information
asverdlin authored and paulburton committed Jul 17, 2018
1 parent 4936084 commit 5c93316
Show file tree
Hide file tree
Showing 28 changed files with 47 additions and 32 deletions.
3 changes: 2 additions & 1 deletion arch/mips/alchemy/board-gpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <asm/bootinfo.h>
#include <asm/idle.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
#include <asm/mach-au1x00/gpio-au1000.h>
#include <prom.h>
Expand All @@ -60,7 +61,7 @@ void __init prom_init(void)
add_memory_region(0, memsize, BOOT_MEM_RAM);
}

void prom_putchar(unsigned char c)
void prom_putchar(char c)
{
alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
}
Expand Down
3 changes: 2 additions & 1 deletion arch/mips/alchemy/board-mtx1.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <mtd/mtd-abi.h>
#include <asm/bootinfo.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
#include <asm/mach-au1x00/gpio-au1000.h>
#include <asm/mach-au1x00/au1xxx_eth.h>
Expand Down Expand Up @@ -58,7 +59,7 @@ void __init prom_init(void)
add_memory_region(0, memsize, BOOT_MEM_RAM);
}

void prom_putchar(unsigned char c)
void prom_putchar(char c)
{
alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
}
Expand Down
3 changes: 2 additions & 1 deletion arch/mips/alchemy/board-xxs1500.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <linux/pm.h>
#include <asm/bootinfo.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
#include <prom.h>

Expand All @@ -55,7 +56,7 @@ void __init prom_init(void)
add_memory_region(0, memsize, BOOT_MEM_RAM);
}

void prom_putchar(unsigned char c)
void prom_putchar(char c)
{
alchemy_uart_putchar(AU1000_UART0_PHYS_ADDR, c);
}
Expand Down
3 changes: 2 additions & 1 deletion arch/mips/alchemy/devboards/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <asm/bootinfo.h>
#include <asm/idle.h>
#include <asm/reboot.h>
#include <asm/setup.h>
#include <asm/mach-au1x00/au1000.h>
#include <asm/mach-db1x00/bcsr.h>

Expand All @@ -36,7 +37,7 @@ void __init prom_init(void)
add_memory_region(0, memsize, BOOT_MEM_RAM);
}

void prom_putchar(unsigned char c)
void prom_putchar(char c)
{
if (alchemy_get_cputype() == ALCHEMY_CPU_AU1300)
alchemy_uart_putchar(AU1300_UART2_PHYS_ADDR, c);
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/ar7/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <linux/string.h>
#include <linux/io.h>
#include <asm/bootinfo.h>
#include <asm/setup.h>

#include <asm/mach-ar7/ar7.h>
#include <asm/mach-ar7/prom.h>
Expand Down Expand Up @@ -259,10 +260,9 @@ static inline void serial_out(int offset, int value)
writel(value, (void *)PORT(offset));
}

int prom_putchar(char c)
void prom_putchar(char c)
{
while ((serial_in(UART_LSR) & UART_LSR_TEMT) == 0)
;
serial_out(UART_TX, c);
return 1;
}
5 changes: 3 additions & 2 deletions arch/mips/ath25/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/mm.h>
#include <linux/io.h>
#include <linux/serial_reg.h>
#include <asm/setup.h>

#include "devices.h"
#include "ar2315_regs.h"
Expand All @@ -25,7 +26,7 @@ static inline unsigned char prom_uart_rr(void __iomem *base, unsigned reg)
return __raw_readl(base + 4 * reg);
}

void prom_putchar(unsigned char ch)
void prom_putchar(char ch)
{
static void __iomem *base;

Expand All @@ -38,7 +39,7 @@ void prom_putchar(unsigned char ch)

while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
;
prom_uart_wr(base, UART_TX, ch);
prom_uart_wr(base, UART_TX, (unsigned char)ch);
while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
;
}
16 changes: 9 additions & 7 deletions arch/mips/ath79/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
#include <linux/errno.h>
#include <linux/serial_reg.h>
#include <asm/addrspace.h>
#include <asm/setup.h>

#include <asm/mach-ath79/ath79.h>
#include <asm/mach-ath79/ar71xx_regs.h>
#include <asm/mach-ath79/ar933x_uart.h>

static void (*_prom_putchar) (unsigned char);
static void (*_prom_putchar)(char);

static inline void prom_putchar_wait(void __iomem *reg, u32 mask, u32 val)
{
Expand All @@ -33,27 +34,28 @@ static inline void prom_putchar_wait(void __iomem *reg, u32 mask, u32 val)

#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)

static void prom_putchar_ar71xx(unsigned char ch)
static void prom_putchar_ar71xx(char ch)
{
void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE));

prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
__raw_writel(ch, base + UART_TX * 4);
__raw_writel((unsigned char)ch, base + UART_TX * 4);
prom_putchar_wait(base + UART_LSR * 4, BOTH_EMPTY, BOTH_EMPTY);
}

static void prom_putchar_ar933x(unsigned char ch)
static void prom_putchar_ar933x(char ch)
{
void __iomem *base = (void __iomem *)(KSEG1ADDR(AR933X_UART_BASE));

prom_putchar_wait(base + AR933X_UART_DATA_REG, AR933X_UART_DATA_TX_CSR,
AR933X_UART_DATA_TX_CSR);
__raw_writel(AR933X_UART_DATA_TX_CSR | ch, base + AR933X_UART_DATA_REG);
__raw_writel(AR933X_UART_DATA_TX_CSR | (unsigned char)ch,
base + AR933X_UART_DATA_REG);
prom_putchar_wait(base + AR933X_UART_DATA_REG, AR933X_UART_DATA_TX_CSR,
AR933X_UART_DATA_TX_CSR);
}

static void prom_putchar_dummy(unsigned char ch)
static void prom_putchar_dummy(char ch)
{
/* nothing to do */
}
Expand Down Expand Up @@ -92,7 +94,7 @@ static void prom_putchar_init(void)
}
}

void prom_putchar(unsigned char ch)
void prom_putchar(char ch)
{
if (!_prom_putchar)
prom_putchar_init();
Expand Down
1 change: 1 addition & 0 deletions arch/mips/bcm63xx/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <bcm63xx_io.h>
#include <linux/serial_bcm63xx.h>
#include <asm/setup.h>

static void wait_xfered(void)
{
Expand Down
3 changes: 1 addition & 2 deletions arch/mips/boot/compressed/uart-prom.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// SPDX-License-Identifier: GPL-2.0

extern void prom_putchar(unsigned char ch);
#include <asm/setup.h>

void putc(char c)
{
Expand Down
4 changes: 2 additions & 2 deletions arch/mips/cavium-octeon/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <asm/mipsregs.h>
#include <asm/bootinfo.h>
#include <asm/sections.h>
#include <asm/setup.h>
#include <asm/time.h>

#include <asm/octeon/octeon.h>
Expand Down Expand Up @@ -1108,7 +1109,7 @@ void __init plat_mem_setup(void)
* Emit one character to the boot UART. Exported for use by the
* watchdog timer.
*/
int prom_putchar(char c)
void prom_putchar(char c)
{
uint64_t lsrval;

Expand All @@ -1119,7 +1120,6 @@ int prom_putchar(char c)

/* Write the byte */
cvmx_write_csr(CVMX_MIO_UARTX_THR(octeon_uart), c & 0xffull);
return 1;
}
EXPORT_SYMBOL(prom_putchar);

Expand Down
1 change: 1 addition & 0 deletions arch/mips/fw/arc/arc_con.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <linux/init.h>
#include <linux/console.h>
#include <linux/fs.h>
#include <asm/setup.h>
#include <asm/sgialib.h>

static void prom_console_write(struct console *co, const char *s,
Expand Down
1 change: 1 addition & 0 deletions arch/mips/fw/arc/promlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/kernel.h>
#include <asm/sgialib.h>
#include <asm/bcache.h>
#include <asm/setup.h>

/*
* IP22 boardcache is not compatible with board caches. Thus we disable it
Expand Down
1 change: 1 addition & 0 deletions arch/mips/fw/sni/sniprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <asm/mipsprom.h>
#include <asm/mipsregs.h>
#include <asm/bootinfo.h>
#include <asm/setup.h>

/* special SNI prom calls */
/*
Expand Down
2 changes: 2 additions & 0 deletions arch/mips/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#ifndef _MIPS_SETUP_H
#define _MIPS_SETUP_H

#include <linux/types.h>
#include <uapi/asm/setup.h>

extern void prom_putchar(char);
extern void setup_early_printk(void);

#ifdef CONFIG_EARLY_PRINTK_8250
Expand Down
1 change: 0 additions & 1 deletion arch/mips/include/asm/sgialib.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ extern int prom_flags;
#define PROM_FLAG_DONT_FREE_TEMP 4

/* Simple char-by-char console I/O. */
extern void prom_putchar(char c);
extern char prom_getchar(void);

/* Get next memory descriptor after CURR, returns first descriptor
Expand Down
1 change: 0 additions & 1 deletion arch/mips/include/asm/txx9/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ void txx9_spi_init(int busid, unsigned long base, int irq);
void txx9_ethaddr_init(unsigned int id, unsigned char *ethaddr);
void txx9_sio_init(unsigned long baseaddr, int irq,
unsigned int line, unsigned int sclk, int nocts);
void prom_putchar(char c);
#ifdef CONFIG_EARLY_PRINTK
extern void (*txx9_prom_putchar)(char c);
void txx9_sio_putchar_init(unsigned long baseaddr);
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/kernel/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include <asm/setup.h>

extern void prom_putchar(char);

static void early_console_write(struct console *con, const char *s, unsigned n)
{
while (n-- && *s) {
Expand Down
1 change: 1 addition & 0 deletions arch/mips/kernel/early_printk_8250.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/io.h>
#include <linux/serial_core.h>
#include <linux/serial_reg.h>
#include <asm/setup.h>

static void __iomem *serial8250_base;
static unsigned int serial8250_reg_shift;
Expand Down
1 change: 1 addition & 0 deletions arch/mips/lantiq/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <linux/cpu.h>
#include <lantiq_soc.h>
#include <asm/setup.h>

#define ASC_BUF 1024
#define LTQ_ASC_FSTAT ((u32 *)(LTQ_EARLY_ASC + 0x0048))
Expand Down
1 change: 1 addition & 0 deletions arch/mips/lasat/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <asm/bootinfo.h>
#include <asm/lasat/lasat.h>
#include <asm/cpu.h>
#include <asm/setup.h>

#include "at93c.h"
#include <asm/lasat/eeprom.h>
Expand Down
1 change: 1 addition & 0 deletions arch/mips/loongson64/common/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* option) any later version.
*/
#include <linux/serial_reg.h>
#include <asm/setup.h>

#include <loongson.h>

Expand Down
1 change: 1 addition & 0 deletions arch/mips/netlogic/common/earlycons.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/serial_reg.h>

#include <asm/mipsregs.h>
#include <asm/setup.h>
#include <asm/netlogic/haldefs.h>
#include <asm/netlogic/common.h>

Expand Down
5 changes: 2 additions & 3 deletions arch/mips/paravirt/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
#include <linux/kernel.h>
#include <linux/virtio_console.h>
#include <linux/kvm_para.h>
#include <asm/setup.h>

/*
* Emit one character to the boot console.
*/
int prom_putchar(char c)
void prom_putchar(char c)
{
kvm_hypercall3(KVM_HC_MIPS_CONSOLE_OUTPUT, 0 /* port 0 */,
(unsigned long)&c, 1 /* len == 1 */);

return 1;
}

#ifdef CONFIG_VIRTIO_CONSOLE
Expand Down
5 changes: 2 additions & 3 deletions arch/mips/pic32/pic32mzda/early_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
#include <asm/mach-pic32/pic32.h>
#include <asm/fw/fw.h>
#include <asm/setup.h>

#include "pic32mzda.h"
#include "early_pin.h"
Expand Down Expand Up @@ -157,7 +158,7 @@ void __init fw_init_early_console(char port)
setup_early_console(port, baud);
}

int prom_putchar(char c)
void prom_putchar(char c)
{
if (console_port >= 0) {
while (__raw_readl(
Expand All @@ -166,6 +167,4 @@ int prom_putchar(char c)

__raw_writel(c, uart_base + U_TXR(console_port));
}

return 1;
}
7 changes: 4 additions & 3 deletions arch/mips/ralink/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/serial_reg.h>

#include <asm/addrspace.h>
#include <asm/setup.h>

#ifdef CONFIG_SOC_RT288X
#define EARLY_UART_BASE 0x300c00
Expand Down Expand Up @@ -68,21 +69,21 @@ static void find_uart_base(void)
}
}

void prom_putchar(unsigned char ch)
void prom_putchar(char ch)
{
if (!init_complete) {
find_uart_base();
init_complete = 1;
}

if (IS_ENABLED(CONFIG_SOC_MT7621) || soc_is_mt7628()) {
uart_w32(ch, UART_TX);
uart_w32((unsigned char)ch, UART_TX);
while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
;
} else {
while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0)
;
uart_w32(ch, UART_REG_TX);
uart_w32((unsigned char)ch, UART_REG_TX);
while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0)
;
}
Expand Down
1 change: 1 addition & 0 deletions arch/mips/sgi-ip27/ip27-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <asm/page.h>
#include <asm/setup.h>
#include <asm/sn/addrs.h>
#include <asm/sn/sn0/hub.h>
#include <asm/sn/klconfig.h>
Expand Down
Loading

0 comments on commit 5c93316

Please sign in to comment.