Commit 52cb4d4f authored by Jean-Christophe PLAGNIOL-VILLARD's avatar Jean-Christophe PLAGNIOL-VILLARD Committed by Wolfgang Denk

stdio/device: rework function naming convention

So far the console API uses the following naming convention:

	======Extract======
	typedef struct device_t;

	int	device_register (device_t * dev);
	int	devices_init (void);
	int	device_deregister(char *devname);
	struct list_head* device_get_list(void);
	device_t* device_get_by_name(char* name);
	device_t* device_clone(device_t *dev);
	=======

which is too generic and confusing.

Instead of using device_XX and device_t we change this
into stdio_XX and stdio_dev

This will also allow to add later a generic device mechanism in order
to have support for multiple devices and driver instances.
Signed-off-by: 's avatarJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Edited commit message.
Signed-off-by: 's avatarWolfgang Denk <wd@denx.de>
parent f732a759
......@@ -34,7 +34,7 @@
*/
#include <common.h>
#include <asm/processor.h>
#include <devices.h>
#include <stdio_dev.h>
#include "ps2kbd.h"
......@@ -226,7 +226,7 @@ int overwrite_console (void)
int drv_isa_kbd_init (void)
{
int error;
device_t kbddev ;
struct stdio_dev kbddev ;
char *stdinname = getenv ("stdin");
if(isa_kbd_init() == -1)
......@@ -239,7 +239,7 @@ int drv_isa_kbd_init (void)
kbddev.getc = kbd_getc ;
kbddev.tstc = kbd_testc ;
error = device_register (&kbddev);
error = stdio_register (&kbddev);
if(error==0) {
/* check if this is the standard input device */
if(strcmp(stdinname,DEVNAME)==0) {
......
......@@ -22,7 +22,7 @@
*/
#include <common.h>
#include <devices.h>
#include <stdio_dev.h>
#include "memio.h"
#include <part.h>
......@@ -98,7 +98,7 @@ int video_inited = 0;
int drv_video_init(void)
{
int error, devices = 1 ;
device_t vgadev ;
struct stdio_dev vgadev ;
if (video_inited) return 1;
video_inited = 1;
video_init();
......@@ -112,7 +112,7 @@ int drv_video_init(void)
vgadev.tstc = NULL;
vgadev.start = video_start;
error = device_register (&vgadev);
error = stdio_register (&vgadev);
if (error == 0)
{
......
......@@ -14,7 +14,7 @@
#include <asm/mach-common/bits/dma.h>
#include <i2c.h>
#include <linux/types.h>
#include <devices.h>
#include <stdio_dev.h>
int gunzip(void *, int, unsigned char *, unsigned long *);
......@@ -272,7 +272,7 @@ void video_puts(const char *s)
int drv_video_init(void)
{
int error, devices = 1;
device_t videodev;
struct stdio_dev videodev;
u8 *dst;
u32 fbmem_size = LCD_X_RES * LCD_Y_RES * LCD_PIXEL_SIZE + ACTIVE_VIDEO_MEM_OFFSET;
......@@ -311,7 +311,7 @@ int drv_video_init(void)
videodev.putc = video_putc; /* 'putc' function */
videodev.puts = video_puts; /* 'puts' function */
error = device_register(&videodev);
error = stdio_register(&videodev);
return (error == 0) ? devices : error;
}
......@@ -18,7 +18,7 @@
#include <asm/mach-common/bits/dma.h>
#include <i2c.h>
#include <linux/types.h>
#include <devices.h>
#include <stdio_dev.h>
int gunzip(void *, int, unsigned char *, unsigned long *);
......@@ -154,7 +154,7 @@ static void video_init(char *NTSCFrame)
int drv_video_init(void)
{
device_t videodev;
struct stdio_dev videodev;
video_init((void *)NTSC_FRAME_ADDR);
......@@ -163,5 +163,5 @@ int drv_video_init(void)
videodev.ext = DEV_EXT_VIDEO;
videodev.flags = DEV_FLAGS_SYSTEM;
return device_register(&videodev);
return stdio_register(&videodev);
}
......@@ -14,7 +14,7 @@
#include <asm/mach-common/bits/dma.h>
#include <i2c.h>
#include <linux/types.h>
#include <devices.h>
#include <stdio_dev.h>
int gunzip(void *, int, unsigned char *, unsigned long *);
......@@ -282,7 +282,7 @@ void video_puts(const char *s)
int drv_video_init(void)
{
int error, devices = 1;
device_t videodev;
struct stdio_dev videodev;
u8 *dst;
u32 fbmem_size = LCD_X_RES * LCD_Y_RES * LCD_PIXEL_SIZE + ACTIVE_VIDEO_MEM_OFFSET;
......@@ -321,7 +321,7 @@ int drv_video_init(void)
videodev.putc = video_putc; /* 'putc' function */
videodev.puts = video_puts; /* 'puts' function */
error = device_register(&videodev);
error = stdio_register(&videodev);
return (error == 0) ? devices : error;
}
......@@ -26,7 +26,7 @@
#include <watchdog.h>
#include <command.h>
#include <malloc.h>
#include <devices.h>
#include <stdio_dev.h>
#include <net.h>
#include <timestamp.h>
#include <dtt.h>
......
......@@ -33,7 +33,7 @@
#include "../common/fsl_diu_fb.h"
#if defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)
#include <devices.h>
#include <stdio_dev.h>
#include <video_fb.h>
#endif
......
......@@ -22,7 +22,7 @@
*/
#include <common.h>
#include <ns16550.h>
#include <console.h>
#include <stdio_dev.h>
/* Button codes from the AVR */
#define PWRR 0x20 /* Power button release */
......
......@@ -29,7 +29,7 @@
#include <asm/processor.h>
#include <asm/byteorder.h>
#include <i2c.h>
#include <devices.h>
#include <stdio_dev.h>
#include <pci.h>
#include <malloc.h>
#include <bzlib.h>
......
......@@ -26,7 +26,7 @@
#include <common.h>
#include <asm/processor.h>
#include <devices.h>
#include <stdio_dev.h>
#include "isa.h"
#include "piix4_pci.h"
#include "kbd.h"
......
......@@ -28,7 +28,7 @@
*/
#include <common.h>
#include <asm/processor.h>
#include <devices.h>
#include <stdio_dev.h>
#include "isa.h"
#include "kbd.h"
......@@ -215,7 +215,7 @@ int overwrite_console (void)
int drv_isa_kbd_init (void)
{
int error;
device_t kbddev ;
struct stdio_dev kbddev ;
char *stdinname = getenv ("stdin");
if(isa_kbd_init()==-1)
......@@ -228,7 +228,7 @@ int drv_isa_kbd_init (void)
kbddev.getc = kbd_getc ;
kbddev.tstc = kbd_testc ;
error = device_register (&kbddev);
error = stdio_register (&kbddev);
if(error==0) {
/* check if this is the standard input device */
if(strcmp(stdinname,DEVNAME)==0) {
......
......@@ -46,7 +46,7 @@
#include <common.h>
#include <mpc5xx.h>
#include <devices.h>
#include <stdio_dev.h>
#include <pci_ids.h>
#define PLX9056_LOC
#include "plx9056.h"
......@@ -447,7 +447,7 @@ int checkboard (void)
int recbuf[REC_BUFFER_SIZE];
static int r_ptr = 0;
int w_ptr;
device_t pci_con_dev;
struct stdio_dev pci_con_dev;
int conn=0;
int buff_full=0;
......@@ -584,7 +584,7 @@ void pci_con_connect(void)
pci_con_dev.puts = pci_con_puts;
pci_con_dev.getc = pci_con_getc;
pci_con_dev.tstc = pci_con_tstc;
device_register (&pci_con_dev);
stdio_register (&pci_con_dev);
printf("PATI ready for PCI connection, type ctrl-c for exit\n");
do {
udelay(10);
......
......@@ -37,7 +37,7 @@
#include <version.h>
#include <linux/types.h>
#include <devices.h>
#include <stdio_dev.h>
#include <sed156x.h>
......@@ -325,7 +325,7 @@ int phone_getc(void)
int drv_phone_init(void)
{
device_t console_dev;
struct stdio_dev console_dev;
console_init();
......@@ -340,7 +340,7 @@ int drv_phone_init(void)
console_dev.tstc = phone_tstc; /* 'tstc' function */
console_dev.getc = phone_getc; /* 'getc' function */
if (device_register(&console_dev) == 0)
if (stdio_register(&console_dev) == 0)
return 1;
return 0;
......
......@@ -30,7 +30,7 @@
#include <common.h>
#include <watchdog.h>
#include <commproc.h>
#include <devices.h>
#include <stdio_dev.h>
#include <lcd.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -249,18 +249,18 @@ int smc1_tstc(void)
int drv_keyboard_init(void)
{
int error = 0;
device_t kbd_dev;
struct stdio_dev kbd_dev;
if (0) {
/* register the keyboard */
memset (&kbd_dev, 0, sizeof(device_t));
memset (&kbd_dev, 0, sizeof(struct stdio_dev));
strcpy(kbd_dev.name, "kbd");
kbd_dev.flags = DEV_FLAGS_INPUT | DEV_FLAGS_SYSTEM;
kbd_dev.putc = NULL;
kbd_dev.puts = NULL;
kbd_dev.getc = smc1_getc;
kbd_dev.tstc = smc1_tstc;
error = device_register (&kbd_dev);
error = stdio_register (&kbd_dev);
} else {
lcd_is_enabled = 0;
lcd_disable();
......
......@@ -36,7 +36,7 @@
#include <version.h>
#include <stdarg.h>
#include <linux/types.h>
#include <devices.h>
#include <stdio_dev.h>
#include <s3c2400.h>
DECLARE_GLOBAL_DATA_PTR;
......
......@@ -32,7 +32,6 @@ COBJS-y += main.o
COBJS-y += circbuf.o
COBJS-y += console.o
COBJS-y += command.o
COBJS-y += devices.o
COBJS-y += dlmalloc.o
COBJS-y += exports.o
COBJS-$(CONFIG_SYS_HUSH_PARSER) += hush.o
......@@ -40,6 +39,7 @@ COBJS-y += image.o
COBJS-y += memsize.o
COBJS-y += s_record.o
COBJS-$(CONFIG_SERIAL_MULTI) += serial.o
COBJS-y += stdio.o
COBJS-y += xyzModem.o
# core command
......
......@@ -26,22 +26,22 @@
*/
#include <common.h>
#include <command.h>
#include <devices.h>
#include <stdio_dev.h>
extern void _do_coninfo (void);
int do_coninfo (cmd_tbl_t * cmd, int flag, int argc, char *argv[])
{
int l;
struct list_head *list = device_get_list();
struct list_head *list = stdio_get_list();
struct list_head *pos;
device_t *dev;
struct stdio_dev *dev;
/* Scan for valid output and input devices */
puts ("List of available devices:\n");
list_for_each(pos, list) {
dev = list_entry(pos, device_t, list);
dev = list_entry(pos, struct stdio_dev, list);
printf ("%-8s %08x %c%c%c ",
dev->name,
......
......@@ -42,7 +42,7 @@
#include <common.h>
#include <command.h>
#include <devices.h>
#include <stdio_dev.h>
#include <post.h>
#include <logbuff.h>
......@@ -142,7 +142,7 @@ void logbuff_reset (void)
int drv_logbuff_init (void)
{
device_t logdev;
struct stdio_dev logdev;
int rc;
/* Device initialization */
......@@ -154,7 +154,7 @@ int drv_logbuff_init (void)
logdev.putc = logbuff_putc; /* 'putc' function */
logdev.puts = logbuff_puts; /* 'puts' function */
rc = device_register (&logdev);
rc = stdio_register (&logdev);
return (rc == 0) ? 1 : rc;
}
......
......@@ -26,19 +26,19 @@
*/
#include <common.h>
#include <command.h>
#include <devices.h>
#include <stdio_dev.h>
#include <serial.h>
int do_terminal(cmd_tbl_t * cmd, int flag, int argc, char *argv[])
{
int last_tilde = 0;
device_t *dev = NULL;
struct stdio_dev *dev = NULL;
if (argc < 1)
return -1;
/* Scan for selected output/input device */
dev = device_get_by_name(argv[1]);
dev = stdio_get_by_name(argv[1]);
if (!dev)
return -1;
......
......@@ -24,7 +24,7 @@
#include <common.h>
#include <stdarg.h>
#include <malloc.h>
#include <console.h>
#include <stdio_dev.h>
#include <exports.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -48,7 +48,7 @@ extern int overwrite_console(void);
#endif /* CONFIG_SYS_CONSOLE_IS_IN_ENV */
static int console_setfile(int file, device_t * dev)
static int console_setfile(int file, struct stdio_dev * dev)
{
int error = 0;
......@@ -96,8 +96,8 @@ static int console_setfile(int file, device_t * dev)
#if defined(CONFIG_CONSOLE_MUX)
/** Console I/O multiplexing *******************************************/
static device_t *tstcdev;
device_t **console_devices[MAX_FILES];
static struct stdio_dev *tstcdev;
struct stdio_dev **console_devices[MAX_FILES];
int cd_count[MAX_FILES];
/*
......@@ -119,7 +119,7 @@ static int console_getc(int file)
static int console_tstc(int file)
{
int i, ret;
device_t *dev;
struct stdio_dev *dev;
disable_ctrlc(1);
for (i = 0; i < cd_count[file]; i++) {
......@@ -141,7 +141,7 @@ static int console_tstc(int file)
static void console_putc(int file, const char c)
{
int i;
device_t *dev;
struct stdio_dev *dev;
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
......@@ -153,7 +153,7 @@ static void console_putc(int file, const char c)
static void console_puts(int file, const char *s)
{
int i;
device_t *dev;
struct stdio_dev *dev;
for (i = 0; i < cd_count[file]; i++) {
dev = console_devices[file][i];
......@@ -167,7 +167,7 @@ static inline void console_printdevs(int file)
iomux_printdevs(file);
}
static inline void console_doenv(int file, device_t *dev)
static inline void console_doenv(int file, struct stdio_dev *dev)
{
iomux_doenv(file, dev->name);
}
......@@ -197,7 +197,7 @@ static inline void console_printdevs(int file)
printf("%s\n", stdio_devices[file]->name);
}
static inline void console_doenv(int file, device_t *dev)
static inline void console_doenv(int file, struct stdio_dev *dev)
{
console_setfile(file, dev);
}
......@@ -479,11 +479,11 @@ inline void dbg(const char *fmt, ...)
/** U-Boot INIT FUNCTIONS *************************************************/
device_t *search_device(int flags, char *name)
struct stdio_dev *search_device(int flags, char *name)
{
device_t *dev;
struct stdio_dev *dev;
dev = device_get_by_name(name);
dev = stdio_get_by_name(name);
if (dev && (dev->flags & flags))
return dev;
......@@ -494,7 +494,7 @@ device_t *search_device(int flags, char *name)
int console_assign(int file, char *devname)
{
int flag;
device_t *dev;
struct stdio_dev *dev;
/* Check for valid file */
switch (file) {
......@@ -537,7 +537,7 @@ int console_init_f(void)
int console_init_r(void)
{
char *stdinname, *stdoutname, *stderrname;
device_t *inputdev = NULL, *outputdev = NULL, *errdev = NULL;
struct stdio_dev *inputdev = NULL, *outputdev = NULL, *errdev = NULL;
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
int i;
#endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
......@@ -645,11 +645,11 @@ done:
/* Called after the relocation - use desired console functions */
int console_init_r(void)
{
device_t *inputdev = NULL, *outputdev = NULL;
struct stdio_dev *inputdev = NULL, *outputdev = NULL;
int i;
struct list_head *list = device_get_list();
struct list_head *list = stdio_get_list();
struct list_head *pos;
device_t *dev;
struct stdio_dev *dev;
#ifdef CONFIG_SPLASH_SCREEN
/*
......@@ -662,7 +662,7 @@ int console_init_r(void)
/* Scan devices looking for input and output devices */
list_for_each(pos, list) {
dev = list_entry(pos, device_t, list);
dev = list_entry(pos, struct stdio_dev, list);
if ((dev->flags & DEV_FLAGS_INPUT) && (inputdev == NULL)) {
inputdev = dev;
......
......@@ -29,7 +29,7 @@
void iomux_printdevs(const int console)
{
int i;
device_t *dev;
struct stdio_dev *dev;
for (i = 0; i < cd_count[console]; i++) {
dev = console_devices[console][i];
......@@ -43,8 +43,8 @@ int iomux_doenv(const int console, const char *arg)
{
char *console_args, *temp, **start;
int i, j, k, io_flag, cs_idx, repeat;
device_t *dev;
device_t **cons_set;
struct stdio_dev *dev;
struct stdio_dev **cons_set;
console_args = strdup(arg);
if (console_args == NULL)
......@@ -85,7 +85,7 @@ int iomux_doenv(const int console, const char *arg)
*temp = '\0';
start[i] = temp + 1;
}
cons_set = (device_t **)calloc(i, sizeof(device_t *));
cons_set = (struct stdio_dev **)calloc(i, sizeof(struct stdio_dev *));
if (cons_set == NULL) {
free(start);
free(console_args);
......@@ -158,14 +158,14 @@ int iomux_doenv(const int console, const char *arg)
} else {
/* Works even if console_devices[console] is NULL. */
console_devices[console] =
(device_t **)realloc(console_devices[console],
cs_idx * sizeof(device_t *));
(struct stdio_dev **)realloc(console_devices[console],
cs_idx * sizeof(struct stdio_dev *));
if (console_devices[console] == NULL) {
free(cons_set);
return 1;
}
memcpy(console_devices[console], cons_set, cs_idx *
sizeof(device_t *));
sizeof(struct stdio_dev *));
cd_count[console] = cs_idx;
}
......
......@@ -34,7 +34,7 @@
#include <command.h>
#include <stdarg.h>
#include <linux/types.h>
#include <devices.h>
#include <stdio_dev.h>
#if defined(CONFIG_POST)
#include <post.h>
#endif
......@@ -355,7 +355,7 @@ static void test_pattern (void)
int drv_lcd_init (void)
{
device_t lcddev;
struct stdio_dev lcddev;
int rc;
lcd_base = (void *)(gd->fb_base);
......@@ -373,7 +373,7 @@ int drv_lcd_init (void)
lcddev.putc = lcd_putc; /* 'putc' function */
lcddev.puts = lcd_puts; /* 'puts' function */
rc = device_register (&lcddev);
rc = stdio_register (&lcddev);
return (rc == 0) ? 1 : rc;
}
......
......@@ -23,7 +23,7 @@
#include <common.h>
#include <serial.h>
#include <devices.h>
#include <stdio_dev.h>
DECLARE_GLOBAL_DATA_PTR;
......@@ -142,9 +142,9 @@ void serial_initialize (void)
serial_assign (default_serial_console ()->name);
}
void serial_devices_init (void)
void serial_stdio_init (void)
{
device_t dev;
struct stdio_dev dev;
struct serial_device *s = serial_devices;
while (s) {
......@@ -159,7 +159,7 @@ void serial_devices_init (void)
dev.getc = s->getc;
dev.tstc = s->tstc;
device_register (&dev);
stdio_register (&dev);
s = s->next;
}
......
......@@ -25,7 +25,7 @@
#include <common.h>
#include <stdarg.h>
#include <malloc.h>
#include <devices.h>
#include <stdio_dev.h>
#include <serial.h>
#ifdef CONFIG_LOGBUFFER
#include <logbuff.h>
......@@ -36,8 +36,8 @@
DECLARE_GLOBAL_DATA_PTR;
static device_t devs;
device_t *stdio_devices[] = { NULL, NULL, NULL };
static struct stdio_dev devs;
struct stdio_dev *stdio_devices[] = { NULL, NULL, NULL };
char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" };
#if defined(CONFIG_SPLASH_SCREEN) && !defined(CONFIG_SYS_DEVICE_NULLDEV)
......@@ -70,7 +70,7 @@ int nulldev_input(void)
static void drv_system_init (void)
{
device_t dev;
struct stdio_dev dev;
memset (&dev, 0, sizeof (dev));
......@@ -88,7 +88,7 @@ static void drv_system_init (void)
dev.tstc = serial_tstc;
#endif
device_register (&dev);
stdio_register (&dev);
#ifdef CONFIG_SYS_DEVICE_NULLDEV
memset (&dev, 0, sizeof (dev));
......@@ -100,7 +100,7 @@ static void drv_system_init (void)
dev.getc = nulldev_input;
dev.tstc = nulldev_input;
device_register (&dev);
stdio_register (&dev);
#endif
}
......@@ -108,21 +108,21 @@ static void drv_system_init (void)
* DEVICES
**************************************************************************
*/
struct list_head* device_get_list(void)
struct list_head* stdio_get_list(void)
{
return &(devs.list);
}
device_t* device_get_by_name(char* name)
struct stdio_dev* stdio_get_by_name(char* name)
{
struct list_head *pos;
device_t *dev;
struct stdio_dev *dev;
if(!name)
return NULL;
list_for_each(pos, &(devs.list)) {
dev = list_entry(pos, device_t, list);
dev = list_entry(pos, struct stdio_dev, list);
if(strcmp(dev->name, name) == 0)
return dev;
}
......@@ -130,29 +130,29 @@ device_t* device_get_by_name(char* name)
return NULL;
}
device_t* device_clone(device_t *dev)
struct stdio_dev* stdio_clone(struct stdio_dev *dev)
{
device_t *_dev;
struct stdio_dev *_dev;
if(!dev)
return NULL;
_dev = calloc(1, sizeof(device_t));
_dev = calloc(1, sizeof(struct stdio_dev));
if(!_dev)
return NULL;
memcpy(_dev, dev, sizeof(device_t));
memcpy(_dev, dev, sizeof(struct stdio_dev));
strncpy(_dev->name, dev->name, 16);
return _dev;
}
int device_register (device_t * dev)
int stdio_register (struct stdio_dev * dev)
{
device_t *_dev;
struct stdio_dev *_dev;
_dev = device_clone(dev);
_dev = stdio_clone(dev);
if(!_dev)
return -1;
list_add_tail(&(_dev->list), &(devs.list));
......@@ -162,15 +162,15 @@ int device_register (device_t * dev)
/* deregister the device "devname".
* returns 0 if success, -1 if device is assigned and 1 if devname not found
*/
#ifdef CONFIG_SYS_DEVICE_DEREGISTER
int device_deregister(char *devname)
#ifdef CONFIG_SYS_STDIO_DEREGISTER
int stdio_deregister(char *devname)
{
int l;