From: Marek Vasut Date: Sat, 1 Sep 2012 00:44:11 +0200 Subject: [U-Boot] [PATCH 2/6] stdio: dm: Add accessors to stdio_devices[] In-Reply-To: <1346453055-30888-1-git-send-email-marex@denx.de> References: <1346453055-30888-1-git-send-email-marex@denx.de> Message-ID: <1346453055-30888-3-git-send-email-marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Implement stdio_get_fd() and stdio_set_fd() calls to access currently assigned STDIO devices. This will in turn allow to make the stdio_devices[] local to stdio.c Signed-off-by: Marek Vasut Cc: Wolfgang Denk --- common/stdio.c | 26 ++++++++++++++++++++++++++ include/stdio_dev.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/common/stdio.c b/common/stdio.c index 1bf9ba0..6c8ac73 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -33,6 +33,7 @@ #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) #include #endif +#include DECLARE_GLOBAL_DATA_PTR; @@ -122,6 +123,31 @@ struct stdio_dev* stdio_get_by_name(const char *name) return NULL; } +struct stdio_dev *stdio_get_fd(int ioe) +{ + switch (ioe) { + case stdin: + case stdout: + case stderr: + return stdio_devices[ioe]; + default: + return NULL; + } +} + +int stdio_set_fd(int ioe, struct stdio_dev *dev) +{ + switch (ioe) { + case stdin: + case stdout: + case stderr: + stdio_devices[ioe] = dev; + return 0; + default: + return -EINVAL; + } +} + struct stdio_dev* stdio_clone(struct stdio_dev *dev) { struct stdio_dev *_dev; diff --git a/include/stdio_dev.h b/include/stdio_dev.h index 23e0ee1..86b2a4f 100644 --- a/include/stdio_dev.h +++ b/include/stdio_dev.h @@ -97,6 +97,8 @@ int stdio_deregister(const char *devname); #endif struct list_head* stdio_get_list(void); struct stdio_dev* stdio_get_by_name(const char* name); +struct stdio_dev *stdio_get_fd(int ioe); +int stdio_set_fd(int ioe, struct stdio_dev *dev); struct stdio_dev* stdio_clone(struct stdio_dev *dev); #ifdef CONFIG_ARM_DCC_MULTI -- 1.7.10.4