LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/2] x86,earlyptink: use macros which are already defined
@ 2015-01-23 17:50 Alexander Kuleshov
  2015-01-23 17:51 ` [PATCH 1/2] x86/boot/earlyprintk: " Alexander Kuleshov
  2015-01-23 17:51 ` [PATCH 2/2] x86/kernel/earlyprintk: " Alexander Kuleshov
  0 siblings, 2 replies; 3+ messages in thread
From: Alexander Kuleshov @ 2015-01-23 17:50 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: H. Peter Anvin, Ingo Molnar, x86, linux-kernel

It's better to use macros which already defined. <linux/serial_reg.h> already
contains macros for initialization and work with serial port, but with another
names.

Alexander Kuleshov (2):
  x86/boot/early_serial: use macros which are already defined
  x86/kernel/early_printk: use macros which are already defined

 arch/x86/boot/boot.h                 |  1 +
 arch/x86/boot/compressed/misc.c      |  9 +++-----
 arch/x86/boot/compressed/misc.h      |  1 +
 arch/x86/boot/early_serial_console.c | 44 ++++++++++++------------------------
 arch/x86/boot/tty.c                  | 10 +++-----
 arch/x86/kernel/early_printk.c       | 40 +++++++++++---------------------
 6 files changed, 35 insertions(+), 70 deletions(-)

--
2.3.0.rc1.275.g028c360

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] x86/boot/earlyprintk: use macros which are already defined
  2015-01-23 17:50 [PATCH 0/2] x86,earlyptink: use macros which are already defined Alexander Kuleshov
@ 2015-01-23 17:51 ` Alexander Kuleshov
  2015-01-23 17:51 ` [PATCH 2/2] x86/kernel/earlyprintk: " Alexander Kuleshov
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Kuleshov @ 2015-01-23 17:51 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: H. Peter Anvin, Ingo Molnar, x86, linux-kernel, Alexander Kuleshov

Use macros which are already defined at <linux/serial_reg.h> for early
initialization of serial port and work with it.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 arch/x86/boot/boot.h                 |  1 +
 arch/x86/boot/compressed/misc.c      |  9 +++-----
 arch/x86/boot/compressed/misc.h      |  1 +
 arch/x86/boot/early_serial_console.c | 44 ++++++++++++------------------------
 arch/x86/boot/tty.c                  | 10 +++-----
 5 files changed, 22 insertions(+), 43 deletions(-)

diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index bd49ec6..f09becb 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -23,6 +23,7 @@
 #include <stdarg.h>
 #include <linux/types.h>
 #include <linux/edd.h>
+#include <linux/serial_reg.h>
 #include <asm/boot.h>
 #include <asm/setup.h>
 #include "bitops.h"
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index dcc1c53..df9bf76 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -156,18 +156,15 @@ static void scroll(void)
 		vidmem[i] = ' ';
 }

-#define XMTRDY          0x20
-
-#define TXR             0       /*  Transmit register (WRITE) */
-#define LSR             5       /*  Line Status               */
 static void serial_putchar(int ch)
 {
 	unsigned timeout = 0xffff;

-	while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+	while ((inb(early_serial_base + UART_LSR) & UART_LSR_THRE) == 0 &&
+	       --timeout)
 		cpu_relax();

-	outb(ch, early_serial_base + TXR);
+	outb(ch, early_serial_base + UART_TX);
 }

 void __putstr(const char *s)
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 24e3e56..3f5eaaa 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -15,6 +15,7 @@
 #include <linux/screen_info.h>
 #include <linux/elf.h>
 #include <linux/io.h>
+#include <linux/serial_reg.h>
 #include <asm/page.h>
 #include <asm/boot.h>
 #include <asm/bootparam.h>
diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 5df2869..bcac6b9 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -2,22 +2,6 @@

 #define DEFAULT_SERIAL_PORT 0x3f8 /* ttyS0 */

-#define XMTRDY          0x20
-
-#define DLAB		0x80
-
-#define TXR             0       /*  Transmit register (WRITE) */
-#define RXR             0       /*  Receive register  (READ)  */
-#define IER             1       /*  Interrupt Enable          */
-#define IIR             2       /*  Interrupt ID              */
-#define FCR             2       /*  FIFO control              */
-#define LCR             3       /*  Line control              */
-#define MCR             4       /*  Modem control             */
-#define LSR             5       /*  Line Status               */
-#define MSR             6       /*  Modem Status              */
-#define DLL             0       /*  Divisor Latch Low         */
-#define DLH             1       /*  Divisor latch High        */
-
 #define DEFAULT_BAUD 9600

 static void early_serial_init(int port, int baud)
@@ -25,17 +9,17 @@ static void early_serial_init(int port, int baud)
 	unsigned char c;
 	unsigned divisor;

-	outb(0x3, port + LCR);	/* 8n1 */
-	outb(0, port + IER);	/* no interrupt */
-	outb(0, port + FCR);	/* no fifo */
-	outb(0x3, port + MCR);	/* DTR + RTS */
+	outb(0x3, port + UART_LCR);/* 8n1 */
+	outb(0, port + UART_IER); /* no interrupt */
+	outb(0, port + UART_FCR); /* no fifo */
+	outb(0x3, port + UART_MCR);	  /* DTR + RTS */

 	divisor	= 115200 / baud;
-	c = inb(port + LCR);
-	outb(c | DLAB, port + LCR);
-	outb(divisor & 0xff, port + DLL);
-	outb((divisor >> 8) & 0xff, port + DLH);
-	outb(c & ~DLAB, port + LCR);
+	c = inb(port + UART_LCR);
+	outb(c | UART_LCR_DLAB, port + UART_LCR);
+	outb(divisor & 0xff, port + UART_DLL);
+	outb((divisor >> 8) & 0xff, port + UART_DLM);
+	outb(c & ~UART_LCR_DLAB, port + UART_LCR);

 	early_serial_base = port;
 }
@@ -101,11 +85,11 @@ static unsigned int probe_baud(int port)
 	unsigned char lcr, dll, dlh;
 	unsigned int quot;

-	lcr = inb(port + LCR);
-	outb(lcr | DLAB, port + LCR);
-	dll = inb(port + DLL);
-	dlh = inb(port + DLH);
-	outb(lcr, port + LCR);
+	lcr = inb(port + UART_LCR);
+	outb(lcr | UART_LCR_DLAB, port + UART_LCR);
+	dll = inb(port + UART_DLL);
+	dlh = inb(port + UART_DLM);
+	outb(lcr, port + UART_LCR);
 	quot = (dlh << 8) | dll;

 	return BASE_BAUD / quot;
diff --git a/arch/x86/boot/tty.c b/arch/x86/boot/tty.c
index def2451..93ce9d6d 100644
--- a/arch/x86/boot/tty.c
+++ b/arch/x86/boot/tty.c
@@ -17,11 +17,6 @@

 int early_serial_base;

-#define XMTRDY          0x20
-
-#define TXR             0       /*  Transmit register (WRITE) */
-#define LSR             5       /*  Line Status               */
-
 /*
  * These functions are in .inittext so they can be used to signal
  * error during initialization.
@@ -31,10 +26,11 @@ static void __attribute__((section(".inittext"))) serial_putchar(int ch)
 {
 	unsigned timeout = 0xffff;

-	while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+	while ((inb(early_serial_base + UART_LSR) & UART_LSR_THRE) == 0 &&
+	       --timeout)
 		cpu_relax();

-	outb(ch, early_serial_base + TXR);
+	outb(ch, early_serial_base + UART_TX);
 }

 static void __attribute__((section(".inittext"))) bios_putchar(int ch)
--
2.3.0.rc1.275.g028c360

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] x86/kernel/earlyprintk: use macros which are already defined
  2015-01-23 17:50 [PATCH 0/2] x86,earlyptink: use macros which are already defined Alexander Kuleshov
  2015-01-23 17:51 ` [PATCH 1/2] x86/boot/earlyprintk: " Alexander Kuleshov
@ 2015-01-23 17:51 ` Alexander Kuleshov
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Kuleshov @ 2015-01-23 17:51 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: H. Peter Anvin, Ingo Molnar, x86, linux-kernel, Alexander Kuleshov

Use macros which are already defined at <linux/serial_reg.h> for earlyprintk.

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
 arch/x86/kernel/early_printk.c | 40 +++++++++++++---------------------------
 1 file changed, 13 insertions(+), 27 deletions(-)

diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 01d1c18..99ff7ee 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -7,6 +7,7 @@
 #include <linux/pci_regs.h>
 #include <linux/pci_ids.h>
 #include <linux/errno.h>
+#include <linux/serial_reg.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 #include <asm/fcntl.h>
@@ -78,29 +79,14 @@ static struct console early_vga_console = {

 static int early_serial_base = 0x3f8;  /* ttyS0 */

