ADD: [nrhw18] allow checking for existance of files without getting error message
BugzID: 49311
This commit is contained in:
parent
f68df0ad00
commit
e0c3093625
|
|
@ -18,7 +18,8 @@ void find_and_set_active_partition(void)
|
||||||
|
|
||||||
void set_console(void)
|
void set_console(void)
|
||||||
{
|
{
|
||||||
char buf[50] = "\0";
|
char buf[6];
|
||||||
|
char consolefile[] = "/root/boot/consoledev";
|
||||||
char *defaultconsole = env_get("defaultconsole");
|
char *defaultconsole = env_get("defaultconsole");
|
||||||
|
|
||||||
#if defined(CONFIG_PRE_CONSOLE_BUFFER)
|
#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);
|
read_file_set_blk_dev("mmc", "0:3", FS_TYPE_EXT);
|
||||||
|
|
||||||
len = read_file("/root/boot/consoledev", buf, 16);
|
len = get_file_size(consolefile);
|
||||||
if ((len != 5) || (strstr(buf, "tty")!=buf) || ((buf[4]<'0') && (buf[4]>'1'))) {
|
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;
|
buf[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,22 @@ void read_file_set_blk_dev(const char *ifname,
|
||||||
l_fstype = fstype;
|
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)
|
int read_file(const char* filename, char *buf, int size)
|
||||||
{
|
{
|
||||||
loff_t filesize = 0;
|
loff_t filesize = 0;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,25 @@
|
||||||
#define FILEACCESS_H
|
#define FILEACCESS_H
|
||||||
#include <fs.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);
|
int read_file(const char* filename, char *buf, int size);
|
||||||
|
|
||||||
void read_file_set_blk_dev(const char *ifname,
|
void read_file_set_blk_dev(const char *ifname,
|
||||||
const char *dev_part_str, int fstype);
|
const char *dev_part_str, int fstype);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -823,7 +823,7 @@ static int nbhw_fpga_bind(struct udevice *dev)
|
||||||
|
|
||||||
/* Get memory region for fpga */
|
/* Get memory region for fpga */
|
||||||
priv->regs = (struct mvebu_gpio_regs *)devfdt_get_addr(dev);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,12 +124,12 @@ static void read_eeprom_serdes_config(void)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Valid user serdes config found\n");
|
printf("Using user defined serdes config override\n");
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
memset(&eeprom_serdes_config, 0xff, sizeof(eeprom_serdes_config));
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue