Serial API cleanup
Subsystems (5)
Hi,
currenlty we have 3 api for stdio device : stdio_dev, serial_device (multi-serial) and the serial_getc/putc...
this cleanup will join them in one api the stdio_dev which will support the multi-serial for before and after relocation
this will also pass the current device to the driver to allow it to have base address and other information to simplify the implementation and avoid workarround as done for ns16550 on the omap3 zoom or ppc4xx as example
Best Regards,
J.
RFC PATCH 1/3 serial: join stdio_dev and serial_device
we use for the serail multi api the struct stdio_dev also which will reduce and simplify the code and prepare the join of all serial APIs.
--- board/esd/pmc440/pmc440.c | 2 +- board/lwmon/lwmon.c | 2 +- board/omap3/zoom2/zoom2_serial.h | 18 +++--- board/trizepsiv/conxs.c | 8 ++-- common/serial.c | 89 +++++++++++++++---------------- common/stdio.c | 3 - cpu/mpc5xxx/serial.c | 36 ++++++------ cpu/mpc8xx/serial.c | 36 ++++++------ cpu/ppc4xx/4xx_uart.c | 38 +++++++------- drivers/serial/serial.c | 24 ++++---- drivers/serial/serial_pxa.c | 54 +++++++++--------- drivers/serial/serial_s3c24x0.c | 22 ++++---- include/serial.h | 109 ++++++++++++++++--------------------- include/stdio_dev.h | 9 +++- 14 files changed, 218 insertions(+), 232 deletions(-)
rewrite include/serial.h (65%)
board/esd/pmc440/pmc440.c +1 -1
@@ -53,7 +53,7 @@ int is_monarch(void);int bootstrap_eeprom_read (unsigned dev_addr,unsigned offset,uchar *buffer,unsigned cnt); -struct serial_device *default_serial_console (void ) +struct stdio_dev *default_serial_console (void ) {uchar buf[4 ];ulong delay;
board/lwmon/lwmon.c +1 -1
@@ -469,7 +469,7 @@ int board_postclk_init (void)return (0 ); } -struct serial_device *default_serial_console (void ) +struct stdio_dev *default_serial_console (void ) {return gd->do_mdm_init ? &serial_scc_device : &serial_smc_device; }
board/omap3/zoom2/zoom2_serial.h +9 -9
@@ -60,16 +60,16 @@ int quad_tstc_##n(void) \ { \ return quad_tstc_dev(QUAD_BASE_##n); \ } \ -struct serial_device zoom2_serial_device##n = \ +struct stdio_dev zoom2_serial_device##n = \ { \ - N(n), \ - U(n), \ - quad_init_##n, \ - quad_setbrg_##n, \ - quad_getc_##n, \ - quad_tstc_##n, \ - quad_putc_##n, \ - quad_puts_##n, \ + .name = N(n), \ + .ctlr = U(n), \ + .start = quad_init_##n, \ + .setbrg = quad_setbrg_##n, \ + .getc = quad_getc_##n, \ + .tstc = quad_tstc_##n, \ + .putc = quad_putc_##n, \ + .puts = quad_puts_##n, \ }; #endif /* ZOOM2_SERIAL_H */
board/trizepsiv/conxs.c +4 -4
@@ -40,9 +40,9 @@ DECLARE_GLOBAL_DATA_PTR;#define RH_A_PSM (1 << 8)/* power switching mode */ #define RH_A_NPS (1 << 9)/* no power switching */ -extern struct serial_device serial_ffuart_device; -extern struct serial_device serial_btuart_device; -extern struct serial_device serial_stuart_device; +extern struct stdio_dev serial_ffuart_device; +extern struct stdio_dev serial_btuart_device; +extern struct stdio_dev serial_stuart_device;#if CONFIG_POLARIS #define BOOT_CONSOLE "serial_stuart"
@@ -130,7 +130,7 @@ int board_late_init(void)return 0 ; } -struct serial_device *default_serial_console (void ) +struct stdio_dev *default_serial_console (void ) {return &serial_ffuart_device; }
common/serial.c +43 -46
169 lines not on this page · raw message
common/stdio.c +0 -3
@@ -234,9 +234,6 @@ int stdio_init (void)drv_logbuff_init ();#endif drv_system_init (); -#ifdef CONFIG_SERIAL_MULTI -serial_stdio_init (); -#endif #ifdef CONFIG_USB_TTY drv_usbtty_init ();#endif
cpu/mpc5xxx/serial.c +18 -18
@@ -352,28 +352,28 @@ int serial1_tstc(void) return (serial_tstc_dev(PSC_BASE2)); } -struct serial_device serial0_device = +struct stdio_dev serial0_device = { -"serial0" , -"UART0" , - serial0_init, - serial0_setbrg, - serial0_getc, - serial0_tstc, - serial0_putc, - serial0_puts, + .name ="serial0" , + .ctlr ="UART0" , + .start = serial0_init, + .setbrg = serial0_setbrg, + .getc = serial0_getc, + .tstc = serial0_tstc, + .putc = serial0_putc, + .puts = serial0_puts, }; -struct serial_device serial1_device = +struct stdio_dev serial1_device = { -"serial1" , -"UART1" , - serial1_init, - serial1_setbrg, - serial1_getc, - serial1_tstc, - serial1_putc, - serial1_puts, + .name ="serial1" , + .ctlr ="UART1" , + .start = serial1_init, + .setbrg = serial1_setbrg, + .getc = serial1_getc, + .tstc = serial1_tstc, + .putc = serial1_putc, + .puts = serial1_puts, };#endif /* CONFIG_SERIAL_MULTI */
cpu/mpc8xx/serial.c +18 -18
@@ -387,16 +387,16 @@ smc_tstc(void) return !(rtx->rxbd.cbd_sc & BD_SC_EMPTY); } -struct serial_device serial_smc_device = +struct stdio_dev serial_smc_device = { -"serial_smc" , -"SMC" , - smc_init, - smc_setbrg, - smc_getc, - smc_tstc, - smc_putc, - smc_puts, + .name ="serial_smc" , + .ctlr ="SMC" , + .start = smc_init, + .setbrg = smc_setbrg, + .getc = smc_getc, + .tstc = smc_tstc, + .putc = smc_putc, + .puts = smc_puts, };#endif /* CONFIG_8xx_CONS_SMC1 || CONFIG_8xx_CONS_SMC2 */
@@ -657,16 +657,16 @@ scc_tstc(void) return(!(rbdf->cbd_sc & BD_SC_EMPTY)); } -struct serial_device serial_scc_device = +struct stdio_dev serial_scc_device = { -"serial_scc" , -"SCC" , - scc_init, - scc_setbrg, - scc_getc, - scc_tstc, - scc_putc, - scc_puts, + .name ="serial_scc" , + .ctlr ="SCC" , + .start = scc_init, + .setbrg = scc_setbrg, + .getc = scc_getc, + .tstc = scc_tstc, + .putc = scc_putc, + .puts = scc_puts, };#endif /* CONFIG_8xx_CONS_SCCx */
cpu/ppc4xx/4xx_uart.c +19 -19
@@ -817,28 +817,28 @@ int serial1_tstc(void) return (serial_tstc_dev(UART1_BASE)); } -struct serial_device serial0_device = -{ -"serial0" , -"UART0" , - serial0_init, - serial0_setbrg, - serial0_getc, - serial0_tstc, - serial0_putc, - serial0_puts, +struct stdio_dev serial0_device = +{ + .name ="serial0" , + .ctlr ="UART0" , + .start = serial0_init, + .setbrg = serial0_setbrg, + .getc = serial0_getc, + .tstc = serial0_tstc, + .putc = serial0_putc, + .puts = serial0_puts, }; -struct serial_device serial1_device = +struct stdio_dev serial1_device = { -"serial1" , -"UART1" , - serial1_init, - serial1_setbrg, - serial1_getc, - serial1_tstc, - serial1_putc, - serial1_puts, + .name ="serial1" , + .ctlr ="UART1" , + .start = serial1_init, + .setbrg = serial1_setbrg, + .getc = serial1_getc, + .tstc = serial1_tstc, + .putc = serial1_putc, + .puts = serial1_puts, };#else /*
drivers/serial/serial.c +12 -12
@@ -112,14 +112,14 @@ static NS16550_t serial_ports[4] = {/* Serial device descriptor */ #define INIT_ESERIAL_STRUCTURE (port,name,bus) {\ - name,\ - bus,\ - eserial##port##_init,\ - eserial##port##_setbrg,\ - eserial##port##_getc,\ - eserial##port##_tstc,\ - eserial##port##_putc,\ - eserial##port##_puts, } + .name = name,\ + .ctlr = bus,\ + .start = eserial##port##_init,\ + .setbrg = eserial##port##_setbrg,\ + .getc = eserial##port##_getc,\ + .tstc = eserial##port##_tstc,\ + .putc = eserial##port##_putc,\ + .puts = eserial##port##_puts, }#endif /* CONFIG_SERIAL_MULTI */
@@ -317,15 +317,15 @@ serial_setbrg(void)#if defined(CONFIG_SERIAL_MULTI )DECLARE_ESERIAL_FUNCTIONS (1 ); -struct serial_device eserial1_device = +struct stdio_dev eserial1_device =INIT_ESERIAL_STRUCTURE (1 ,"eserial0" ,"EUART1" );DECLARE_ESERIAL_FUNCTIONS (2 ); -struct serial_device eserial2_device = +struct stdio_dev eserial2_device =INIT_ESERIAL_STRUCTURE (2 ,"eserial1" ,"EUART2" );DECLARE_ESERIAL_FUNCTIONS (3 ); -struct serial_device eserial3_device = +struct stdio_dev eserial3_device =INIT_ESERIAL_STRUCTURE (3 ,"eserial2" ,"EUART3" );DECLARE_ESERIAL_FUNCTIONS (4 ); -struct serial_device eserial4_device = +struct stdio_dev eserial4_device =INIT_ESERIAL_STRUCTURE (4 ,"eserial3" ,"EUART4" );#endif /* CONFIG_SERIAL_MULTI */
drivers/serial/serial_pxa.c +27 -27
75 lines not on this page · raw message
drivers/serial/serial_s3c24x0.c +11 -11
@@ -65,14 +65,14 @@ DECLARE_GLOBAL_DATA_PTR; serial_puts_dev(port, s);}#define INIT_S3C_SERIAL_STRUCTURE (port,name,bus) {\ - name,\ - bus,\ - s3serial##port##_init,\ - s3serial##port##_setbrg,\ - s3serial##port##_getc,\ - s3serial##port##_tstc,\ - s3serial##port##_putc,\ - s3serial##port##_puts, } + .name = name,\ + .ctlr = bus,\ + .start = s3serial##port##_init,\ + .setbrg = s3serial##port##_setbrg,\ + .getc = s3serial##port##_getc,\ + .tstc = s3serial##port##_tstc,\ + .putc = s3serial##port##_putc,\ + .puts = s3serial##port##_puts, }#endif /* CONFIG_SERIAL_MULTI */
@@ -288,13 +288,13 @@ serial_puts (const char *s)#if defined(CONFIG_SERIAL_MULTI )DECLARE_S3C_SERIAL_FUNCTIONS (0 ); -struct serial_device s3c24xx_serial0_device = +struct stdio_dev s3c24xx_serial0_device =INIT_S3C_SERIAL_STRUCTURE (0 ,"s3ser0" ,"S3UART1" );DECLARE_S3C_SERIAL_FUNCTIONS (1 ); -struct serial_device s3c24xx_serial1_device = +struct stdio_dev s3c24xx_serial1_device =INIT_S3C_SERIAL_STRUCTURE (1 ,"s3ser1" ,"S3UART2" );DECLARE_S3C_SERIAL_FUNCTIONS (2 ); -struct serial_device s3c24xx_serial2_device = +struct stdio_dev s3c24xx_serial2_device =INIT_S3C_SERIAL_STRUCTURE (2 ,"s3ser2" ,"S3UART3" );#endif /* CONFIG_SERIAL_MULTI */
include/serial.h +47 -62
109 lines not on this page · raw message
include/stdio_dev.h +8 -1
@@ -32,14 +32,19 @@#define DEV_FLAGS_INPUT 0x00000001/* Device can be used as input console */ #define DEV_FLAGS_OUTPUT 0x00000002/* Device can be used as output console */ +#define DEV_FLAGS_SERIAL 0x00000003/* Device is a serial device */ #define DEV_FLAGS_SYSTEM 0x80000000/* Device is a system device */ #define DEV_EXT_VIDEO 0x00000001/* Video extensions supported */ +#define NAMESIZE 16 +#define CTLRSIZE 8 +/* Device information */ struct stdio_dev {int flags;/* Device flags: input/output/system */ int ext;/* Supported extensions */ -char name[16 ];/* Device name */ +char name[NAMESIZE ];/* Device name */ +char ctlr[CTLRSIZE ];/* GENERAL functions */
@@ -57,6 +62,7 @@ struct stdio_dev {int (*getc) (void );/* To get that char */ /* Other functions */ +void (*setbrg) (void );/* Set baudrate */ void *priv;/* Private extensions */ struct list_head list;
@@ -96,6 +102,7 @@ void stdio_print_current_devices(void);int stdio_deregister (char *devname);#endif struct list_head *stdio_get_list (void ); +struct stdio_dev *stdio_get_devs (void );struct stdio_dev *stdio_get_by_name (char * name);struct stdio_dev *stdio_clone (struct stdio_dev *dev);
Signature · 1 line
1.6.3.1
RFC PATCH 2/3 stdio: pass the current device to the driver
to allow it to have base address and other information to simplify the implementation and avoid workarround as done for ns16550 on the omap3 zoom or ppc4xx as example
--- board/MAI/AmigaOneG3SE/video.c | 10 +++--- board/bf527-ezkit/video.c | 4 +- board/bf548-ezkit/video.c | 4 +- board/cm-bf548/video.c | 4 +- board/omap3/zoom2/zoom2_serial.h | 70 +++++++++++++++++++------------------- board/rbc823/kbd.c | 4 +- common/cmd_log.c | 16 ++++++--- common/console.c | 18 +++++----- common/lcd.c | 21 +++++++++-- common/serial.c | 28 +++++++------- common/stdio.c | 58 ++++++++++++++++++++++++------- common/usb_kbd.c | 4 +- cpu/blackfin/jtag-console.c | 8 ++-- cpu/mpc5xxx/serial.c | 24 ++++++------ cpu/mpc8xx/serial.c | 32 +++++++++--------- cpu/mpc8xx/video.c | 6 ++-- cpu/ppc4xx/4xx_uart.c | 24 ++++++------ drivers/input/i8042.c | 4 +- drivers/net/netconsole.c | 10 +++--- drivers/serial/arm_dcc.c | 39 ++++++++++++++------- drivers/serial/serial.c | 12 +++--- drivers/serial/serial_pxa.c | 36 ++++++++++---------- drivers/serial/serial_s3c24x0.c | 12 +++--- drivers/serial/usbtty.c | 8 ++-- drivers/video/cfb_console.c | 6 ++-- include/i8042.h | 4 +- include/stdio_dev.h | 14 ++++---- lib_i386/video.c | 4 +- 28 files changed, 273 insertions(+), 211 deletions(-)
board/MAI/AmigaOneG3SE/video.c +5 -5
@@ -46,8 +46,8 @@ unsigned int video_scrolls = 0;#define VIDEO_NAME "vga"void video_test (void ); -void video_putc (char ch); -void video_puts (char *string); +void video_putc (struct stdio_dev *dev,char ch); +void video_puts (struct stdio_dev *dev,char *string);void video_scroll (int rows);void video_banner (void );int video_init (void );
@@ -163,7 +163,7 @@ void video_test(void) } -void video_putc (char ch) +void video_putc (struct stdio_dev *dev,char ch) {switch (ch) {
@@ -224,11 +224,11 @@ void video_scroll(int rows) cursor_col=0 ; } -void video_puts (char *string) +void video_puts (struct stdio_dev *dev,char *string) {while (*string) { -video_putc (*string); +video_putc (dev, *string); string++; } }
board/bf527-ezkit/video.c +2 -2
@@ -261,11 +261,11 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y) } -void video_putc (const char c) +void video_putc (struct stdio_dev *dev,const char c) { } -void video_puts (const char *s) +void video_puts (struct stdio_dev *dev,const char *s) { }
board/bf548-ezkit/video.c +2 -2
@@ -271,11 +271,11 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y) } -void video_putc (const char c) +void video_putc (struct stdio_dev *dev,const char c) { } -void video_puts (const char *s) +void video_puts (struct stdio_dev *dev,const char *s) { }
board/cm-bf548/video.c +2 -2
@@ -280,11 +280,11 @@ static void dma_bitblit(void *dst, fastimage_t *logo, int x, int y) } -void video_putc (const char c) +void video_putc (struct stdio_dev *dev,const char c) { } -void video_puts (const char *s) +void video_puts (struct stdio_dev *dev,const char *s) { }
board/omap3/zoom2/zoom2_serial.h +35 -35
76 lines not on this page · raw message
board/rbc823/kbd.c +2 -2
@@ -205,7 +205,7 @@ void smc1_putc(const char c) } } -int smc1_getc (void ) +int smc1_getc (struct stdio_dev *dev) {volatile cbd_t *rbdf;volatile unsigned char *buf;
@@ -231,7 +231,7 @@ int smc1_getc(void)return (c); } -int smc1_tstc (void ) +int smc1_tstc (struct stdio_dev *dev) {volatile cbd_t *rbdf;volatile smc_uart_t *up;
common/cmd_log.c +11 -5
@@ -49,8 +49,9 @@DECLARE_GLOBAL_DATA_PTR ;/* Local prototypes */ -static void logbuff_putc (const char c); -static void logbuff_puts (const char *s); +static void stdio_logbuff_putc (struct stdio_dev *dev,const char c); +static void stdio_logbuff_puts (struct stdio_dev *dev,const char *s); +static void logbuff_putc (const char c) static int logbuff_printk(const char *line);static char buf[1024 ];
@@ -151,14 +152,19 @@ int drv_logbuff_init (void)strcpy (logdev.name,"logbuff" ); logdev.ext =0 ;/* No extensions */ logdev.flags =DEV_FLAGS_OUTPUT ;/* Output only */ - logdev.putc = logbuff_putc;/* 'putc' function */ - logdev.puts = logbuff_puts;/* 'puts' function */ + logdev.putc = stdio_logbuff_putc;/* 'putc' function */ + logdev.puts = stdio_logbuff_puts;/* 'puts' function */ rc =stdio_register (&logdev);return (rc ==0 ) ?1 : rc; } +static void stdio_logbuff_putc (struct stdio_dev *dev,const char c) +{ +logbuff_putc (c); +} +static void logbuff_putc (const char c) {char buf[2 ];
@@ -167,7 +173,7 @@ static void logbuff_putc (const char c)logbuff_printk (buf); } -static void logbuff_puts (const char *s) +static void stdio_logbuff_puts (struct stdio_dev *dev,const char *s) {logbuff_printk (s); }
common/console.c +9 -9
@@ -61,7 +61,7 @@ static int console_setfile(int file, struct stdio_dev * dev)case stderr:/* Start new device */ if (dev->start) { - error = dev->start (); + error = dev->start (dev);/* If it's not started dont use it */ if (error <0 )break ;
@@ -111,7 +111,7 @@ static int console_getc(int file)unsigned char ret;/* This is never called with testcdev == NULL */ - ret = tstcdev->getc (); + ret = tstcdev->getc (tstcdev); tstcdev =NULL ;return ret; }
@@ -125,7 +125,7 @@ static int console_tstc(int file)for (i =0 ; i < cd_count[file]; i++) { dev = console_devices[file][i];if (dev->tstc !=NULL ) { - ret = dev->tstc (); + ret = dev->tstc (dev);if (ret >0 ) { tstcdev = dev;disable_ctrlc (0 );
@@ -146,7 +146,7 @@ static void console_putc(int file, const char c)for (i =0 ; i < cd_count[file]; i++) { dev = console_devices[file][i];if (dev->putc !=NULL ) - dev->putc (c); + dev->putc (dev, c); } }
@@ -158,7 +158,7 @@ static void console_puts(int file, const char *s)for (i =0 ; i < cd_count[file]; i++) { dev = console_devices[file][i];if (dev->puts !=NULL ) - dev->puts (s); + dev->puts (dev, s); } }
@@ -174,22 +174,22 @@ static inline void console_doenv(int file, struct stdio_dev *dev)#else static inline int console_getc (int file) { -return stdio_devices[file]->getc (); +return stdio_devices[file]->getc (stdio_devices[file]); }static inline int console_tstc (int file) { -return stdio_devices[file]->tstc (); +return stdio_devices[file]->tstc (stdio_devices[file]); }static inline void console_putc (int file,const char c) { - stdio_devices[file]->putc (c); + stdio_devices[file]->putc (stdio_devices[file], c); }static inline void console_puts (int file,const char *s) { - stdio_devices[file]->puts (s); + stdio_devices[file]->puts (stdio_devices[file], s); }static inline void console_printdevs (int file)
common/lcd.c +17 -4
@@ -69,6 +69,7 @@#endif DECLARE_GLOBAL_DATA_PTR ; +struct stdio_dev lcddev;ulong lcd_setmem (ulong addr);
@@ -76,6 +77,9 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count);static inline void lcd_puts_xy (ushort x,ushort y,uchar *s);static inline void lcd_putc_xy (ushort x,ushort y,uchar c); +static void dev_lcd_putc (struct stdio_dev *dev,const char c); +static void dev_lcd_puts (struct stdio_dev *dev,const char *s); +static int lcd_init (void *lcdbase);static int lcd_clear (cmd_tbl_t * cmdtp,int flag,int argc,char *argv[]);
@@ -162,6 +166,11 @@ static inline void console_newline (void)void lcd_putc (const char c) { +dev_lcd_putc (&lcddev, c); +} + +static void dev_lcd_putc (struct stdio_dev *dev,const char c) +{if (!lcd_is_enabled) {serial_putc (c);return ;
@@ -201,13 +210,18 @@ void lcd_putc (const char c)void lcd_puts (const char *s) { +dev_lcd_puts (&lcddev, s); +} + +static void dev_lcd_puts (struct stdio_dev *dev,const char *s) +{if (!lcd_is_enabled) {serial_puts (s);return ; }while (*s) { -lcd_putc (*s++); +dev_lcd_putc (dev, *s++); } }
@@ -343,7 +357,6 @@ static void test_pattern (void)int drv_lcd_init (void ) { -struct stdio_dev lcddev;int rc; lcd_base = (void *)(gd->fb_base);
@@ -358,8 +371,8 @@ int drv_lcd_init (void)strcpy (lcddev.name,"lcd" ); lcddev.ext =0 ;/* No extensions */ lcddev.flags =DEV_FLAGS_OUTPUT ;/* Output only */ - lcddev.putc = lcd_putc;/* 'putc' function */ - lcddev.puts = lcd_puts;/* 'puts' function */ + lcddev.putc = dev_lcd_putc;/* 'putc' function */ + lcddev.puts = dev_lcd_puts;/* 'puts' function */ rc =stdio_register (&lcddev);
common/serial.c +14 -14
@@ -173,9 +173,9 @@ void serial_reinit_all (void)if ((dev->flags &DEV_FLAGS_SERIAL ) !=DEV_FLAGS_SERIAL )continue ;if (dev->stop) - dev->stop (); + dev->stop (dev);if (dev->start) - dev->start (); + dev->start (dev); } }
@@ -185,13 +185,13 @@ int serial_init (void)struct stdio_dev *dev =default_serial_console ();if (dev->start) -return dev->start (); +return dev->start (dev);return 0 ; }if (serial_current->start) -return serial_current->start (); +return serial_current->start (serial_current);return 0 ; }
@@ -201,11 +201,11 @@ void serial_setbrg (void)if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) {struct stdio_dev *dev =default_serial_console (); - dev->setbrg (); + dev->setbrg (dev);return ; } - serial_current->setbrg (); + serial_current->setbrg (serial_current); }int serial_getc (void )
@@ -213,10 +213,10 @@ int serial_getc (void)if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) {struct stdio_dev *dev =default_serial_console (); -return dev->getc (); +return dev->getc (dev); } -return serial_current->getc (); +return serial_current->getc (serial_current); }int serial_tstc (void )
@@ -224,10 +224,10 @@ int serial_tstc (void)if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) {struct stdio_dev *dev =default_serial_console (); -return dev->tstc (); +return dev->tstc (dev); } -return serial_current->tstc (); +return serial_current->tstc (serial_current); }void serial_putc (const char c)
@@ -235,11 +235,11 @@ void serial_putc (const char c)if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) {struct stdio_dev *dev =default_serial_console (); - dev->putc (c); + dev->putc (dev, c);return ; } - serial_current->putc (c); + serial_current->putc (serial_current, c); }void serial_puts (const char *s)
@@ -247,9 +247,9 @@ void serial_puts (const char *s)if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) {struct stdio_dev *dev =default_serial_console (); - dev->puts (s); + dev->puts (dev, s);return ; } - serial_current->puts (s); + serial_current->puts (serial_current, s); }
common/stdio.c +44 -14
84 lines not on this page · raw message
common/usb_kbd.c +2 -2
@@ -118,7 +118,7 @@ static void usb_kbd_put_queue(char data) }/* test if a character is in the queue */ -static int usb_kbd_testc (void ) +static int usb_kbd_testc (struct stdio_dev *dev) {#ifdef CONFIG_SYS_USB_EVENT_POLL usb_event_poll ();
@@ -129,7 +129,7 @@ static int usb_kbd_testc(void)return (1 ); }/* gets the character from the queue */ -static int usb_kbd_getc (void ) +static int usb_kbd_getc (struct stdio_dev *dev) {char c;while (usb_in_pointer==usb_out_pointer) {
cpu/blackfin/jtag-console.c +4 -4
@@ -45,11 +45,11 @@ static void jtag_send(const char *c, uint32_t len)for (i =0 ; i < len; i +=4 )jtag_write_emudat ((c[i] <<0 ) | (c[i+1 ] <<8 ) | (c[i+2 ] <<16 ) | (c[i+3 ] <<24 )); } -static void jtag_putc (const char c) +static void jtag_putc (struct stdio_dev *dev,const char c) {jtag_send (&c,1 ); } -static void jtag_puts (const char *s) +static void jtag_puts (struct stdio_dev *dev,const char *s) {jtag_send (s,strlen (s)); }
@@ -63,7 +63,7 @@ static int jtag_tstc_dbg(void) }/* Higher layers want to know when any data is available */ -static int jtag_tstc (void ) +static int jtag_tstc (struct stdio_dev *dev) {return jtag_tstc_dbg () || leftovers_len; }
@@ -72,7 +72,7 @@ static int jtag_tstc(void)* [32bit length][actual data] */ static uint32_t leftovers; -static int jtag_getc (void ) +static int jtag_getc (struct stdio_dev *dev) {int ret;uint32_t emudat;
cpu/mpc5xxx/serial.c +12 -12
@@ -296,58 +296,58 @@ int serial_getcts(void) }#if defined(CONFIG_SERIAL_MULTI ) -int serial0_init (void ) +int serial0_init (struct stdio_dev *dev) {return (serial_init_dev (PSC_BASE )); } -int serial1_init (void ) +int serial1_init (struct stdio_dev *dev) {return (serial_init_dev (PSC_BASE2 )); } -void serial0_setbrg (void ) +void serial0_setbrg (struct stdio_dev *dev) {serial_setbrg_dev (PSC_BASE ); } -void serial1_setbrg (void ) +void serial1_setbrg (struct stdio_dev *dev) {serial_setbrg_dev (PSC_BASE2 ); } -void serial0_putc (const char c) +void serial0_putc (struct stdio_dev *dev,const char c) {serial_putc_dev (PSC_BASE ,c); } -void serial1_putc (const char c) +void serial1_putc (struct stdio_dev *dev,const char c) {serial_putc_dev (PSC_BASE2 , c); } -void serial0_puts (const char *s) +void serial0_puts (struct stdio_dev *dev,const char *s) {serial_puts_dev (PSC_BASE , s); } -void serial1_puts (const char *s) +void serial1_puts (struct stdio_dev *dev,const char *s) {serial_puts_dev (PSC_BASE2 , s); } -int serial0_getc (void ) +int serial0_getc (struct stdio_dev *dev) {return (serial_getc_dev (PSC_BASE )); } -int serial1_getc (void ) +int serial1_getc (struct stdio_dev *dev) {return (serial_getc_dev (PSC_BASE2 )); } -int serial0_tstc (void ) +int serial0_tstc (struct stdio_dev *dev) {return (serial_tstc_dev (PSC_BASE )); } -int serial1_tstc (void ) +int serial1_tstc (struct stdio_dev *dev) {return (serial_tstc_dev (PSC_BASE2 )); }
cpu/mpc8xx/serial.c +16 -16
@@ -109,7 +109,7 @@ static void serial_setdivisor(volatile cpm8xx_t *cp)* as serial console interface. */ -static void smc_setbrg (void ) +static void smc_setbrg (struct stdio_dev *dev) {volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR ;volatile cpm8xx_t *cp = &(im->im_cpm);
@@ -125,7 +125,7 @@ static void smc_setbrg (void)serial_setdivisor (cp); } -static int smc_init (void ) +static int smc_init (struct stdio_dev *dev) {volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR ;volatile smc_t *sp;
@@ -266,7 +266,7 @@ static int smc_init (void) cp->cp_simode = ((cp->cp_simode & ~0xf000 ) |0x7000 );#else /* Set up the baud rate generator */ -smc_setbrg (); +smc_setbrg (dev);#endif /* Make the first buffer the only buffer. */
@@ -294,7 +294,7 @@ static int smc_init (void) }static void -smc_putc (const char c) +smc_putc (struct stdio_dev *dev,const char c) {volatile smc_uart_t *up;volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR ;
@@ -307,7 +307,7 @@ smc_putc(const char c)#endif if (c =='\n' ) -smc_putc ('\r' ); +smc_putc (dev,'\r' ); up = (smc_uart_t *)&cpmp->cp_dparam[PROFF_SMC ];#ifdef CONFIG_SYS_SMC_UCODE_PATCH
@@ -329,15 +329,15 @@ smc_putc(const char c) }static void -smc_puts (const char *s) +smc_puts (struct stdio_dev *dev,const char *s) {while (*s) { -smc_putc (*s++); +smc_putc (dev, *s++); } }static int -smc_getc (void ) +smc_getc (struct stdio_dev *dev) {volatile smc_uart_t *up;volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR ;
@@ -370,7 +370,7 @@ smc_getc(void) }static int -smc_tstc (void ) +smc_tstc (struct stdio_dev *dev) {volatile smc_uart_t *up;volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR ;
@@ -405,7 +405,7 @@ struct stdio_dev serial_smc_device = defined(CONFIG_8xx_CONS_SCC3) || defined(CONFIG_8xx_CONS_SCC4)static void -scc_setbrg (void ) +scc_setbrg (struct stdio_dev *dev) {volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR ;volatile cpm8xx_t *cp = &(im->im_cpm);
@@ -421,7 +421,7 @@ scc_setbrg (void)serial_setdivisor (cp); } -static int scc_init (void ) +static int scc_init (struct stdio_dev *dev) {volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR ;volatile scc_t *sp;
@@ -502,7 +502,7 @@ static int scc_init (void) tbdf->cbd_sc =0 ;/* Set up the baud rate generator. */ -scc_setbrg (); +scc_setbrg (dev);/* Set up the uart parameters in the parameter ram. */ up->scc_genscc.scc_rbase = dpaddr;
@@ -573,7 +573,7 @@ static int scc_init (void) }static void -scc_putc (const char c) +scc_putc (struct stdio_dev *dev,const char c) {volatile cbd_t *tbdf;volatile char *buf;
@@ -609,7 +609,7 @@ scc_putc(const char c) }static void -scc_puts (const char *s) +scc_puts (struct stdio_dev *dev,const char *s) {while (*s) {scc_putc (*s++);
@@ -617,7 +617,7 @@ scc_puts (const char *s) }static int -scc_getc (void ) +scc_getc (struct stdio_dev *dev) {volatile cbd_t *rbdf;volatile unsigned char *buf;
@@ -643,7 +643,7 @@ scc_getc(void) }static int -scc_tstc (void ) +scc_tstc (struct stdio_dev *dev) {volatile cbd_t *rbdf;volatile scc_uart_t *up;
cpu/mpc8xx/video.c +3 -3
@@ -996,7 +996,7 @@ static inline void console_newline (void) } } -void video_putc (const char c) +void video_putc (struct stdio_dev *dev,const char c) {if (!video_enable) {serial_putc (c);
@@ -1033,7 +1033,7 @@ void video_putc (const char c) } } -void video_puts (const char *s) +void video_puts (struct stdio_dev *dev,const char *s) {int count =strlen (s);
@@ -1042,7 +1042,7 @@ void video_puts (const char *s)serial_putc (*s++); else while (count--) - video_putc (*s++); + video_putc (dev, *s++); }/************************************************************************/
cpu/ppc4xx/4xx_uart.c +12 -12
@@ -757,62 +757,62 @@ void kgdb_interruptible (int yes)#if defined(CONFIG_SERIAL_MULTI ) -int serial0_init (void ) +int serial0_init (struct stdio_dev *dev) {return (serial_init_dev (UART0_BASE )); } -int serial1_init (void ) +int serial1_init (struct stdio_dev *dev) {return (serial_init_dev (UART1_BASE )); } -void serial0_setbrg (void ) +void serial0_setbrg (struct stdio_dev *dev) {serial_setbrg_dev (UART0_BASE ); } -void serial1_setbrg (void ) +void serial1_setbrg (struct stdio_dev *dev) {serial_setbrg_dev (UART1_BASE ); } -void serial0_putc (const char c) +void serial0_putc (struct stdio_dev *dev,const char c) {serial_putc_dev (UART0_BASE ,c); } -void serial1_putc (const char c) +void serial1_putc (struct stdio_dev *dev,const char c) {serial_putc_dev (UART1_BASE , c); } -void serial0_puts (const char *s) +void serial0_puts (struct stdio_dev *dev,const char *s) {serial_puts_dev (UART0_BASE , s); } -void serial1_puts (const char *s) +void serial1_puts (struct stdio_dev *dev,const char *s) {serial_puts_dev (UART1_BASE , s); } -int serial0_getc (void ) +int serial0_getc (struct stdio_dev *dev) {return (serial_getc_dev (UART0_BASE )); } -int serial1_getc (void ) +int serial1_getc (struct stdio_dev *dev) {return (serial_getc_dev (UART1_BASE )); } -int serial0_tstc (void ) +int serial0_tstc (struct stdio_dev *dev) {return (serial_tstc_dev (UART0_BASE )); } -int serial1_tstc (void ) +int serial1_tstc (struct stdio_dev *dev) {return (serial_tstc_dev (UART1_BASE )); }
drivers/input/i8042.c +2 -2
@@ -359,7 +359,7 @@ int i8042_kbd_init (void)* i8042_tstc - test if keyboard input is available * option: cursor blinking if called in a loop */ -int i8042_tstc (void ) +int i8042_tstc (struct stdio_dev *dev) {unsigned char scan_code =0 ;
@@ -395,7 +395,7 @@ int i8042_tstc (void)* i8042_getc - wait till keyboard input is available * option: turn on/off cursor while waiting */ -int i8042_getc (void ) +int i8042_getc (struct stdio_dev *dev) {int ret_chr;unsigned char scan_code;
drivers/net/netconsole.c +5 -5
@@ -139,7 +139,7 @@ static void nc_send_packet (const char *buf, int len)eth_halt (); } -int nc_start (void ) +int nc_start (struct stdio_dev *dev) {int netmask, our_ip;
@@ -169,7 +169,7 @@ int nc_start (void)return 0 ; } -void nc_putc (char c) +void nc_putc (struct stdio_dev *dev,char c) {if (output_recursion)return ;
@@ -180,7 +180,7 @@ void nc_putc (char c) output_recursion =0 ; } -void nc_puts (const char *s) +void nc_puts (struct stdio_dev *dev,const char *s) {int len;
@@ -196,7 +196,7 @@ void nc_puts (const char *s) output_recursion =0 ; } -int nc_getc (void ) +int nc_getc (struct stdio_dev *dev) {uchar c;
@@ -217,7 +217,7 @@ int nc_getc (void)return c; } -int nc_tstc (void ) +int nc_tstc (struct stdio_dev *dev) {struct eth_device *eth;
drivers/serial/arm_dcc.c +26 -13
@@ -90,20 +90,21 @@#define TIMEOUT_COUNT 0x4000000#ifndef CONFIG_ARM_DCC_MULTI -#define arm_dcc_init serial_init -void serial_setbrg (void ) {} -#define arm_dcc_getc serial_getc -#define arm_dcc_putc serial_putc -#define arm_dcc_puts serial_puts -#define arm_dcc_tstc serial_tstc -#endif - -int arm_dcc_init (void ) +int serial_init (void ) {return 0 ; } -int arm_dcc_getc (void ) +void serial_setbrg (void ) +{ +} +#endif + +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_getc(struct stdio_dev *dev) +#else +int serial_getc(void) +#endif {int ch; registerunsigned int reg;
@@ -116,7 +117,11 @@ int arm_dcc_getc(void)return ch; } -void arm_dcc_putc (char ch) +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_putc(struct stdio_dev *dev, char ch) +#else +void serial_putc(char ch) +#endif { registerunsigned int reg;unsigned int timeout_count =TIMEOUT_COUNT ;
@@ -132,13 +137,21 @@ void arm_dcc_putc(char ch)write_dcc (ch); } -void arm_dcc_puts (const char *s) +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_puts(struct stdio_dev *dev, const char *s) +#else +void serial_puts(const char *s) +#endif { while (*s) arm_dcc_putc(*s++); } -int arm_dcc_tstc (void ) +#ifndef CONFIG_ARM_DCC_MULTI +int arm_dcc_tstc(struct stdio_dev *dev) +#else +int serial_tstc(void) +#endif { register unsigned int reg;
drivers/serial/serial.c +6 -6
@@ -94,20 +94,20 @@ static NS16550_t serial_ports[4] = {/* Multi serial device functions */ #define DECLARE_ESERIAL_FUNCTIONS (port) \ - int eserial##port##_init (void) {\ + int eserial##port##_init (struct stdio_dev *dev) {\ int clock_divisor; \ clock_divisor = calc_divisor(serial_ports[port-1]); \ NS16550_init(serial_ports[port-1], clock_divisor); \ return(0);}\ - void eserial##port##_setbrg (void) {\ + void eserial##port##_setbrg (struct stdio_dev *dev) {\ serial_setbrg_dev(port);}\ - int eserial##port##_getc (void) {\ + int eserial##port##_getc (struct stdio_dev *dev) {\ return serial_getc_dev(port);}\ - int eserial##port##_tstc (void) {\ + int eserial##port##_tstc (struct stdio_dev *dev) {\ return serial_tstc_dev(port);}\ - void eserial##port##_putc (const char c) {\ + void eserial##port##_putc (struct stdio_dev *dev, const char c) {\ serial_putc_dev(port, c);}\ - void eserial##port##_puts (const char *s) {\ + void eserial##port##_puts (struct stdio_dev *dev, const char *s) {\ serial_puts_dev(port, s);}/* Serial device descriptor */
drivers/serial/serial_pxa.c +18 -18
@@ -231,32 +231,32 @@ pxa_puts_dev (unsigned int uart_index,const char *s) }#if defined (CONFIG_FFUART ) -static int ffuart_init (void ) +static int ffuart_init (struct stdio_dev *dev) {return pxa_init_dev (FFUART_INDEX ); } -static void ffuart_setbrg (void ) +static void ffuart_setbrg (struct stdio_dev *dev) {return pxa_setbrg_dev (FFUART_INDEX ); } -static void ffuart_putc (const char c) +static void ffuart_putc (struct stdio_dev *dev,const char c) {return pxa_putc_dev (FFUART_INDEX ,c); } -static void ffuart_puts (const char *s) +static void ffuart_puts (struct stdio_dev *dev,const char *s) {return pxa_puts_dev (FFUART_INDEX ,s); } -static int ffuart_getc (void ) +static int ffuart_getc (struct stdio_dev *dev) {return pxa_getc_dev (FFUART_INDEX ); } -static int ffuart_tstc (void ) +static int ffuart_tstc (struct stdio_dev *dev) {return pxa_tstc_dev (FFUART_INDEX ); }
@@ -275,32 +275,32 @@ struct stdio_dev serial_ffuart_device =#endif #if defined (CONFIG_BTUART ) -static int btuart_init (void ) +static int btuart_init (struct stdio_dev *dev) {return pxa_init_dev (BTUART_INDEX ); } -static void btuart_setbrg (void ) +static void btuart_setbrg (struct stdio_dev *dev) {return pxa_setbrg_dev (BTUART_INDEX ); } -static void btuart_putc (const char c) +static void btuart_putc (struct stdio_dev *dev,const char c) {return pxa_putc_dev (BTUART_INDEX ,c); } -static void btuart_puts (const char *s) +static void btuart_puts (struct stdio_dev *dev,const char *s) {return pxa_puts_dev (BTUART_INDEX ,s); } -static int btuart_getc (void ) +static int btuart_getc (struct stdio_dev *dev) {return pxa_getc_dev (BTUART_INDEX ); } -static int btuart_tstc (void ) +static int btuart_tstc (struct stdio_dev *dev) {return pxa_tstc_dev (BTUART_INDEX ); }
@@ -319,32 +319,32 @@ struct stdio_dev serial_btuart_device =#endif #if defined (CONFIG_STUART ) -static int stuart_init (void ) +static int stuart_init (struct stdio_dev *dev) {return pxa_init_dev (STUART_INDEX ); } -static void stuart_setbrg (void ) +static void stuart_setbrg (struct stdio_dev *dev) {return pxa_setbrg_dev (STUART_INDEX ); } -static void stuart_putc (const char c) +static void stuart_putc (struct stdio_dev *dev,const char c) {return pxa_putc_dev (STUART_INDEX ,c); } -static void stuart_puts (const char *s) +static void stuart_puts (struct stdio_dev *dev,const char *s) {return pxa_puts_dev (STUART_INDEX ,s); } -static int stuart_getc (void ) +static int stuart_getc (struct stdio_dev *dev) {return pxa_getc_dev (STUART_INDEX ); } -static int stuart_tstc (void ) +static int stuart_tstc (struct stdio_dev *dev) {return pxa_tstc_dev (STUART_INDEX ); }
drivers/serial/serial_s3c24x0.c +6 -6
@@ -51,17 +51,17 @@ DECLARE_GLOBAL_DATA_PTR;/* Multi serial device functions */ #define DECLARE_S3C_SERIAL_FUNCTIONS (port) \ - int s3serial##port##_init (void) {\ + int s3serial##port##_init (struct stdio_dev *dev) {\ return serial_init_dev(port);}\ - void s3serial##port##_setbrg (void) {\ + void s3serial##port##_setbrg (struct stdio_dev *dev) {\ serial_setbrg_dev(port);}\ - int s3serial##port##_getc (void) {\ + int s3serial##port##_getc (struct stdio_dev *dev) {\ return serial_getc_dev(port);}\ - int s3serial##port##_tstc (void) {\ + int s3serial##port##_tstc (struct stdio_dev *dev) {\ return serial_tstc_dev(port);}\ - void s3serial##port##_putc (const char c) {\ + void s3serial##port##_putc (struct stdio_dev *dev, const char c) {\ serial_putc_dev(port, c);}\ - void s3serial##port##_puts (const char *s) {\ + void s3serial##port##_puts (struct stdio_dev *dev, const char *s) {\ serial_puts_dev(port, s);}#define INIT_S3C_SERIAL_STRUCTURE (port,name,bus) {\
drivers/serial/usbtty.c +4 -4
@@ -388,7 +388,7 @@ static void str2wide (char *str, u16 * wide)* Test whether a character is in the RX buffer */ -int usbtty_tstc (void ) +int usbtty_tstc (struct stdio_dev *dev) {struct usb_endpoint_instance *endpoint = &endpoint_instance[rx_endpoint];
@@ -408,7 +408,7 @@ int usbtty_tstc (void)* written into its argument c. */ -int usbtty_getc (void ) +int usbtty_getc (struct stdio_dev *dev) {char c; struct usb_endpoint_instance *endpoint =
@@ -428,7 +428,7 @@ int usbtty_getc (void)/* * Output a single byte to the usb client port. */ -void usbtty_putc (const char c) +void usbtty_putc (struct stdio_dev *dev,const char c) {if (!usbtty_configured ())return ;
@@ -483,7 +483,7 @@ static void __usbtty_puts (const char *str, int len) } } -void usbtty_puts (const char *str) +void usbtty_puts (struct stdio_dev *dev,const char *str) {int n;int len;
drivers/video/cfb_console.c +3 -3
@@ -693,7 +693,7 @@ static void console_cr (void)/*****************************************************************************/ -void video_putc (const char c) +void video_putc (struct stdio_dev *dev,const char c) {static int nl =1 ;
@@ -737,12 +737,12 @@ CURSOR_SET}/*****************************************************************************/ -void video_puts (const char *s) +void video_puts (struct stdio_dev *dev,const char *s) {int count =strlen (s);while (count--) -video_putc (*s++); +video_putc (dev, *s++); }/*****************************************************************************/
include/i8042.h +2 -2
@@ -70,7 +70,7 @@/* exports */ int i8042_kbd_init (void ); -int i8042_tstc (void ); -int i8042_getc (void ); +int i8042_tstc (struct stdio_dev *dev); +int i8042_getc (struct stdio_dev *dev);#endif /* _I8042_H_ */
include/stdio_dev.h +7 -7
@@ -48,21 +48,21 @@ struct stdio_dev {/* GENERAL functions */ -int (*start) (void );/* To start the device */ -int (*stop) (void );/* To stop the device */ +int (*start) (struct stdio_dev *dev);/* To start the device */ +int (*stop) (struct stdio_dev *dev);/* To stop the device */ /* OUTPUT functions */ -void (*putc) (const char c);/* To put a char */ -void (*puts) (const char *s);/* To put a string (accelerator) */ +void (*putc) (struct stdio_dev *dev,const char c);/* To put a char */ +void (*puts) (struct stdio_dev *dev,const char *s);/* To put a string */ /* INPUT functions */ -int (*tstc) (void );/* To test if a char is ready... */ -int (*getc) (void );/* To get that char */ +int (*tstc) (struct stdio_dev *dev);/* To test if a char is ready.. */ +int (*getc) (struct stdio_dev *dev);/* To get that char */ /* Other functions */ -void (*setbrg) (void );/* Set baudrate */ +void (*setbrg) (struct stdio_dev *dev);/* Set baudrate */ void *priv;/* Private extensions */ struct list_head list;
lib_i386/video.c +2 -2
@@ -123,7 +123,7 @@ static void __video_putc(const char c, int *x, int *y) } } -static void video_putc (const char c) +static void video_putc (struct stdio_dev *dev,const char c) {int x,y,pos;
@@ -142,7 +142,7 @@ static void video_putc(const char c)outb_p (0xff & (pos >>1 ), vidport+1 ); } -static void video_puts (const char *s) +static void video_puts (struct stdio_dev *dev,const char *s) {int x,y,pos;char c;
Signature · 1 line
1.6.3.1
RFC PATCH 3/3 stdio/serial: factorize retrieve current device
--- common/serial.c | 62 +++++++++++++++++------------------------------------- 1 files changed, 20 insertions(+), 42 deletions(-)
common/serial.c +20 -42
@@ -179,77 +179,55 @@ void serial_reinit_all (void) } } -int serial_init (void ) +struct stdio_dev *serial_get_current_device (void ) { -if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) { -struct stdio_dev *dev =default_serial_console (); +if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) +return default_serial_console (); -if (dev->start) -return dev->start (dev); +return serial_current; +} -return 0 ; - } +int serial_init (void ) +{ +struct stdio_dev *dev =serial_get_current_device (); -if (serial_current->start) -return serial_current->start (serial_current); +if (dev->start) +return dev->start (dev);return 0 ; }void serial_setbrg (void ) { -if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) { -struct stdio_dev *dev =default_serial_console (); - - dev->setbrg (dev); -return ; - } +struct stdio_dev *dev =serial_get_current_device (); - serial_current->setbrg (serial_current); + dev->setbrg (dev); }int serial_getc (void ) { -if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) { -struct stdio_dev *dev =default_serial_console (); +struct stdio_dev *dev =serial_get_current_device (); -return dev->getc (dev); - } - -return serial_current->getc (serial_current); +return dev->getc (dev); }int serial_tstc (void ) { -if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) { -struct stdio_dev *dev =default_serial_console (); - -return dev->tstc (dev); - } +struct stdio_dev *dev =serial_get_current_device (); -return serial_current->tstc (serial_current); +return dev->tstc (dev); }void serial_putc (const char c) { -if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) { -struct stdio_dev *dev =default_serial_console (); +struct stdio_dev *dev =serial_get_current_device (); - dev->putc (dev, c); -return ; - } - - serial_current->putc (serial_current, c); + dev->putc (dev, c); }void serial_puts (const char *s) { -if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) { -struct stdio_dev *dev =default_serial_console (); - - dev->puts (dev, s); -return ; - } +struct stdio_dev *dev =serial_get_current_device (); - serial_current->puts (serial_current, s); + dev->puts (dev, s); }
Signature · 1 line
1.6.3.1
RFC PATCH 3/3 stdio/serial: factorize retrieve current device
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 1 line · In message <[email protected]> you wrote:
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>
Please add a commit message that exaplains what you are doing. Your
Subject: line is not sufficient.
common/serial.c void serial_reinit_all (void) · line 195
Quoted 8 lines
common/serial.c +5
-2+int serial_init (void ) +{ +struct stdio_dev *dev =serial_get_current_device (); -if (serial_current->start) -return serial_current->start (serial_current); +if (dev->start) +return dev->start (dev);
What happens if dev == NULL ?
common/serial.c void serial_reinit_all (void) · line 204
Quoted 12 lines
void
serial_setbrg(void)
{common/serial.c +2
-7-if (!(gd->flags &GD_FLG_RELOC ) || !serial_current) { -struct stdio_dev *dev =default_serial_console (); - - dev->setbrg (dev); -return ; - } +struct stdio_dev *dev =serial_get_current_device (); - serial_current->setbrg (serial_current); + dev->setbrg (dev);
What happens if dev == NULL ?
etc.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de No question is too silly to ask. Of course, some questions are too silly to to answer... - L. Wall & R. L. Schwartz, _Programming Perl_
RFC PATCH 2/3 stdio: pass the current device to the driver
In reply to Jean-Christophe PLAGNIOL-VILLARDDear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 3 lines · In message <[email protected]> you wrote:
to allow it to have base address and other information to simplify the implementation and avoid workarround as done for ns16550 on the omap3 zoom or ppc4xx as example
Can you please explain what you mean?
Sorry, but I do not understand your commit message. Please use complete sentences.
If I understood your patch 1/3 correctly, you introduces a current device; if this is correct, then why do we need to add allt he additional function arguments?
Isn't this only adding to the memory footprint?
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de It is practically impossible to teach good programming style to stu- dents that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. - Dijkstra
Wolfgang Denk
NAKRFC PATCH 1/3 serial: join stdio_dev and serial_device
In reply to Jean-Christophe PLAGNIOL-VILLARDDear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 27 lines · In message <[email protected]> you wrote:
we use for the serail multi api the struct
stdio_devalso which will reduce and simplify the code and prepare the join of all serial APIs.Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>--- board/esd/pmc440/pmc440.c | 2 +- board/lwmon/lwmon.c | 2 +- board/omap3/zoom2/zoom2_serial.h | 18 +++--- board/trizepsiv/conxs.c | 8 ++-- common/serial.c | 89 +++++++++++++++---------------- common/stdio.c | 3 - cpu/mpc5xxx/serial.c | 36 ++++++------ cpu/mpc8xx/serial.c | 36 ++++++------ cpu/ppc4xx/4xx_uart.c | 38 +++++++------- drivers/serial/serial.c | 24 ++++---- drivers/serial/serial_pxa.c | 54 +++++++++--------- drivers/serial/serial_s3c24x0.c | 22 ++++---- include/serial.h | 109 ++++++++++++++++--------------------- include/stdio_dev.h | 9 +++- 14 files changed, 218 insertions(+), 232 deletions(-)rewrite
include/serial.h(65%)board/esd/pmc440/pmc440.c +0
-0
board/esd/pmc440/pmc440.c int is_monarch(void); · line 56
Quoted 5 lines
board/esd/pmc440/pmc440.c +1
-1@@ -53,7 +53,7 @@ int is_monarch(void);int bootstrap_eeprom_read (unsigned dev_addr,unsigned offset,uchar *buffer,unsigned cnt); -struct serial_device *default_serial_console (void ) +struct stdio_dev *default_serial_console (void )
I don't think the renaming of "serial" into "stdio" is a good idea.
"stdio" is a more specific term, which can only be applied to the standard input/output channes (sdin, stdout and stderr); in other words, this is restricted to the serial ports used as console interface.
However, "serial" is a more general term - in addition to the stdio devices this may be used for example for additional serial ports controlling other things.
...
board/esd/pmc440/pmc440.c int is_monarch(void); · line 59
Quoted 5 lines
board/esd/pmc440/pmc440.c +2
-2-int serial_register (struct serial_device *dev) +int serial_register (struct stdio_dev *dev) { - dev->init += gd->reloc_off; + dev->flags =DEV_FLAGS_OUTPUT |DEV_FLAGS_INPUT |DEV_FLAGS_SERIAL ;
Please see comment below about DEV_FLAGS_SERIAL.
board/esd/pmc440/pmc440.c
Quoted 6 lines
board/esd/pmc440/pmc440.c +2
-3-void serial_stdio_init (void ) +static struct stdio_dev *serial_get_by_name (char * name) { -struct stdio_dev dev; -struct serial_device *s = serial_devices; +struct stdio_dev *dev =stdio_get_by_name (name);
Here it becomes clear that your renaming of serial into stdio is not consistent; to me it makes no sense.
Why is it serial_get_by_name() [note: "serial"], when it actually returns a "struct stdio_dev*"?
You call stdio_get_by_name() internally?
That does not amke sense. How can you get a device from a wider class (serial devices), when you consider only a smaller selection (stio devices)?
Hmmm... What is a "stdio device" by the way?
When we use a USB keyboard and assign it as stdin, it is a stdio device, right? when we assing a LCD outpout as stdout and stderr, it is a stdio device, right?
include/stdio_dev.h line 35
Quoted 7 lines
include/stdio_dev.h +1
-0@@ -32,14 +32,19 @@#define DEV_FLAGS_INPUT 0x00000001/* Device can be used as input console */ #define DEV_FLAGS_OUTPUT 0x00000002/* Device can be used as output console */ +#define DEV_FLAGS_SERIAL 0x00000003/* Device is a serial device */
No.
This makes no sense at all. DEV_FLAGS_* are bit names. DEV_FLAGS_SERIAL migfht be 4, but in no case it makes sense to use 3 here, which is "DEV_FLAGS_INPUT | DEV_FLAGS_OUTPUT".
include/stdio_dev.h line 47
Quoted 7 lines
include/stdio_dev.h +2
-1/* Device information */ struct stdio_dev {int flags;/* Device flags: input/output/system */ int ext;/* Supported extensions */ -char name[16 ];/* Device name */ +char name[NAMESIZE ];/* Device name */ +char ctlr[CTLRSIZE ];
Comment? What's ctlr[CTLRSIZE] supposed to mean?
NAK.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de A witty saying proves nothing, but saying something pointless gets people's attention.