-#define XMTRDY          0x20
-
-#define DLAB		0x80
-
-#define TXR             0       /*  Transmit register (WRITE) */
-#define RXR             0       /*  Receive register  (READ)  */
-#define IER             1       /*  Interrupt Enable          */
-#define IIR             2       /*  Interrupt ID              */
-#define FCR             2       /*  FIFO control              */
-#define LCR             3       /*  Line control              */
-#define MCR             4       /*  Modem control             */
-#define LSR             5       /*  Line Status               */
-#define MSR             6       /*  Modem Status              */
-#define DLL             0       /*  Divisor Latch Low         */
-#define DLH             1       /*  Divisor latch High        */
-
 static int early_serial_putc(unsigned char ch)
 {
 	unsigned timeout = 0xffff;

-	while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+	while ((inb(early_serial_base + UART_LSR) & UART_LSR_THRE) == 0 &&
+	       --timeout)
 		cpu_relax();
-	outb(ch, early_serial_base + TXR);
+	outb(ch, early_serial_base + UART_TX);
 	return timeout ? 0 : -1;
 }

@@ -145,10 +131,10 @@ static __init void early_serial_init(char *s)
 			s++;
 	}

-	outb(0x3, early_serial_base + LCR);	/* 8n1 */
-	outb(0, early_serial_base + IER);	/* no interrupt */
-	outb(0, early_serial_base + FCR);	/* no fifo */
-	outb(0x3, early_serial_base + MCR);	/* DTR + RTS */
+	outb(0x3, early_serial_base + UART_LCR);	/* 8n1 */
+	outb(0, early_serial_base + UART_IER);		/* no interrupt */
+	outb(0, early_serial_base + UART_FCR);		/* no fifo */
+	outb(0x3, early_serial_base + UART_MCR);	/* DTR + RTS */

 	if (*s) {
 		baud = simple_strtoul(s, &e, 0);
@@ -157,11 +143,11 @@ static __init void early_serial_init(char *s)
 	}

 	divisor = 115200 / baud;
-	c = inb(early_serial_base + LCR);
-	outb(c | DLAB, early_serial_base + LCR);
-	outb(divisor & 0xff, early_serial_base + DLL);
-	outb((divisor >> 8) & 0xff, early_serial_base + DLH);
-	outb(c & ~DLAB, early_serial_base + LCR);
+	c = inb(early_serial_base + UART_LCR);
+	outb(c | UART_LCR_DLAB, early_serial_base + UART_LCR);
+	outb(divisor & 0xff, early_serial_base + UART_DLL);
+	outb((divisor >> 8) & 0xff, early_serial_base + UART_DLM);
+	outb(c & ~UART_LCR_DLAB, early_serial_base + UART_LCR);
 }

 static struct console early_serial_console = {
--
2.3.0.rc1.275.g028c360

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-23 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-23 17:50 [PATCH 0/2] x86,earlyptink: use macros which are already defined Alexander Kuleshov
2015-01-23 17:51 ` [PATCH 1/2] x86/boot/earlyprintk: " Alexander Kuleshov
2015-01-23 17:51 ` [PATCH 2/2] x86/kernel/earlyprintk: " Alexander Kuleshov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).