ADD: [nrhw18] allow checking for existance of files without getting error message

BugzID: 49311
This commit is contained in:
Marcel Reichmuth 2018-11-02 08:13:34 +01:00
parent f68df0ad00
commit e0c3093625
5 changed files with 47 additions and 6 deletions

View File

@ -18,7 +18,8 @@ void find_and_set_active_partition(void)
void set_console(void)
{
char buf[50] = "\0";
char buf[6];
char consolefile[] = "/root/boot/consoledev";
char *defaultconsole = env_get("defaultconsole");
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
@ -26,8 +27,14 @@ void set_console(void)
read_file_set_blk_dev("mmc", "0:3", FS_TYPE_EXT);
len = read_file("/root/boot/consoledev", buf, 16);
if ((len != 5) || (strstr(buf, "tty")!=buf) || ((buf[4]<'0') && (buf[4]>'1'))) {
len = get_file_size(consolefile);
if (len>=5) {
read_file(consolefile, buf, sizeof(buf));
buf[sizeof(buf)-1] = 0;
if ((strstr(buf, "tty")!=buf) || ((buf[4]<'0') && (buf[4]>'1'))) {
buf[0] = 0;
}
} else {
buf[0] = 0;
}

View File

@ -14,6 +14,22 @@ void read_file_set_blk_dev(const char *ifname,
l_fstype = fstype;
}
int get_file_size(const char* filename)
{
loff_t filesize = 0;
if (fs_set_blk_dev("mmc", "0:3", FS_TYPE_EXT) != 0) {
puts("Error, can not set blk device\n");
return -1;
}
if (fs_size(filename, &filesize)) {
return -1;
}
return filesize;
}
int read_file(const char* filename, char *buf, int size)
{
loff_t filesize = 0;

View File

@ -9,7 +9,25 @@
#define FILEACCESS_H
#include <fs.h>
/**
* Query the file size of a file in the file system
*
* @param filename [input] Name of the file including path
* @return File size of -1, if the file does not exist
*/
int get_file_size(const char* filename);
/**
* Read a file from file system
*
* @param filename [input] Name of the file including path
* @param buf [input] Buffer to store the file
* @param size [input] Maximum number of bytes to be read.
* must be bigger than size of file.
* @return Number of read bytes or -1 on error
*/
int read_file(const char* filename, char *buf, int size);
void read_file_set_blk_dev(const char *ifname,
const char *dev_part_str, int fstype);

View File

@ -823,7 +823,7 @@ static int nbhw_fpga_bind(struct udevice *dev)
/* Get memory region for fpga */
priv->regs = (struct mvebu_gpio_regs *)devfdt_get_addr(dev);
printf("FPGA Regs: %p\n", priv->regs);
debug("FPGA Regs: %p\n", priv->regs);
return 0;
}

View File

@ -124,12 +124,12 @@ static void read_eeprom_serdes_config(void)
goto fail;
}
printf("Valid user serdes config found\n");
printf("Using user defined serdes config override\n");
return;
fail:
memset(&eeprom_serdes_config, 0xff, sizeof(eeprom_serdes_config));
printf("No user serdes config found\n");
printf("Using default serdes config (No user defined override)\n");
return;
}