Message ID | 1445219487-24518-2-git-send-email-sjg@chromium.org |
---|---|
State | Accepted |
Delegated to: | Simon Glass |
Headers | show |
Hi Simon, On Mon, Oct 19, 2015 at 9:51 AM, Simon Glass <sjg@chromium.org> wrote: > We want to be able to add other common code to this function. So change the > driver's version to have an underscore before it, just like > _debug_uart_putc(). Define debug_uart_init() to call this version. > > Update all drivers to this new method. > > Signed-off-by: Simon Glass <sjg@chromium.org> > --- Reviewed-by: Bin Meng <bmeng.cn@gmail.com> > > Changes in v2: > - Adjust all _debug_uart_init() declarations to be static inline > > drivers/serial/ns16550.c | 2 +- > drivers/serial/serial_efi.c | 2 +- > drivers/serial/serial_s5p.c | 2 +- > include/debug_uart.h | 9 +++++++-- > lib/efi/efi_stub.c | 2 +- > 5 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c > index 6275a11..6433844 100644 > --- a/drivers/serial/ns16550.c > +++ b/drivers/serial/ns16550.c > @@ -257,7 +257,7 @@ int NS16550_tstc(NS16550_t com_port) > (1 << CONFIG_DEBUG_UART_SHIFT), \ > CONFIG_DEBUG_UART_SHIFT) > > -void debug_uart_init(void) > +static inline void _debug_uart_init(void) > { > struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; > int baud_divisor; > diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c > index cf57d89..ea25c25 100644 > --- a/drivers/serial/serial_efi.c > +++ b/drivers/serial/serial_efi.c > @@ -107,7 +107,7 @@ static int serial_efi_pending(struct udevice *dev, bool input) > * There is nothing to init here since the EFI console is already running by > * the time we enter U-Boot. > */ > -void debug_uart_init(void) > +static inline void _debug_uart_init(void) > { > } > > diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c > index 3f0b588..feba467 100644 > --- a/drivers/serial/serial_s5p.c > +++ b/drivers/serial/serial_s5p.c > @@ -207,7 +207,7 @@ U_BOOT_DRIVER(serial_s5p) = { > > #include <debug_uart.h> > > -void debug_uart_init(void) > +static inline void _debug_uart_init(void) > { > struct s5p_uart *uart = (struct s5p_uart *)CONFIG_DEBUG_UART_BASE; > > diff --git a/include/debug_uart.h b/include/debug_uart.h > index a75e377..257ba00 100644 > --- a/include/debug_uart.h > +++ b/include/debug_uart.h > @@ -38,7 +38,7 @@ > * To enable the debug UART in your serial driver: > * > * - #include <debug_uart.h> > - * - Define debug_uart_init(), trying to avoid using the stack > + * - Define _debug_uart_init(), trying to avoid using the stack > * - Define _debug_uart_putc() as static inline (avoiding stack usage) > * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the > * functionality (printch(), etc.) > @@ -132,6 +132,11 @@ void printhex8(uint value); > void printhex8(uint value) \ > { \ > printhex(value, 8); \ > - } > + } \ > +\ > + void debug_uart_init(void) \ > + { \ > + _debug_uart_init(); \ > + } \ I think the ending \ in the last line will cause problems. > > #endif > diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c > index d4d3e49..e138709 100644 > --- a/lib/efi/efi_stub.c > +++ b/lib/efi/efi_stub.c > @@ -59,7 +59,7 @@ struct __packed desctab_info { > * considering if we start needing more U-Boot functionality. Note that we > * could then move get_codeseg32() to arch/x86/cpu/cpu.c. > */ > -void debug_uart_init(void) > +void _debug_uart_init(void) > { > } > > -- Regards, Bin
On 18 October 2015 at 21:17, Bin Meng <bmeng.cn@gmail.com> wrote: > Hi Simon, > > On Mon, Oct 19, 2015 at 9:51 AM, Simon Glass <sjg@chromium.org> wrote: >> We want to be able to add other common code to this function. So change the >> driver's version to have an underscore before it, just like >> _debug_uart_putc(). Define debug_uart_init() to call this version. >> >> Update all drivers to this new method. >> >> Signed-off-by: Simon Glass <sjg@chromium.org> >> --- > > Reviewed-by: Bin Meng <bmeng.cn@gmail.com> > >> >> Changes in v2: >> - Adjust all _debug_uart_init() declarations to be static inline >> >> drivers/serial/ns16550.c | 2 +- >> drivers/serial/serial_efi.c | 2 +- >> drivers/serial/serial_s5p.c | 2 +- >> include/debug_uart.h | 9 +++++++-- >> lib/efi/efi_stub.c | 2 +- >> 5 files changed, 11 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c >> index 6275a11..6433844 100644 >> --- a/drivers/serial/ns16550.c >> +++ b/drivers/serial/ns16550.c >> @@ -257,7 +257,7 @@ int NS16550_tstc(NS16550_t com_port) >> (1 << CONFIG_DEBUG_UART_SHIFT), \ >> CONFIG_DEBUG_UART_SHIFT) >> >> -void debug_uart_init(void) >> +static inline void _debug_uart_init(void) >> { >> struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; >> int baud_divisor; >> diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c >> index cf57d89..ea25c25 100644 >> --- a/drivers/serial/serial_efi.c >> +++ b/drivers/serial/serial_efi.c >> @@ -107,7 +107,7 @@ static int serial_efi_pending(struct udevice *dev, bool input) >> * There is nothing to init here since the EFI console is already running by >> * the time we enter U-Boot. >> */ >> -void debug_uart_init(void) >> +static inline void _debug_uart_init(void) >> { >> } >> >> diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c >> index 3f0b588..feba467 100644 >> --- a/drivers/serial/serial_s5p.c >> +++ b/drivers/serial/serial_s5p.c >> @@ -207,7 +207,7 @@ U_BOOT_DRIVER(serial_s5p) = { >> >> #include <debug_uart.h> >> >> -void debug_uart_init(void) >> +static inline void _debug_uart_init(void) >> { >> struct s5p_uart *uart = (struct s5p_uart *)CONFIG_DEBUG_UART_BASE; >> >> diff --git a/include/debug_uart.h b/include/debug_uart.h >> index a75e377..257ba00 100644 >> --- a/include/debug_uart.h >> +++ b/include/debug_uart.h >> @@ -38,7 +38,7 @@ >> * To enable the debug UART in your serial driver: >> * >> * - #include <debug_uart.h> >> - * - Define debug_uart_init(), trying to avoid using the stack >> + * - Define _debug_uart_init(), trying to avoid using the stack >> * - Define _debug_uart_putc() as static inline (avoiding stack usage) >> * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the >> * functionality (printch(), etc.) >> @@ -132,6 +132,11 @@ void printhex8(uint value); >> void printhex8(uint value) \ >> { \ >> printhex(value, 8); \ >> - } >> + } \ >> +\ >> + void debug_uart_init(void) \ >> + { \ >> + _debug_uart_init(); \ >> + } \ > > I think the ending \ in the last line will cause problems. It should not be there really. I missed it for this cycle but I'll tidy it up at some point. Applied to u-boot-x86.
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 6275a11..6433844 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -257,7 +257,7 @@ int NS16550_tstc(NS16550_t com_port) (1 << CONFIG_DEBUG_UART_SHIFT), \ CONFIG_DEBUG_UART_SHIFT) -void debug_uart_init(void) +static inline void _debug_uart_init(void) { struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; int baud_divisor; diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c index cf57d89..ea25c25 100644 --- a/drivers/serial/serial_efi.c +++ b/drivers/serial/serial_efi.c @@ -107,7 +107,7 @@ static int serial_efi_pending(struct udevice *dev, bool input) * There is nothing to init here since the EFI console is already running by * the time we enter U-Boot. */ -void debug_uart_init(void) +static inline void _debug_uart_init(void) { } diff --git a/drivers/serial/serial_s5p.c b/drivers/serial/serial_s5p.c index 3f0b588..feba467 100644 --- a/drivers/serial/serial_s5p.c +++ b/drivers/serial/serial_s5p.c @@ -207,7 +207,7 @@ U_BOOT_DRIVER(serial_s5p) = { #include <debug_uart.h> -void debug_uart_init(void) +static inline void _debug_uart_init(void) { struct s5p_uart *uart = (struct s5p_uart *)CONFIG_DEBUG_UART_BASE; diff --git a/include/debug_uart.h b/include/debug_uart.h index a75e377..257ba00 100644 --- a/include/debug_uart.h +++ b/include/debug_uart.h @@ -38,7 +38,7 @@ * To enable the debug UART in your serial driver: * * - #include <debug_uart.h> - * - Define debug_uart_init(), trying to avoid using the stack + * - Define _debug_uart_init(), trying to avoid using the stack * - Define _debug_uart_putc() as static inline (avoiding stack usage) * - Immediately afterwards, add DEBUG_UART_FUNCS to define the rest of the * functionality (printch(), etc.) @@ -132,6 +132,11 @@ void printhex8(uint value); void printhex8(uint value) \ { \ printhex(value, 8); \ - } + } \ +\ + void debug_uart_init(void) \ + { \ + _debug_uart_init(); \ + } \ #endif diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index d4d3e49..e138709 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -59,7 +59,7 @@ struct __packed desctab_info { * considering if we start needing more U-Boot functionality. Note that we * could then move get_codeseg32() to arch/x86/cpu/cpu.c. */ -void debug_uart_init(void) +void _debug_uart_init(void) { }
We want to be able to add other common code to this function. So change the driver's version to have an underscore before it, just like _debug_uart_putc(). Define debug_uart_init() to call this version. Update all drivers to this new method. Signed-off-by: Simon Glass <sjg@chromium.org> --- Changes in v2: - Adjust all _debug_uart_init() declarations to be static inline drivers/serial/ns16550.c | 2 +- drivers/serial/serial_efi.c | 2 +- drivers/serial/serial_s5p.c | 2 +- include/debug_uart.h | 9 +++++++-- lib/efi/efi_stub.c | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-)