9
0
Fork 0

Merge branch 'for-next/include-cleanup'

This commit is contained in:
Sascha Hauer 2016-05-09 08:49:42 +02:00
commit 55aca0a48c
130 changed files with 510 additions and 585 deletions

View File

@ -123,7 +123,7 @@ static int edb93xx_console_init(void)
else else
shortname = "unknown"; shortname = "unknown";
board = asprintf("Cirrus Logic %s", shortname); board = basprintf("Cirrus Logic %s", shortname);
barebox_set_model(board); barebox_set_model(board);
free(board); free(board);
barebox_set_hostname(shortname); barebox_set_hostname(shortname);

View File

@ -70,8 +70,8 @@ static int e9_devices_init(void)
armlinux_set_architecture(3980); armlinux_set_architecture(3980);
environment_path = asprintf("/chosen/environment-mmc%d", environment_path = basprintf("/chosen/environment-mmc%d",
bootsource_get_instance()); bootsource_get_instance());
ret = of_device_enable_path(environment_path); ret = of_device_enable_path(environment_path);

View File

@ -125,20 +125,20 @@ static int physom_imx6_devices_init(void)
switch (bootsource_get()) { switch (bootsource_get()) {
case BOOTSOURCE_MMC: case BOOTSOURCE_MMC:
environment_path = asprintf("/chosen/environment-sd%d", environment_path = basprintf("/chosen/environment-sd%d",
bootsource_get_instance() + 1); bootsource_get_instance() + 1);
envdev = "MMC"; envdev = "MMC";
break; break;
case BOOTSOURCE_NAND: case BOOTSOURCE_NAND:
environment_path = asprintf("/chosen/environment-nand"); environment_path = basprintf("/chosen/environment-nand");
envdev = "NAND flash"; envdev = "NAND flash";
break; break;
case BOOTSOURCE_SPI: case BOOTSOURCE_SPI:
environment_path = asprintf("/chosen/environment-spinor"); environment_path = basprintf("/chosen/environment-spinor");
envdev = "SPI NOR flash"; envdev = "SPI NOR flash";
break; break;
default: default:
environment_path = asprintf(default_environment_path); environment_path = basprintf(default_environment_path);
envdev = default_envdev; envdev = default_envdev;
break; break;
} }

View File

@ -201,8 +201,8 @@ static void rpi_get_board_rev(void)
if (!rpi_board_rev) if (!rpi_board_rev)
goto unknown_rev; goto unknown_rev;
name = asprintf("RaspberryPi %s %s", rpi_models[rpi_board_rev].name, name = basprintf("RaspberryPi %s %s",
rpi_model_string); rpi_models[rpi_board_rev].name, rpi_model_string);
barebox_set_model(name); barebox_set_model(name);
free(name); free(name);
@ -210,7 +210,7 @@ static void rpi_get_board_rev(void)
unknown_rev: unknown_rev:
rpi_board_rev = 0; rpi_board_rev = 0;
name = asprintf("RaspberryPi %s", rpi_model_string); name = basprintf("RaspberryPi %s", rpi_model_string);
barebox_set_model(name); barebox_set_model(name);
free(name); free(name);
} }

View File

@ -99,49 +99,49 @@ static void boot_nand_barebox_action(struct menu *m, struct menu_entry *me)
{ {
at91bootstrap_boot_nand(true); at91bootstrap_boot_nand(true);
getc(); getchar();
} }
static void boot_nand_action(struct menu *m, struct menu_entry *me) static void boot_nand_action(struct menu *m, struct menu_entry *me)
{ {
at91bootstrap_boot_nand(false); at91bootstrap_boot_nand(false);
getc(); getchar();
} }
static void boot_m25p80_barebox_action(struct menu *m, struct menu_entry *me) static void boot_m25p80_barebox_action(struct menu *m, struct menu_entry *me)
{ {
at91bootstrap_boot_nand(true); at91bootstrap_boot_nand(true);
getc(); getchar();
} }
static void boot_m25p80_action(struct menu *m, struct menu_entry *me) static void boot_m25p80_action(struct menu *m, struct menu_entry *me)
{ {
at91bootstrap_boot_nand(false); at91bootstrap_boot_nand(false);
getc(); getchar();
} }
static void boot_dataflash_barebox_action(struct menu *m, struct menu_entry *me) static void boot_dataflash_barebox_action(struct menu *m, struct menu_entry *me)
{ {
at91bootstrap_boot_dataflash(true); at91bootstrap_boot_dataflash(true);
getc(); getchar();
} }
static void boot_dataflash_action(struct menu *m, struct menu_entry *me) static void boot_dataflash_action(struct menu *m, struct menu_entry *me)
{ {
at91bootstrap_boot_dataflash(false); at91bootstrap_boot_dataflash(false);
getc(); getchar();
} }
static void boot_mmc_disk_action(struct menu *m, struct menu_entry *me) static void boot_mmc_disk_action(struct menu *m, struct menu_entry *me)
{ {
at91bootstrap_boot_mmc(); at91bootstrap_boot_mmc();
getc(); getchar();
} }
static void boot_reset_action(struct menu *m, struct menu_entry *me) static void boot_reset_action(struct menu *m, struct menu_entry *me)
@ -234,7 +234,7 @@ static int at91_bootstrap(void)
{ {
if (is_menu()) { if (is_menu()) {
printf("press 'm' to start the menu\n"); printf("press 'm' to start the menu\n");
if (tstc() && getc() == 'm') if (tstc() && getchar() == 'm')
at91_bootstrap_menu(); at91_bootstrap_menu();
} }

View File

@ -330,7 +330,7 @@ static void imx_iim_add_mac_param(struct iim_priv *iim, int macnum, int bank, in
iimmac->offset = offset; iimmac->offset = offset;
iimmac->bank = iim->bank[bank]; iimmac->bank = iim->bank[bank];
name = asprintf("ethaddr%d", macnum); name = basprintf("ethaddr%d", macnum);
dev_add_param_mac(&iim->dev, name, imx_iim_set_mac, dev_add_param_mac(&iim->dev, name, imx_iim_set_mac,
imx_iim_get_mac, iimmac->ethaddr, iimmac); imx_iim_get_mac, iimmac->ethaddr, iimmac);

View File

@ -130,7 +130,7 @@ static int omap_env_init(void)
device_detect_by_name(diskdev); device_detect_by_name(diskdev);
partname = asprintf("/dev/%s.0", diskdev); partname = basprintf("/dev/%s.0", diskdev);
mkdir("/boot", 0666); mkdir("/boot", 0666);
ret = mount(partname, "fat", "/boot", NULL); ret = mount(partname, "fat", "/boot", NULL);

View File

@ -115,7 +115,7 @@ static void *omap_xload_boot_mmc(void)
device_detect_by_name(diskdev); device_detect_by_name(diskdev);
partname = asprintf("%s.0", diskdev); partname = basprintf("%s.0", diskdev);
ret = mount(partname, NULL, "/", NULL); ret = mount(partname, NULL, "/", NULL);
@ -280,7 +280,7 @@ static void *am33xx_net_boot(void)
return NULL; return NULL;
} }
file = asprintf("%s/%s", TFTP_MOUNT, bootfile); file = basprintf("%s/%s", TFTP_MOUNT, bootfile);
buf = read_file(file, &len); buf = read_file(file, &len);
if (!buf) if (!buf)

View File

@ -15,6 +15,7 @@
*/ */
#include <common.h> #include <common.h>
#include <crc.h>
#include <i2c/i2c.h> #include <i2c/i2c.h>
#include <mach/immap_85xx.h> #include <mach/immap_85xx.h>
#include <mach/fsl_i2c.h> #include <mach/fsl_i2c.h>

View File

@ -20,6 +20,7 @@
#include <fs.h> #include <fs.h>
#include <errno.h> #include <errno.h>
#include <getopt.h> #include <getopt.h>
#include <libfile.h>
static int do_automount(int argc, char *argv[]) static int do_automount(int argc, char *argv[])
{ {

View File

@ -156,7 +156,7 @@ static int bootscript_scan_path(struct blspec *blspec, const char *path)
return 1; return 1;
} }
files = asprintf("%s/*", path); files = basprintf("%s/*", path);
glob(files, 0, NULL, &globb); glob(files, 0, NULL, &globb);
@ -208,7 +208,7 @@ static int bootentry_parse_one(struct blspec *blspec, const char *name)
char *path; char *path;
if (*name != '/') if (*name != '/')
path = asprintf("/env/boot/%s", name); path = basprintf("/env/boot/%s", name);
else else
path = xstrdup(name); path = xstrdup(name);
@ -233,7 +233,7 @@ static struct blspec *bootentries_collect(char *entries[], int num_entries)
blspec = blspec_alloc(); blspec = blspec_alloc();
if (IS_ENABLED(CONFIG_MENU)) if (IS_ENABLED(CONFIG_MENU))
blspec->menu->display = asprintf("boot"); blspec->menu->display = basprintf("boot");
if (!num_entries) if (!num_entries)
bootscript_scan_path(blspec, "/env/boot"); bootscript_scan_path(blspec, "/env/boot");

View File

@ -97,7 +97,7 @@ static int do_clk_get_rate(int argc, char *argv[])
} }
if (optind == argc) { if (optind == argc) {
fprintf(stderr, "No clock name given\n"); eprintf("No clock name given\n");
return COMMAND_ERROR_USAGE; return COMMAND_ERROR_USAGE;
} }
@ -110,7 +110,7 @@ static int do_clk_get_rate(int argc, char *argv[])
if (variable_name) { if (variable_name) {
char *t; char *t;
t = asprintf("%lu", rate); t = basprintf("%lu", rate);
setenv(variable_name, t); setenv(variable_name, t);
free(t); free(t);
} else } else

View File

@ -20,6 +20,7 @@
#include <common.h> #include <common.h>
#include <command.h> #include <command.h>
#include <fs.h> #include <fs.h>
#include <crc.h>
#include <getopt.h> #include <getopt.h>
#include <malloc.h> #include <malloc.h>
#include <libfile.h> #include <libfile.h>
@ -97,13 +98,13 @@ static int do_crc(int argc, char *argv[])
filename, (ulong)start, (ulong)start + total - 1, crc); filename, (ulong)start, (ulong)start + total - 1, crc);
if (crcvarname) { if (crcvarname) {
char *crcstr = asprintf("0x%lx", crc); char *crcstr = basprintf("0x%lx", crc);
setenv(crcvarname, crcstr); setenv(crcvarname, crcstr);
kfree(crcstr); kfree(crcstr);
} }
if (sizevarname) { if (sizevarname) {
char *sizestr = asprintf("0x%lx", total); char *sizestr = basprintf("0x%lx", total);
setenv(sizevarname, sizestr); setenv(sizevarname, sizestr);
kfree(sizestr); kfree(sizestr);
} }

View File

@ -60,8 +60,8 @@ static int do_defaultenv(int argc, char *argv[])
if (ret) if (ret)
return ret; return ret;
from = asprintf("/.defaultenv/%s", restorepath); from = basprintf("/.defaultenv/%s", restorepath);
to = asprintf("%s/%s", dirname, restorepath); to = basprintf("%s/%s", dirname, restorepath);
printf("Restoring %s from default environment\n", restorepath); printf("Restoring %s from default environment\n", restorepath);

View File

@ -27,7 +27,7 @@
static int do_echo(int argc, char *argv[]) static int do_echo(int argc, char *argv[])
{ {
int i, optind = 1; int i, optind = 1;
int fd = stdout, opt, newline = 1; int fd = STDOUT_FILENO, opt, newline = 1;
char *file = NULL; char *file = NULL;
int oflags = O_WRONLY | O_CREAT; int oflags = O_WRONLY | O_CREAT;
char str[CONFIG_CBSIZE]; char str[CONFIG_CBSIZE];
@ -81,17 +81,17 @@ exit_parse:
for (i = optind; i < argc; i++) { for (i = optind; i < argc; i++) {
if (i > optind) if (i > optind)
fputc(fd, ' '); dputc(fd, ' ');
if (process_escape) { if (process_escape) {
process_escape_sequence(argv[i], str, CONFIG_CBSIZE); process_escape_sequence(argv[i], str, CONFIG_CBSIZE);
fputs(fd, str); dputs(fd, str);
} else { } else {
fputs(fd, argv[i]); dputs(fd, argv[i]);
} }
} }
if (newline) if (newline)
fputc(fd, '\n'); dputc(fd, '\n');
if (file) if (file)
close(fd); close(fd);

View File

@ -367,7 +367,7 @@ static void getwinsize(void)
printf(ESC "7" ESC "[r" ESC "[999;999H" ESC "[6n"); printf(ESC "7" ESC "[r" ESC "[999;999H" ESC "[6n");
while ((r = getc()) != 'R') { while ((r = getchar()) != 'R') {
buf[i] = r; buf[i] = r;
i++; i++;
} }

View File

@ -46,7 +46,7 @@ static int do_hash(char *algo, int argc, char *argv[])
} }
if (key) { if (key) {
char *tmp = asprintf("hmac(%s)", algo); char *tmp = basprintf("hmac(%s)", algo);
d = digest_alloc(tmp); d = digest_alloc(tmp);
free(tmp); free(tmp);
BUG_ON(!d); BUG_ON(!d);

View File

@ -183,8 +183,7 @@ static int os_data_save(void)
ret = write(ofd, write_buffer, ret = write(ofd, write_buffer,
MAX_WRITE_BUFFER); MAX_WRITE_BUFFER);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, eprintf("write to device failed\n");
"write to device failed\n");
return ret; return ret;
} }
write_idx = 0; write_idx = 0;
@ -563,7 +562,7 @@ static ulong load_serial_bin(void)
/* Try to allocate the buffer we shall write to files */ /* Try to allocate the buffer we shall write to files */
write_buffer = malloc(MAX_WRITE_BUFFER); write_buffer = malloc(MAX_WRITE_BUFFER);
if (write_buffer == NULL) { if (write_buffer == NULL) {
fprintf(stderr, "could not allocate file i/o buffer\n"); eprintf("could not allocate file i/o buffer\n");
return -ENOMEM; return -ENOMEM;
} }
@ -585,7 +584,7 @@ static ulong load_serial_bin(void)
if (write_idx > 0) { if (write_idx > 0) {
i = write(ofd, write_buffer, write_idx); i = write(ofd, write_buffer, write_idx);
if (i < 0) { if (i < 0) {
fprintf(stderr, "write to device failed\n"); eprintf("write to device failed\n");
size = i; size = i;
goto err_quit; goto err_quit;
} }

View File

@ -26,6 +26,7 @@
#include <envfs.h> #include <envfs.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <malloc.h> #include <malloc.h>
#include <globalvar.h> #include <globalvar.h>

View File

@ -59,7 +59,7 @@ static int do_load_serial(int argc, char *argv[])
*/ */
for (i=0; i<100; ++i) { for (i=0; i<100; ++i) {
if (tstc()) { if (tstc()) {
(void) getc(); (void) getchar();
} }
udelay(1000); udelay(1000);
} }
@ -142,7 +142,7 @@ static int read_record(char *buf, ulong len)
--len; /* always leave room for terminating '\0' byte */ --len; /* always leave room for terminating '\0' byte */
for (p=buf; p < buf+len; ++p) { for (p=buf; p < buf+len; ++p) {
c = getc(); /* read character */ c = getchar(); /* read character */
if (do_echo) if (do_echo)
putchar(c); putchar(c);
@ -180,7 +180,7 @@ static int do_save_serial(int argc, char *argv[])
printf ("## Ready for S-Record upload, press ENTER to proceed ...\n"); printf ("## Ready for S-Record upload, press ENTER to proceed ...\n");
for (;;) { for (;;) {
if (getc() == '\r') if (getchar() == '\r')
break; break;
} }
if (save_serial(offset, size)) { if (save_serial(offset, size)) {

View File

@ -28,6 +28,7 @@
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <linux/stat.h> #include <linux/stat.h>

View File

@ -41,29 +41,6 @@
char *mem_rw_buf; char *mem_rw_buf;
int open_and_lseek(const char *filename, int mode, loff_t pos)
{
int fd, ret;
fd = open(filename, mode | O_RDONLY);
if (fd < 0) {
perror("open");
return fd;
}
if (!pos)
return fd;
ret = lseek(fd, pos, SEEK_SET);
if (ret == -1) {
perror("lseek");
close(fd);
return -errno;
}
return fd;
}
/* /*
* Common function for parsing options for the 'md', 'mw', 'memcpy', 'memcmp' * Common function for parsing options for the 'md', 'mw', 'memcpy', 'memcmp'
* commands. * commands.

View File

@ -28,6 +28,7 @@
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <linux/stat.h> #include <linux/stat.h>

View File

@ -28,6 +28,7 @@
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <linux/stat.h> #include <linux/stat.h>

View File

@ -28,6 +28,7 @@
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <linux/stat.h> #include <linux/stat.h>

View File

@ -160,8 +160,8 @@ static int do_menu_add(struct cmd_menu *cm)
free: free:
eprintf("Menu '%s' add fail", cm->menu); eprintf("Menu '%s' add fail", cm->menu);
if (ret == -EEXIST) if (ret == -EEXIST)
eputs(" already exist"); eprintf(" already exist");
eputs("\n"); eprintf("\n");
menu_free(m); menu_free(m);

View File

@ -120,7 +120,7 @@ static int show_basic_mii(struct mii_bus *mii, struct phy_device *phydev,
if (mii_val[MII_BMCR] == 0xffff || mii_val[MII_BMSR] == 0x0000) { if (mii_val[MII_BMCR] == 0xffff || mii_val[MII_BMSR] == 0x0000) {
fprintf(stderr, " No MII transceiver present!.\n"); eprintf(" No MII transceiver present!.\n");
return -1; return -1;
} }

View File

@ -22,6 +22,7 @@
#include <fs.h> #include <fs.h>
#include <errno.h> #include <errno.h>
#include <getopt.h> #include <getopt.h>
#include <libfile.h>
static int do_mkdir(int argc, char *argv[]) static int do_mkdir(int argc, char *argv[])
{ {

View File

@ -22,6 +22,7 @@
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <linux/stat.h> #include <linux/stat.h>

View File

@ -153,15 +153,16 @@ static int print_field_ge_v7(u8 *reg, int index)
tmp = get_field_val(DATA_SECTOR_SIZE, 0, 0x1); tmp = get_field_val(DATA_SECTOR_SIZE, 0, 0x1);
if (tmp64 == 0xFFFFFFFF) if (tmp64 == 0xFFFFFFFF)
if (tmp) if (tmp)
str = "16 TB"; str = strdup("16 TB");
else else
str = "2 TB"; str = strdup("2 TB");
else else
if (tmp) if (tmp)
sprintf(str, "%llu B", tmp64 * 4096); str = basprintf("%llu B", tmp64 * 4096);
else else
sprintf(str, "%llu B", tmp64 * 512); str = basprintf("%llu B", tmp64 * 512);
printf("\tMax_Pre_Loading_Data_Size: %s\n", str); printf("\tMax_Pre_Loading_Data_Size: %s\n", str);
free(str);
return 1; return 1;
/* EXT_CSD_PRE_LOADING_DATA_SIZE */ /* EXT_CSD_PRE_LOADING_DATA_SIZE */
@ -181,15 +182,16 @@ static int print_field_ge_v7(u8 *reg, int index)
tmp = get_field_val(DATA_SECTOR_SIZE, 0, 0x1); tmp = get_field_val(DATA_SECTOR_SIZE, 0, 0x1);
if (tmp64 == 0xFFFFFFFF) if (tmp64 == 0xFFFFFFFF)
if (tmp) if (tmp)
str = "16 TB"; str = strdup("16 TB");
else else
str = "2 TB"; str = strdup("2 TB");
else else
if (tmp) if (tmp)
sprintf(str, "%llu B", tmp64 * 4096); str = basprintf("%llu B", tmp64 * 4096);
else else
sprintf(str, "%llu B", tmp64 * 512); str = basprintf("%llu B", tmp64 * 512);
printf("\tPre_Loading_Data_Size: %s\n", str); printf("\tPre_Loading_Data_Size: %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_FFU_STATUS: case EXT_CSD_FFU_STATUS:
@ -319,12 +321,13 @@ static int print_field_ge_v7(u8 *reg, int index)
val = get_field_val(DEVICE_LIFE_TIME_EST_TYP_A, 0, 0xFF); val = get_field_val(DEVICE_LIFE_TIME_EST_TYP_A, 0, 0xFF);
val = val * 10; val = val * 10;
if (val == 0) if (val == 0)
str = "not defined"; str = strdup("not defined");
else if (val == 0xB) else if (val == 0xB)
str = "maximum"; str = strdup("maximum");
else else
sprintf(str, "%u%% - %u%%", (val - 10), val); str = basprintf("%u%% - %u%%", (val - 10), val);
printf("\tDevice life time, type A (estimation): %s\n", str); printf("\tDevice life time, type A (estimation): %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B: case EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B:
@ -332,12 +335,13 @@ static int print_field_ge_v7(u8 *reg, int index)
val = get_field_val(DEVICE_LIFE_TIME_EST_TYP_B, 0, 0xFF); val = get_field_val(DEVICE_LIFE_TIME_EST_TYP_B, 0, 0xFF);
val = val * 10; val = val * 10;
if (val == 0) if (val == 0)
str = "not defined"; str = strdup("not defined");
else if (val == 0xB) else if (val == 0xB)
str = "maximum"; str = strdup("maximum");
else else
sprintf(str, "%u%% - %u%%", (val - 10), val); str = basprintf("%u%% - %u%%", (val - 10), val);
printf("\tDevice life time, type B (estimation): %s\n", str); printf("\tDevice life time, type B (estimation): %s\n", str);
free(str);
return 1; return 1;
/* EXT_CSD_NMBR_OF_FW_SCTRS_CRRCTLY_PRGRMD */ /* EXT_CSD_NMBR_OF_FW_SCTRS_CRRCTLY_PRGRMD */
@ -1687,11 +1691,12 @@ static int print_field(u8 *reg, int index)
val = get_field_val(SLEEP_NOTIFICATION_TIME, 0, 0xFF); val = get_field_val(SLEEP_NOTIFICATION_TIME, 0, 0xFF);
val = 100 << val; val = 100 << val;
if (val) if (val)
sprintf(str, "Sleep Notification timeout values: %u us", str = basprintf("Sleep Notification timeout values: %u us",
val); val);
else else
str = "Not defined"; str = strdup("Not defined");
printf("\t[7-0] %s\n", str); printf("\t[7-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_S_A_TIMEOUT: case EXT_CSD_S_A_TIMEOUT:
@ -1699,10 +1704,11 @@ static int print_field(u8 *reg, int index)
val = get_field_val(S_A_TIMEOUT, 0, 0xFF); val = get_field_val(S_A_TIMEOUT, 0, 0xFF);
val = 100 << val; val = 100 << val;
if (val) if (val)
sprintf(str, "Sleep/awake timeout values: %u ns", val); str = basprintf("Sleep/awake timeout values: %u ns", val);
else else
str = "Not defined"; str = strdup("Not defined");
printf("\t[7-0] %s\n", str); printf("\t[7-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_PRODUCTION_ST8_AWARENSS_TIMEOUT: case EXT_CSD_PRODUCTION_ST8_AWARENSS_TIMEOUT:
@ -1710,12 +1716,13 @@ static int print_field(u8 *reg, int index)
val = get_field_val(PRODUCTION_ST8_AWARENSS_TIMEOUT, 0, 0xFF); val = get_field_val(PRODUCTION_ST8_AWARENSS_TIMEOUT, 0, 0xFF);
val = 100 << val; val = 100 << val;
if (val) if (val)
sprintf(str, str = basprintf(
"Production State Awareness timeout definition: %u us", "Production State Awareness timeout definition: %u us",
val); val);
else else
str = "Not defined"; str = strdup("Not defined");
printf("\t[7-0] %s\n", str); printf("\t[7-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_S_C_VCCQ: case EXT_CSD_S_C_VCCQ:
@ -1723,10 +1730,11 @@ static int print_field(u8 *reg, int index)
val = get_field_val(S_C_VCCQ, 0, 0xF); val = get_field_val(S_C_VCCQ, 0, 0xF);
val = 1 << val; val = 1 << val;
if (val) if (val)
sprintf(str, "S_C_VCCQ Sleep Current: %u uA", val); str = basprintf("S_C_VCCQ Sleep Current: %u uA", val);
else else
str = "Not defined"; str = strdup("Not defined");
printf("\t[3-0] %s\n", str); printf("\t[3-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_S_C_VCC: case EXT_CSD_S_C_VCC:
@ -1734,20 +1742,22 @@ static int print_field(u8 *reg, int index)
val = get_field_val(S_C_VCC, 0, 0xFF); val = get_field_val(S_C_VCC, 0, 0xFF);
val = 1 << val; val = 1 << val;
if (val) if (val)
sprintf(str, "S_C_VCC Sleep Current: %u uA", val); str = basprintf("S_C_VCC Sleep Current: %u uA", val);
else else
str = "Not defined"; str = strdup("Not defined");
printf("\t[3-0] %s\n", str); printf("\t[3-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_HC_WP_GRP_SIZE: case EXT_CSD_HC_WP_GRP_SIZE:
print_field_caption(HC_WP_GRP_SIZE, R); print_field_caption(HC_WP_GRP_SIZE, R);
val = get_field_val(HC_WP_GRP_SIZE, 0, 0xFF); val = get_field_val(HC_WP_GRP_SIZE, 0, 0xFF);
if (val) if (val)
sprintf(str, "Write protect group size: %u", val); str = basprintf("Write protect group size: %u", val);
else else
str = "No support"; str = strdup("No support");
printf("\t[7-0] %s\n", str); printf("\t[7-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_REL_WR_SEC_C: case EXT_CSD_REL_WR_SEC_C:
@ -1761,10 +1771,11 @@ static int print_field(u8 *reg, int index)
val = get_field_val(ERASE_TIMEOUT_MULT, 0, 0xFF); val = get_field_val(ERASE_TIMEOUT_MULT, 0, 0xFF);
val = val * 300; val = val * 300;
if (val) if (val)
sprintf(str, "Erase timeout values: %u", val); str = basprintf("Erase timeout values: %u", val);
else else
str = "No support"; str = strdup("No support");
printf("\t[7-0] %s\n", str); printf("\t[7-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_HC_ERASE_GRP_SIZE: case EXT_CSD_HC_ERASE_GRP_SIZE:
@ -1772,10 +1783,11 @@ static int print_field(u8 *reg, int index)
val = get_field_val(HC_ERASE_GRP_SIZE, 0, 0xFF); val = get_field_val(HC_ERASE_GRP_SIZE, 0, 0xFF);
val = val * 524288; val = val * 524288;
if (val) if (val)
sprintf(str, "Erase-unit size: %u", val); str = basprintf("Erase-unit size: %u", val);
else else
str = "No support"; str = strdup("No support");
printf("\t[7-0] %s\n", str); printf("\t[7-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_ACC_SIZE: case EXT_CSD_ACC_SIZE:
@ -1783,10 +1795,11 @@ static int print_field(u8 *reg, int index)
val = get_field_val(ACC_SIZE, 0, 0xF); val = get_field_val(ACC_SIZE, 0, 0xF);
val = val * 512; val = val * 512;
if (val) if (val)
sprintf(str, "Superpage size: %u", val); str = basprintf("Superpage size: %u", val);
else else
str = "Not defined"; str = strdup("Not defined");
printf("\t[3-0] %s\n", str); printf("\t[3-0] %s\n", str);
free(str);
return 1; return 1;
case EXT_CSD_BOOT_SIZE_MULT: case EXT_CSD_BOOT_SIZE_MULT:
@ -1867,14 +1880,14 @@ static int request_write_operation(void)
int c; int c;
printf("This is a one time programmable field!\nDo you want to write? [y/N] "); printf("This is a one time programmable field!\nDo you want to write? [y/N] ");
c = getc(); c = getchar();
/* default is N */ /* default is N */
if (c == 0xD) { if (c == 0xD) {
printf("\n"); printf("\n");
return 0; return 0;
} }
printf("%c", c); printf("%c", c);
getc(); /* wait for carriage return */ getchar(); /* wait for carriage return */
printf("\n"); printf("\n");
if (c == 'y' || c == 'Y') if (c == 'y' || c == 'Y')
return 1; return 1;

View File

@ -28,6 +28,7 @@
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
#include <linux/stat.h> #include <linux/stat.h>

View File

@ -19,6 +19,7 @@
#include <common.h> #include <common.h>
#include <command.h> #include <command.h>
#include <fs.h> #include <fs.h>
#include <libfile.h>
#include <getopt.h> #include <getopt.h>
#include <errno.h> #include <errno.h>

View File

@ -58,10 +58,10 @@ static int do_tftpb(int argc, char *argv[])
dest = argv[optind]; dest = argv[optind];
if (tftp_push) { if (tftp_push) {
dest = freep = asprintf("%s/%s", TFTP_MOUNT_PATH, dest); dest = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, dest);
flags = O_RDONLY; flags = O_RDONLY;
} else { } else {
source = freep = asprintf("%s/%s", TFTP_MOUNT_PATH, source); source = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, source);
flags = O_WRONLY | O_CREAT; flags = O_WRONLY | O_CREAT;
} }

View File

@ -203,16 +203,18 @@ static char *parse_nfs_url(const char *url)
if (ip == 0) if (ip == 0)
goto out; goto out;
hostpath = asprintf("%s:%s", ip_to_string(ip), path); hostpath = basprintf("%s:%s", ip_to_string(ip), path);
prevpath = nfs_find_mountpath(hostpath); prevpath = nfs_find_mountpath(hostpath);
if (prevpath) { if (prevpath) {
mountpath = xstrdup(prevpath); mountpath = xstrdup(prevpath);
} else { } else {
mountpath = asprintf("/mnt/nfs-%s-blspec-%08x", host, rand()); mountpath = basprintf("/mnt/nfs-%s-blspec-%08x", host,
rand());
if (port) if (port)
options = asprintf("mountport=%s,port=%s", port, port); options = basprintf("mountport=%s,port=%s", port,
port);
ret = make_directory(mountpath); ret = make_directory(mountpath);
if (ret) if (ret)
@ -278,7 +280,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
if (!strcmp(devicetree, "none")) if (!strcmp(devicetree, "none"))
return true; return true;
filename = asprintf("%s/%s", abspath, devicetree); filename = basprintf("%s/%s", abspath, devicetree);
fdt = read_file(filename, &size); fdt = read_file(filename, &size);
if (!fdt) { if (!fdt) {
@ -338,7 +340,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
entry_default = read_file_line("%s/default", root); entry_default = read_file_line("%s/default", root);
entry_once = read_file_line("%s/once", root); entry_once = read_file_line("%s/once", root);
abspath = asprintf("%s/%s", root, dirname); abspath = basprintf("%s/%s", root, dirname);
dir = opendir(abspath); dir = opendir(abspath);
if (!dir) { if (!dir) {
@ -356,7 +358,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
if (*d->d_name == '.') if (*d->d_name == '.')
continue; continue;
configname = asprintf("%s/%s", abspath, d->d_name); configname = basprintf("%s/%s", abspath, d->d_name);
dot = strrchr(configname, '.'); dot = strrchr(configname, '.');
if (!dot) { if (!dot) {
@ -402,7 +404,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
found++; found++;
name = asprintf("%s/%s", dirname, d->d_name); name = basprintf("%s/%s", dirname, d->d_name);
if (entry_default && !strcmp(name, entry_default)) if (entry_default && !strcmp(name, entry_default))
entry->boot_default = true; entry->boot_default = true;
if (entry_once && !strcmp(name, entry_once)) if (entry_once && !strcmp(name, entry_once))
@ -415,10 +417,10 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
hwdevname = xstrdup(dev_name(entry->cdev->dev->parent)); hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
} }
entry->me.display = asprintf("%-20s %-20s %s", entry->me.display = basprintf("%-20s %-20s %s",
devname ? devname : "", devname ? devname : "",
hwdevname ? hwdevname : "", hwdevname ? hwdevname : "",
blspec_entry_var_get(entry, "title")); blspec_entry_var_get(entry, "title"));
free(devname); free(devname);
free(hwdevname); free(hwdevname);
@ -669,7 +671,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
else else
abspath = ""; abspath = "";
data.os_file = asprintf("%s/%s", abspath, linuximage); data.os_file = basprintf("%s/%s", abspath, linuximage);
if (devicetree) { if (devicetree) {
if (!strcmp(devicetree, "none")) { if (!strcmp(devicetree, "none")) {
@ -677,13 +679,13 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
if (node) if (node)
of_delete_node(node); of_delete_node(node);
} else { } else {
data.oftree_file = asprintf("%s/%s", abspath, data.oftree_file = basprintf("%s/%s", abspath,
devicetree); devicetree);
} }
} }
if (initrd) if (initrd)
data.initrd_file = asprintf("%s/%s", abspath, initrd); data.initrd_file = basprintf("%s/%s", abspath, initrd);
globalvar_add_simple("linux.bootargs.dyn.blspec", options); globalvar_add_simple("linux.bootargs.dyn.blspec", options);
@ -704,7 +706,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
entry->cdev ? dev_name(entry->cdev->dev) : "none"); entry->cdev ? dev_name(entry->cdev->dev) : "none");
if (entry->boot_once) { if (entry->boot_once) {
char *s = asprintf("%s/once", abspath); char *s = basprintf("%s/once", abspath);
ret = unlink(s); ret = unlink(s);
if (ret) if (ret)

View File

@ -53,7 +53,8 @@ const char *linux_bootargs_get(void)
parts = globalvar_get_match("linux.mtdparts.", ";"); parts = globalvar_get_match("linux.mtdparts.", ";");
if (strlen(parts)) { if (strlen(parts)) {
bootargs = asprintf("%s mtdparts=%s", linux_bootargs, parts); bootargs = basprintf("%s mtdparts=%s", linux_bootargs,
parts);
free(linux_bootargs); free(linux_bootargs);
free(parts); free(parts);
linux_bootargs = bootargs; linux_bootargs = bootargs;
@ -61,7 +62,8 @@ const char *linux_bootargs_get(void)
parts = globalvar_get_match("linux.blkdevparts.", ";"); parts = globalvar_get_match("linux.blkdevparts.", ";");
if (strlen(parts)) { if (strlen(parts)) {
bootargs = asprintf("%s blkdevparts=%s", linux_bootargs, parts); bootargs = basprintf("%s blkdevparts=%s", linux_bootargs,
parts);
free(linux_bootargs); free(linux_bootargs);
free(parts); free(parts);
linux_bootargs = bootargs; linux_bootargs = bootargs;

View File

@ -164,7 +164,7 @@ int console_set_baudrate(struct console_device *cdev, unsigned baudrate)
if (cdev->f_active) { if (cdev->f_active) {
mdelay(50); mdelay(50);
do { do {
c = getc(); c = getchar();
} while (c != '\r' && c != '\n'); } while (c != '\r' && c != '\n');
} }
@ -208,8 +208,8 @@ static void console_set_stdoutpath(struct console_device *cdev)
if (id < 0) if (id < 0)
return; return;
str = asprintf("console=%s%d,%dn8", cdev->linux_console_name, str = basprintf("console=%s%d,%dn8", cdev->linux_console_name, id,
id, cdev->baudrate); cdev->baudrate);
globalvar_add_simple("linux.bootargs.console", str); globalvar_add_simple("linux.bootargs.console", str);
@ -345,7 +345,7 @@ static int tstc_raw(void)
return 0; return 0;
} }
int getc(void) int getchar(void)
{ {
unsigned char ch; unsigned char ch;
uint64_t start; uint64_t start;
@ -380,17 +380,7 @@ int getc(void)
return ch; return ch;
} }
EXPORT_SYMBOL(getc); EXPORT_SYMBOL(getchar);
int fgetc(int fd)
{
char c;
if (!fd)
return getc();
return read(fd, &c, 1);
}
EXPORT_SYMBOL(fgetc);
int tstc(void) int tstc(void)
{ {
@ -476,7 +466,7 @@ int ctrlc (void)
{ {
poller_call(); poller_call();
if (tstc() && getc() == 3) if (tstc() && getchar() == 3)
return 1; return 1;
return 0; return 0;
} }

View File

@ -278,7 +278,7 @@ EXPORT_SYMBOL(console_get_first_active);
#endif /* !CONFIG_CONSOLE_NONE */ #endif /* !CONFIG_CONSOLE_NONE */
int fprintf(int file, const char *fmt, ...) int dprintf(int file, const char *fmt, ...)
{ {
va_list args; va_list args;
char printbuffer[CFG_PBSIZE]; char printbuffer[CFG_PBSIZE];
@ -293,30 +293,30 @@ int fprintf(int file, const char *fmt, ...)
va_end(args); va_end(args);
/* Print the string */ /* Print the string */
return fputs(file, printbuffer); return dputs(file, printbuffer);
} }
EXPORT_SYMBOL(fprintf); EXPORT_SYMBOL(dprintf);
int fputs(int fd, const char *s) int dputs(int fd, const char *s)
{ {
if (fd == 1) if (fd == 1)
return puts(s); return puts(s);
else if (fd == 2) else if (fd == 2)
return eputs(s); return console_puts(CONSOLE_STDERR, s);
else else
return write(fd, s, strlen(s)); return write(fd, s, strlen(s));
} }
EXPORT_SYMBOL(fputs); EXPORT_SYMBOL(dputs);
int fputc(int fd, char c) int dputc(int fd, char c)
{ {
if (fd == 1) if (fd == 1)
putchar(c); putchar(c);
else if (fd == 2) else if (fd == 2)
eputc(c); console_putc(CONSOLE_STDERR, c);
else else
return write(fd, &c, 1); return write(fd, &c, 1);
return 0; return 0;
} }
EXPORT_SYMBOL(fputc); EXPORT_SYMBOL(dputc);

View File

@ -39,7 +39,7 @@ int console_countdown(int timeout_s, unsigned flags, char *out_key)
do { do {
if (tstc()) { if (tstc()) {
key = getc(); key = getchar();
if (flags & CONSOLE_COUNTDOWN_ANYKEY) if (flags & CONSOLE_COUNTDOWN_ANYKEY)
goto out; goto out;
if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n') if (flags & CONSOLE_COUNTDOWN_RETURN && key == '\n')

View File

@ -48,13 +48,13 @@ int tstc(void)
} }
EXPORT_SYMBOL(tstc); EXPORT_SYMBOL(tstc);
int getc(void) int getchar(void)
{ {
if (!console) if (!console)
return -EINVAL; return -EINVAL;
return console->getc(console); return console->getc(console);
} }
EXPORT_SYMBOL(getc); EXPORT_SYMBOL(getchar);
void console_flush(void) void console_flush(void)
{ {
@ -67,7 +67,7 @@ EXPORT_SYMBOL(console_flush);
/* test if ctrl-c was pressed */ /* test if ctrl-c was pressed */
int ctrlc (void) int ctrlc (void)
{ {
if (tstc() && getc() == 3) if (tstc() && getchar() == 3)
return 1; return 1;
return 0; return 0;
} }

View File

@ -261,7 +261,7 @@ EXPORT_SYMBOL(export);
void export_env_ull(const char *name, unsigned long long val) void export_env_ull(const char *name, unsigned long long val)
{ {
char *valstr = asprintf("%llu", val); char *valstr = basprintf("%llu", val);
setenv(name, valstr); setenv(name, valstr);
export(name); export(name);

View File

@ -29,6 +29,7 @@
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <fs.h> #include <fs.h>
#include <crc.h>
#include <fcntl.h> #include <fcntl.h>
#include <envfs.h> #include <envfs.h>
#include <xfuncs.h> #include <xfuncs.h>
@ -79,7 +80,7 @@ static int do_compare_file(const char *filename, const char *base)
char *cmp; char *cmp;
const char *relname = filename + strlen(base) + 1; const char *relname = filename + strlen(base) + 1;
cmp = asprintf("%s/%s", TMPDIR, relname); cmp = basprintf("%s/%s", TMPDIR, relname);
ret = compare_file(cmp, filename); ret = compare_file(cmp, filename);
free(cmp); free(cmp);
@ -193,7 +194,7 @@ static int file_remove_action(const char *filename, struct stat *statbuf,
filename += sizeof(TMPDIR) - 1; filename += sizeof(TMPDIR) - 1;
envname = asprintf("%s/%s", data->base, filename); envname = basprintf("%s/%s", data->base, filename);
ret = stat(envname, &s); ret = stat(envname, &s);
if (ret) { if (ret) {

View File

@ -202,7 +202,7 @@ out:
int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *firmware) int firmwaremgr_load_file(struct firmware_mgr *mgr, const char *firmware)
{ {
int ret; int ret;
char *name = asprintf("/dev/%s", mgr->handler->id); char *name = basprintf("/dev/%s", mgr->handler->id);
ret = copy_file(firmware, name, 0); ret = copy_file(firmware, name, 0);

View File

@ -52,7 +52,7 @@ static int nv_save(const char *name, const char *val)
if (ret) if (ret)
return ret; return ret;
fname = asprintf("/env/nv/%s", name); fname = basprintf("/env/nv/%s", name);
fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC); fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC);
@ -61,7 +61,7 @@ static int nv_save(const char *name, const char *val)
if (fd < 0) if (fd < 0)
return fd; return fd;
fprintf(fd, "%s", val); dprintf(fd, "%s", val);
close(fd); close(fd);
@ -145,7 +145,7 @@ int nvvar_remove(const char *name)
if (!p) if (!p)
return -ENOENT; return -ENOENT;
fname = asprintf("/env/nv/%s", p->name); fname = basprintf("/env/nv/%s", p->name);
unlink(fname); unlink(fname);
free(fname); free(fname);
@ -227,7 +227,8 @@ char *globalvar_get_match(const char *match, const char *separator)
if (!strncmp(match, param->name, strlen(match))) { if (!strncmp(match, param->name, strlen(match))) {
const char *p = dev_get_param(&global_device, param->name); const char *p = dev_get_param(&global_device, param->name);
if (val) { if (val) {
char *new = asprintf("%s%s%s", val, separator, p); char *new = basprintf("%s%s%s", val,
separator, p);
free(val); free(val);
val = new; val = new;
} else { } else {

View File

@ -306,7 +306,7 @@ int imd_command(int argc, char *argv[])
case 't': case 't':
type = imd_name_to_type(optarg); type = imd_name_to_type(optarg);
if (type == IMD_TYPE_INVALID) { if (type == IMD_TYPE_INVALID) {
fprintf(stderr, "no such type: %s\n", optarg); eprintf("no such type: %s\n", optarg);
return -ENOSYS; return -ENOSYS;
} }
break; break;
@ -325,7 +325,7 @@ int imd_command(int argc, char *argv[])
} }
if (optind == argc) { if (optind == argc) {
fprintf(stderr, "No image given\n"); eprintf("No image given\n");
return -ENOSYS; return -ENOSYS;
} }

View File

@ -34,6 +34,7 @@
#include <linux/mtd/nand.h> #include <linux/mtd/nand.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <io.h> #include <io.h>
#include <crc.h>
#include <mach/generic.h> #include <mach/generic.h>
#include <mtd/mtd-peb.h> #include <mtd/mtd-peb.h>

View File

@ -12,9 +12,11 @@
#include <environment.h> #include <environment.h>
#include <libbb.h> #include <libbb.h>
#include <common.h> #include <common.h>
#include <command.h>
#include <glob.h> #include <glob.h>
#include <menu.h> #include <menu.h>
#include <fs.h> #include <fs.h>
#include <shell.h>
#include <libfile.h> #include <libfile.h>
#include <linux/stat.h> #include <linux/stat.h>
@ -96,7 +98,7 @@ int menutree(const char *path, int toplevel)
menu = menu_alloc(); menu = menu_alloc();
globpath = asprintf("%s/*", path); globpath = basprintf("%s/*", path);
ret = glob(globpath, 0, NULL, &g); ret = glob(globpath, 0, NULL, &g);
free(globpath); free(globpath);
if (ret == GLOB_NOMATCH) { if (ret == GLOB_NOMATCH) {
@ -147,7 +149,7 @@ int menutree(const char *path, int toplevel)
mt->me.type = MENU_ENTRY_NORMAL; mt->me.type = MENU_ENTRY_NORMAL;
mt->action = asprintf("%s/action", g.gl_pathv[i]); mt->action = basprintf("%s/action", g.gl_pathv[i]);
ret = stat(mt->action, &s); ret = stat(mt->action, &s);
if (ret) { if (ret) {

View File

@ -51,7 +51,7 @@ static int register_one_partition(struct block_device *blk,
uint64_t size = part->size * SECTOR_SIZE; uint64_t size = part->size * SECTOR_SIZE;
struct cdev *cdev; struct cdev *cdev;
partition_name = asprintf("%s.%d", blk->cdev.name, no); partition_name = basprintf("%s.%d", blk->cdev.name, no);
if (!partition_name) if (!partition_name)
return -ENOMEM; return -ENOMEM;
dev_dbg(blk->dev, "Registering partition %s on drive %s\n", dev_dbg(blk->dev, "Registering partition %s on drive %s\n",

View File

@ -17,6 +17,7 @@
#include <init.h> #include <init.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
#include <dma.h> #include <dma.h>
#include <crc.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include "efi.h" #include "efi.h"

View File

@ -24,6 +24,7 @@
#include <digest.h> #include <digest.h>
#include <malloc.h> #include <malloc.h>
#include <xfuncs.h> #include <xfuncs.h>
#include <command.h>
#include <magicvar.h> #include <magicvar.h>
#include <clock.h> #include <clock.h>
#include <init.h> #include <init.h>
@ -62,7 +63,7 @@ int password(unsigned char *passwd, size_t length, int flags, int timeout)
do { do {
if (tstc()) { if (tstc()) {
ch = getc(); ch = getchar();
switch (ch) { switch (ch) {
case '\r': case '\r':

View File

@ -30,6 +30,7 @@
* @brief Main entry into the C part of barebox * @brief Main entry into the C part of barebox
*/ */
#include <common.h> #include <common.h>
#include <shell.h>
#include <init.h> #include <init.h>
#include <command.h> #include <command.h>
#include <malloc.h> #include <malloc.h>

View File

@ -20,6 +20,7 @@
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <fs.h> #include <fs.h>
#include <crc.h>
#include <init.h> #include <init.h>
#include <ioctl.h> #include <ioctl.h>
#include <libbb.h> #include <libbb.h>
@ -703,8 +704,8 @@ static int state_convert_node_variable(struct state *state,
*indexs = 0; *indexs = 0;
/* construct full name */ /* construct full name */
name = asprintf("%s%s%s", name = basprintf("%s%s%s", parent_name, parent_name[0] ? "." : "",
parent_name, parent_name[0] ? "." : "", short_name); short_name);
free(short_name); free(short_name);
if ((conv == STATE_CONVERT_TO_NODE) || if ((conv == STATE_CONVERT_TO_NODE) ||

View File

@ -21,6 +21,7 @@
#include <image.h> #include <image.h>
#include <malloc.h> #include <malloc.h>
#include <errno.h> #include <errno.h>
#include <crc.h>
#include <libbb.h> #include <libbb.h>
#include <libfile.h> #include <libfile.h>
#include <uncompress.h> #include <uncompress.h>

View File

@ -12,6 +12,7 @@
#include <common.h> #include <common.h>
#include <xfuncs.h> #include <xfuncs.h>
#include <fs.h> #include <fs.h>
#include <crc.h>
#include <fcntl.h> #include <fcntl.h>
#include <malloc.h> #include <malloc.h>
#include <linux/ctype.h> #include <linux/ctype.h>

View File

@ -173,8 +173,8 @@ static int digest_hmac_register(char *name, unsigned int pad_length)
dh->name = xstrdup(name); dh->name = xstrdup(name);
dh->pad_length = pad_length; dh->pad_length = pad_length;
dh->algo = hmac_algo; dh->algo = hmac_algo;
dh->algo.base.name = asprintf("hmac(%s)", name); dh->algo.base.name = basprintf("hmac(%s)", name);
dh->algo.base.driver_name = asprintf("hmac(%s)-generic", name); dh->algo.base.driver_name = basprintf("hmac(%s)-generic", name);
return digest_algo_register(&dh->algo); return digest_algo_register(&dh->algo);
} }

View File

@ -243,7 +243,7 @@ static int ata_port_init(struct ata_port *port)
rc = cdev_find_free_index("ata"); rc = cdev_find_free_index("ata");
if (rc == -1) if (rc == -1)
pr_err("Cannot find a free index for the disk node\n"); pr_err("Cannot find a free index for the disk node\n");
port->blk.cdev.name = asprintf("ata%d", rc); port->blk.cdev.name = basprintf("ata%d", rc);
} }
port->blk.num_blocks = ata_id_n_sectors(port->id); port->blk.num_blocks = ata_id_n_sectors(port->id);

View File

@ -258,7 +258,7 @@ static int biosdisk_probe(struct device_d *dev)
rc = cdev_find_free_index("disk"); rc = cdev_find_free_index("disk");
if (rc < 0) if (rc < 0)
pr_err("Cannot find a free number for the disk node\n"); pr_err("Cannot find a free number for the disk node\n");
m->blk.cdev.name = asprintf("disk%d", rc); m->blk.cdev.name = basprintf("disk%d", rc);
m->blk.blockbits = SECTOR_SHIFT; m->blk.blockbits = SECTOR_SHIFT;
rc = blockdevice_register(&m->blk); rc = blockdevice_register(&m->blk);

View File

@ -429,7 +429,7 @@ static int at24_probe(struct device_d *dev)
at24->chip = chip; at24->chip = chip;
at24->num_addresses = num_addresses; at24->num_addresses = num_addresses;
at24->cdev.name = asprintf("eeprom%d", dev->id); at24->cdev.name = basprintf("eeprom%d", dev->id);
at24->cdev.priv = at24; at24->cdev.priv = at24;
at24->cdev.dev = dev; at24->cdev.dev = dev;
at24->cdev.ops = &at24->fops; at24->cdev.ops = &at24->fops;

View File

@ -506,8 +506,8 @@ static int mmc_change_freq(struct mci *mci)
char *name, *partname; char *name, *partname;
part_size = mci->ext_csd[EXT_CSD_BOOT_MULT] << 17; part_size = mci->ext_csd[EXT_CSD_BOOT_MULT] << 17;
partname = asprintf("boot%d", idx); partname = basprintf("boot%d", idx);
name = asprintf("%s.%s", mci->cdevname, partname); name = basprintf("%s.%s", mci->cdevname, partname);
mci_part_add(mci, part_size, mci_part_add(mci, part_size,
EXT_CSD_PART_CONFIG_ACC_BOOT0 + idx, EXT_CSD_PART_CONFIG_ACC_BOOT0 + idx,
name, partname, idx, true, name, partname, idx, true,
@ -1626,7 +1626,7 @@ static int mci_card_probe(struct mci *mci)
mci->cdevname = strdup(host->devname); mci->cdevname = strdup(host->devname);
} else { } else {
disknum = cdev_find_free_index("disk"); disknum = cdev_find_free_index("disk");
mci->cdevname = asprintf("disk%d", disknum); mci->cdevname = basprintf("disk%d", disknum);
} }
rc = mci_startup(mci); rc = mci_startup(mci);

View File

@ -141,8 +141,8 @@ static int stmpe_probe(struct device_d *dev)
} }
stmpe_dev = xzalloc(sizeof(struct stmpe)); stmpe_dev = xzalloc(sizeof(struct stmpe));
stmpe_dev->cdev.name = asprintf(DRIVERNAME "%d", stmpe_dev->cdev.name = basprintf(DRIVERNAME"%d",
cdev_find_free_index(DRIVERNAME)); cdev_find_free_index(DRIVERNAME));
stmpe_dev->client = to_i2c_client(dev); stmpe_dev->client = to_i2c_client(dev);
stmpe_dev->cdev.size = 191; /* 191 known registers */ stmpe_dev->cdev.size = 191; /* 191 known registers */
stmpe_dev->cdev.dev = dev; stmpe_dev->cdev.dev = dev;

View File

@ -47,8 +47,7 @@ static int sram_probe(struct device_d *dev)
sram = xzalloc(sizeof(*sram)); sram = xzalloc(sizeof(*sram));
sram->cdev.name = asprintf("sram%d", sram->cdev.name = basprintf("sram%d", cdev_find_free_index("sram"));
cdev_find_free_index("sram"));
res = dev_get_resource(dev, IORESOURCE_MEM, 0); res = dev_get_resource(dev, IORESOURCE_MEM, 0);
if (IS_ERR(res)) if (IS_ERR(res))

View File

@ -470,10 +470,10 @@ static int mtd_partition_set(struct device_d *dev, struct param_d *p, const char
static char *print_size(uint64_t s) static char *print_size(uint64_t s)
{ {
if (!(s & ((1 << 20) - 1))) if (!(s & ((1 << 20) - 1)))
return asprintf("%lldM", s >> 20); return basprintf("%lldM", s >> 20);
if (!(s & ((1 << 10) - 1))) if (!(s & ((1 << 10) - 1)))
return asprintf("%lldk", s >> 10); return basprintf("%lldk", s >> 10);
return asprintf("0x%lld", s); return basprintf("0x%lld", s);
} }
static int print_part(char *buf, int bufsize, struct mtd_info *mtd, uint64_t last_ofs, static int print_part(char *buf, int bufsize, struct mtd_info *mtd, uint64_t last_ofs,
@ -577,7 +577,8 @@ static int of_mtd_fixup(struct device_node *root, void *ctx)
list_for_each_entry(partmtd, &mtd->partitions, partitions_entry) { list_for_each_entry(partmtd, &mtd->partitions, partitions_entry) {
int na, ns, len = 0; int na, ns, len = 0;
char *name = asprintf("partition@%0llx", partmtd->master_offset); char *name = basprintf("partition@%0llx",
partmtd->master_offset);
void *p; void *p;
u8 tmp[16 * 16]; /* Up to 64-bit address + 64-bit size */ u8 tmp[16 * 16]; /* Up to 64-bit address + 64-bit size */
@ -675,7 +676,8 @@ int add_mtd_device(struct mtd_info *mtd, const char *devname, int device_id)
if (device_id == DEVICE_ID_SINGLE) if (device_id == DEVICE_ID_SINGLE)
mtd->cdev.name = xstrdup(devname); mtd->cdev.name = xstrdup(devname);
else else
mtd->cdev.name = asprintf("%s%d", devname, mtd->class_dev.id); mtd->cdev.name = basprintf("%s%d", devname,
mtd->class_dev.id);
INIT_LIST_HEAD(&mtd->partitions); INIT_LIST_HEAD(&mtd->partitions);

View File

@ -1058,8 +1058,8 @@ static void __init doc_set_driver_info(int chip_id, struct mtd_info *mtd)
switch (chip_id) { switch (chip_id) {
case DOC_CHIPID_G3: case DOC_CHIPID_G3:
mtd->name = asprintf("DiskOnChip G3 floor %d", mtd->name = basprintf("DiskOnChip G3 floor %d",
docg3->device_id); docg3->device_id);
docg3->max_block = 2047; docg3->max_block = 2047;
break; break;
} }

View File

@ -79,7 +79,7 @@ static int add_mtdoob_device(struct mtd_info *mtd, const char *devname, void **p
mtdoob = xzalloc(sizeof(*mtdoob)); mtdoob = xzalloc(sizeof(*mtdoob));
mtdoob->cdev.ops = &mtd_ops_oob; mtdoob->cdev.ops = &mtd_ops_oob;
mtdoob->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtd->oobsize; mtdoob->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtd->oobsize;
mtdoob->cdev.name = asprintf("%s.oob", mtd->cdev.name); mtdoob->cdev.name = basprintf("%s.oob", mtd->cdev.name);
mtdoob->cdev.priv = mtdoob; mtdoob->cdev.priv = mtdoob;
mtdoob->cdev.dev = &mtd->class_dev; mtdoob->cdev.dev = &mtd->class_dev;
mtdoob->mtd = mtd; mtdoob->mtd = mtd;

View File

@ -308,7 +308,7 @@ static int add_mtdraw_device(struct mtd_info *mtd, const char *devname, void **p
mtdraw->cdev.ops = (struct file_operations *)&mtd_raw_fops; mtdraw->cdev.ops = (struct file_operations *)&mtd_raw_fops;
mtdraw->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtdraw->cdev.size = mtd_div_by_wb(mtd->size, mtd) *
(mtd->writesize + mtd->oobsize); (mtd->writesize + mtd->oobsize);
mtdraw->cdev.name = asprintf("%s.raw", mtd->cdev.name); mtdraw->cdev.name = basprintf("%s.raw", mtd->cdev.name);
mtdraw->cdev.priv = mtdraw; mtdraw->cdev.priv = mtdraw;
mtdraw->cdev.dev = &mtd->class_dev; mtdraw->cdev.dev = &mtd->class_dev;
mtdraw->cdev.mtd = mtd; mtdraw->cdev.mtd = mtd;

View File

@ -288,7 +288,7 @@ struct cdev *mtd_add_bb(struct mtd_info *mtd, const char *name)
if (name) if (name)
bb->cdev.name = xstrdup(name); bb->cdev.name = xstrdup(name);
else else
bb->cdev.name = asprintf("%s.bb", mtd->cdev.name); bb->cdev.name = basprintf("%s.bb", mtd->cdev.name);
nand_bb_calc_size(bb); nand_bb_calc_size(bb);
bb->cdev.ops = &nand_bb_ops; bb->cdev.ops = &nand_bb_ops;

View File

@ -188,7 +188,7 @@ static int do_imx_nand_bbm(int argc, char *argv[])
int c; int c;
printf("create flash bbt (y/n)?"); printf("create flash bbt (y/n)?");
c = getc(); c = getchar();
if (c == 'y') if (c == 'y')
yes = 1; yes = 1;
printf("\n"); printf("\n");

View File

@ -176,7 +176,7 @@ int ubi_volume_cdev_add(struct ubi_device *ubi, struct ubi_volume *vol)
priv->ubi = ubi; priv->ubi = ubi;
cdev->ops = &ubi_volume_fops; cdev->ops = &ubi_volume_fops;
cdev->name = asprintf("%s.%s", ubi->cdev.name, vol->name); cdev->name = basprintf("%s.%s", ubi->cdev.name, vol->name);
cdev->priv = priv; cdev->priv = priv;
cdev->size = vol->used_bytes; cdev->size = vol->used_bytes;
cdev->dev = &vol->dev; cdev->dev = &vol->dev;
@ -239,7 +239,7 @@ int ubi_cdev_add(struct ubi_device *ubi)
int ret; int ret;
cdev->ops = &ubi_fops; cdev->ops = &ubi_fops;
cdev->name = asprintf("%s.ubi", ubi->mtd->cdev.name); cdev->name = basprintf("%s.ubi", ubi->mtd->cdev.name);
cdev->priv = ubi; cdev->priv = ubi;
cdev->size = 0; cdev->size = 0;

View File

@ -16,6 +16,7 @@
#include <common.h> #include <common.h>
#include <malloc.h> #include <malloc.h>
#include <crc.h>
#include <asm-generic/div64.h> #include <asm-generic/div64.h>
#include <errno.h> #include <errno.h>
#include <linux/err.h> #include <linux/err.h>
@ -26,7 +27,7 @@
#include <linux/mtd/mtd.h> #include <linux/mtd/mtd.h>
#include <linux/mtd/ubi.h> #include <linux/mtd/ubi.h>
#define crc32(seed, data, length) crc32_no_comp(seed, (unsigned char const *)data, length) #define crc32(seed, data, length) crc32_no_comp(seed, (unsigned char * const)data, length)
/* configurable */ /* configurable */
#define CONFIG_MTD_UBI_WL_THRESHOLD 4096 #define CONFIG_MTD_UBI_WL_THRESHOLD 4096

View File

@ -20,6 +20,7 @@
#include <common.h> #include <common.h>
#include <malloc.h> #include <malloc.h>
#include <crc.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>

View File

@ -149,7 +149,7 @@ static int micrel_switch_probe(struct device_d *dev)
return -ENODEV; return -ENODEV;
} }
priv->cdev.name = asprintf("switch%d", dev->id); priv->cdev.name = basprintf("switch%d", dev->id);
priv->cdev.size = 256; priv->cdev.size = 256;
priv->cdev.ops = &micrel_switch_ops; priv->cdev.ops = &micrel_switch_ops;
priv->cdev.priv = priv; priv->cdev.priv = priv;

View File

@ -61,7 +61,7 @@ static int environment_check_mount(struct device_d *dev, char **devpath)
/* Set env to be in a file on the now mounted device */ /* Set env to be in a file on the now mounted device */
dev_dbg(dev, "Loading default env from %s on device %s\n", dev_dbg(dev, "Loading default env from %s on device %s\n",
filepath, *devpath); filepath, *devpath);
*devpath = asprintf("%s/%s", ENV_MNT_DIR, filepath); *devpath = basprintf("%s/%s", ENV_MNT_DIR, filepath);
return 0; return 0;
} }

View File

@ -1702,7 +1702,8 @@ struct device_node *of_new_node(struct device_node *parent, const char *name)
if (parent) { if (parent) {
node->name = xstrdup(name); node->name = xstrdup(name);
node->full_name = asprintf("%s/%s", node->parent->full_name, name); node->full_name = basprintf("%s/%s",
node->parent->full_name, name);
list_add(&node->list, &parent->list); list_add(&node->list, &parent->list);
} else { } else {
node->name = xstrdup(""); node->name = xstrdup("");

View File

@ -75,7 +75,7 @@ static int __of_find_path(struct device_node *node, const char *part, char **out
mtd_can_have_bb(cdev->mtd)) mtd_can_have_bb(cdev->mtd))
add_bb = true; add_bb = true;
*outpath = asprintf("/dev/%s%s", cdev->name, add_bb ? ".bb" : ""); *outpath = basprintf("/dev/%s%s", cdev->name, add_bb ? ".bb" : "");
return 0; return 0;
} }

View File

@ -58,7 +58,7 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
if (of_get_property(node, "read-only", &len)) if (of_get_property(node, "read-only", &len))
flags = DEVFS_PARTITION_READONLY; flags = DEVFS_PARTITION_READONLY;
filename = asprintf("%s.%s", cdev->name, partname); filename = basprintf("%s.%s", cdev->name, partname);
new = devfs_add_partition(cdev->name, offset, size, flags, filename); new = devfs_add_partition(cdev->name, offset, size, flags, filename);
if (IS_ERR(new)) if (IS_ERR(new))

View File

@ -306,7 +306,7 @@ static struct mvebu_pcie *mvebu_pcie_port_probe(struct device_d *dev,
reset_gpio = of_get_named_gpio_flags(np, "reset-gpios", 0, &flags); reset_gpio = of_get_named_gpio_flags(np, "reset-gpios", 0, &flags);
if (gpio_is_valid(reset_gpio)) { if (gpio_is_valid(reset_gpio)) {
int reset_active_low = flags & OF_GPIO_ACTIVE_LOW; int reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
char *reset_name = asprintf("pcie%d.%d-reset", port, lane); char *reset_name = basprintf("pcie%d.%d-reset", port, lane);
u32 reset_udelay = 20000; u32 reset_udelay = 20000;
of_property_read_u32(np, "reset-delay-us", &reset_udelay); of_property_read_u32(np, "reset-delay-us", &reset_udelay);
@ -326,7 +326,7 @@ static struct mvebu_pcie *mvebu_pcie_port_probe(struct device_d *dev,
pcie->port = port; pcie->port = port;
pcie->lane = lane; pcie->lane = lane;
pcie->lane_mask = lane_mask; pcie->lane_mask = lane_mask;
pcie->name = asprintf("pcie%d.%d", port, lane); pcie->name = basprintf("pcie%d.%d", port, lane);
pcie->devfn = devfn; pcie->devfn = devfn;
pcie->base = of_iomap(np, 0); pcie->base = of_iomap(np, 0);

View File

@ -68,7 +68,7 @@ int of_pinctrl_select_state(struct device_node *np, const char *name)
/* For each defined state ID */ /* For each defined state ID */
for (state = 0; ; state++) { for (state = 0; ; state++) {
/* Retrieve the pinctrl-* property */ /* Retrieve the pinctrl-* property */
propname = asprintf("pinctrl-%d", state); propname = basprintf("pinctrl-%d", state);
prop = of_find_property(np, propname, NULL); prop = of_find_property(np, propname, NULL);
free(propname); free(propname);

View File

@ -236,9 +236,10 @@ static int imx_pwm_probe(struct device_d *dev)
if (dev->device_node) { if (dev->device_node) {
imx->chip.devname = of_alias_get(dev->device_node); imx->chip.devname = of_alias_get(dev->device_node);
if (!imx->chip.devname) if (!imx->chip.devname)
imx->chip.devname = asprintf("pwm_%p", imx->mmio_base); imx->chip.devname = basprintf("pwm_%p",
imx->mmio_base);
} else { } else {
imx->chip.devname = asprintf("pwm%d", dev->id); imx->chip.devname = basprintf("pwm%d", dev->id);
} }
imx->config = data->config; imx->config = data->config;

View File

@ -143,7 +143,7 @@ static int mxs_pwm_probe(struct device_d *dev)
struct mxs_pwm_chip *mxspwm = &mxs->pwm[i]; struct mxs_pwm_chip *mxspwm = &mxs->pwm[i];
mxspwm->chip.ops = &mxs_pwm_ops; mxspwm->chip.ops = &mxs_pwm_ops;
mxspwm->chip.devname = asprintf("pwm%d", i); mxspwm->chip.devname = basprintf("pwm%d", i);
mxspwm->chip.id = i; mxspwm->chip.id = i;
mxspwm->mxs = mxs; mxspwm->mxs = mxs;

View File

@ -134,7 +134,7 @@ static int pxa_pwm_probe(struct device_d *dev)
struct pxa_pwm_chip *chip; struct pxa_pwm_chip *chip;
chip = xzalloc(sizeof(*chip)); chip = xzalloc(sizeof(*chip));
chip->chip.devname = asprintf("pwm%d", dev->id); chip->chip.devname = basprintf("pwm%d", dev->id);
chip->chip.ops = &pxa_pwm_ops; chip->chip.ops = &pxa_pwm_ops;
iores = dev_request_mem_resource(dev, 0); iores = dev_request_mem_resource(dev, 0);
if (IS_ERR(iores)) if (IS_ERR(iores))

View File

@ -153,7 +153,7 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
struct regulator_internal *ri; struct regulator_internal *ri;
struct device_node *node; struct device_node *node;
propname = asprintf("%s-supply", supply); propname = basprintf("%s-supply", supply);
/* /*
* If the device does have a device node return the dummy regulator. * If the device does have a device node return the dummy regulator.

View File

@ -209,7 +209,7 @@ static int gpio_spi_probe(struct device_d *dev)
if (!gpio_is_valid(pdata->cs[n])) if (!gpio_is_valid(pdata->cs[n]))
continue; continue;
cs_name = asprintf("spi-cs%d", n); cs_name = basprintf("spi-cs%d", n);
ret = gpio_request_one(pdata->cs[n], GPIOF_DIR_OUT, cs_name); ret = gpio_request_one(pdata->cs[n], GPIOF_DIR_OUT, cs_name);
if (ret) if (ret)
return ret; return ret;

View File

@ -1763,7 +1763,7 @@ EXPORT_SYMBOL_GPL(usb_composite_setup_continue);
static char *composite_default_mfr(struct usb_gadget *gadget) static char *composite_default_mfr(struct usb_gadget *gadget)
{ {
return asprintf("barebox %s", gadget->name); return basprintf("barebox %s", gadget->name);
} }
void usb_composite_overwrite_options(struct usb_composite_dev *cdev, void usb_composite_overwrite_options(struct usb_composite_dev *cdev,

View File

@ -17,6 +17,7 @@
#define pr_fmt(fmt) "fastboot: " fmt #define pr_fmt(fmt) "fastboot: " fmt
#include <common.h> #include <common.h>
#include <command.h>
#include <errno.h> #include <errno.h>
#include <malloc.h> #include <malloc.h>
#include <fcntl.h> #include <fcntl.h>
@ -194,7 +195,7 @@ static void fb_setvar(struct fb_variable *var, const char *fmt, ...)
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
var->value = vasprintf(fmt, ap); var->value = bvasprintf(fmt, ap);
va_end(ap); va_end(ap);
} }
@ -204,7 +205,7 @@ static struct fb_variable *fb_addvar(struct f_fastboot *f_fb, const char *fmt, .
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
var->name = vasprintf(fmt, ap); var->name = bvasprintf(fmt, ap);
va_end(ap); va_end(ap);
list_add_tail(&var->list, &f_fb->variables); list_add_tail(&var->list, &f_fb->variables);
@ -701,7 +702,8 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd
if (ret) if (ret)
goto copy; goto copy;
cmd = asprintf("ubiformat -y -f %s %s", FASTBOOT_TMPFILE, filename); cmd = basprintf("ubiformat -y -f %s %s", FASTBOOT_TMPFILE,
filename);
fastboot_tx_print(f_fb, "INFOThis is an UBI image..."); fastboot_tx_print(f_fb, "INFOThis is an UBI image...");

View File

@ -397,7 +397,7 @@ static int usb_stor_add_blkdev(struct us_data *us, struct device_d *dev,
pr_err("Cannot find a free number for the disk node\n"); pr_err("Cannot find a free number for the disk node\n");
pr_info("Using index %d for the new disk\n", result); pr_info("Using index %d for the new disk\n", result);
pblk_dev->blk.cdev.name = asprintf("disk%d", result); pblk_dev->blk.cdev.name = basprintf("disk%d", result);
pblk_dev->blk.blockbits = SECTOR_SHIFT; pblk_dev->blk.blockbits = SECTOR_SHIFT;
result = blockdevice_register(&pblk_dev->blk); result = blockdevice_register(&pblk_dev->blk);

View File

@ -469,7 +469,8 @@ static void calc_mode_timings(int xres, int yres, int refresh,
mode->yres = yres; mode->yres = yres;
mode->refresh = refresh; mode->refresh = refresh;
fb_get_mode(0, refresh, mode); fb_get_mode(0, refresh, mode);
mode->name = asprintf("%dx%d@%d-calc", mode->xres, mode->yres, mode->refresh); mode->name = basprintf("%dx%d@%d-calc", mode->xres, mode->yres,
mode->refresh);
pr_debug(" %s\n", mode->name); pr_debug(" %s\n", mode->name);
} }
@ -602,7 +603,8 @@ const struct fb_videomode vesa_modes[] = {
static void add_vesa_mode(struct fb_videomode *mode, int num) static void add_vesa_mode(struct fb_videomode *mode, int num)
{ {
*mode = vesa_modes[num]; *mode = vesa_modes[num];
mode->name = asprintf("%dx%d@%d-vesa", mode->xres, mode->yres, mode->refresh); mode->name = basprintf("%dx%d@%d-vesa", mode->xres, mode->yres,
mode->refresh);
pr_debug(" %s\n", mode->name); pr_debug(" %s\n", mode->name);
} }
@ -748,7 +750,8 @@ static void get_detailed_timing(unsigned char *block,
pr_debug("%sHSync %sVSync\n", (HSYNC_POSITIVE) ? "+" : "-", pr_debug("%sHSync %sVSync\n", (HSYNC_POSITIVE) ? "+" : "-",
(VSYNC_POSITIVE) ? "+" : "-"); (VSYNC_POSITIVE) ? "+" : "-");
mode->name = asprintf("%dx%d@%d", mode->xres, mode->yres, mode->refresh); mode->name = basprintf("%dx%d@%d", mode->xres, mode->yres,
mode->refresh);
} }
/** /**

View File

@ -262,7 +262,7 @@ int register_framebuffer(struct fb_info *info)
info->line_length = info->xres * (info->bits_per_pixel >> 3); info->line_length = info->xres * (info->bits_per_pixel >> 3);
info->cdev.ops = &fb_ops; info->cdev.ops = &fb_ops;
info->cdev.name = asprintf("fb%d", id); info->cdev.name = basprintf("fb%d", id);
info->cdev.size = info->line_length * info->yres; info->cdev.size = info->line_length * info->yres;
info->cdev.dev = dev; info->cdev.dev = dev;
info->cdev.priv = info; info->cdev.priv = info;

View File

@ -161,7 +161,7 @@ static int imx6q_ldb_prepare(struct imx_ldb_channel *imx_ldb_ch, int di,
ipuno = ((di >> 1) & 1) + 1; ipuno = ((di >> 1) & 1) + 1;
dino = di & 0x1; dino = di & 0x1;
clkname = asprintf("ipu%d_di%d_sel", ipuno, dino); clkname = basprintf("ipu%d_di%d_sel", ipuno, dino);
diclk = clk_lookup(clkname); diclk = clk_lookup(clkname);
free(clkname); free(clkname);
if (IS_ERR(diclk)) { if (IS_ERR(diclk)) {
@ -169,7 +169,7 @@ static int imx6q_ldb_prepare(struct imx_ldb_channel *imx_ldb_ch, int di,
return PTR_ERR(diclk); return PTR_ERR(diclk);
} }
clkname = asprintf("ldb_di%d_podf", imx_ldb_ch->chno); clkname = basprintf("ldb_di%d_podf", imx_ldb_ch->chno);
ldbclk = clk_lookup(clkname); ldbclk = clk_lookup(clkname);
free(clkname); free(clkname);
if (IS_ERR(ldbclk)) { if (IS_ERR(ldbclk)) {
@ -208,7 +208,7 @@ static int imx53_ldb_prepare(struct imx_ldb_channel *imx_ldb_ch, int di,
dino = di & 0x1; dino = di & 0x1;
clkname = asprintf("ipu_di%d_sel", dino); clkname = basprintf("ipu_di%d_sel", dino);
diclk = clk_lookup(clkname); diclk = clk_lookup(clkname);
free(clkname); free(clkname);
if (IS_ERR(diclk)) { if (IS_ERR(diclk)) {
@ -216,7 +216,7 @@ static int imx53_ldb_prepare(struct imx_ldb_channel *imx_ldb_ch, int di,
return PTR_ERR(diclk); return PTR_ERR(diclk);
} }
clkname = asprintf("ldb_di%d_div", imx_ldb_ch->chno); clkname = basprintf("ldb_di%d_div", imx_ldb_ch->chno);
ldbclk = clk_lookup(clkname); ldbclk = clk_lookup(clkname);
free(clkname); free(clkname);
if (IS_ERR(ldbclk)) { if (IS_ERR(ldbclk)) {

View File

@ -732,8 +732,7 @@ int ipu_di_init(struct ipu_soc *ipu, struct device_d *dev, int id,
ipu_di_write(di, 0x10, DI_BS_CLKGEN0); ipu_di_write(di, 0x10, DI_BS_CLKGEN0);
di->clk_di_pixel.parent_names = di->di_parent_names; di->clk_di_pixel.parent_names = di->di_parent_names;
di->clk_name = asprintf("%s_di%d_pixel", di->clk_name = basprintf("%s_di%d_pixel", dev_name(dev), id);
dev_name(dev), id);
if (!di->clk_name) if (!di->clk_name)
return -ENOMEM; return -ENOMEM;

View File

@ -284,7 +284,7 @@ static int ipufb_probe(struct device_d *dev)
info = &fbi->info; info = &fbi->info;
ipuid = of_alias_get_id(dev->parent->device_node, "ipu"); ipuid = of_alias_get_id(dev->parent->device_node, "ipu");
fbi->name = asprintf("ipu%d-di%d", ipuid + 1, pdata->di); fbi->name = basprintf("ipu%d-di%d", ipuid + 1, pdata->di);
fbi->id = ipuid * 2 + pdata->di; fbi->id = ipuid * 2 + pdata->di;
fbi->dino = pdata->di; fbi->dino = pdata->di;

View File

@ -272,7 +272,7 @@ static int ds2431_probe(struct w1_device *dev)
cdev->priv = dev; cdev->priv = dev;
cdev->ops = &ds2431_ops; cdev->ops = &ds2431_ops;
cdev->size = W1_F2D_EEPROM_SIZE; cdev->size = W1_F2D_EEPROM_SIZE;
cdev->name = asprintf(DRIVERNAME"%d", ds2431_count++); cdev->name = basprintf(DRIVERNAME"%d", ds2431_count++);
if (cdev->name == NULL) if (cdev->name == NULL)
return -ENOMEM; return -ENOMEM;

View File

@ -171,7 +171,7 @@ static int ds2433_cdev_create(struct w1_device *dev, int size, int id)
cdev->priv = dev; cdev->priv = dev;
cdev->ops = &ds2433_ops; cdev->ops = &ds2433_ops;
cdev->size = size; cdev->size = size;
cdev->name = asprintf("%s%d", dev->dev.driver->name, id); cdev->name = basprintf("%s%d", dev->dev.driver->name, id);
if (cdev->name == NULL) if (cdev->name == NULL)
return -ENOMEM; return -ENOMEM;

View File

@ -14,6 +14,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <malloc.h> #include <malloc.h>
#include <init.h> #include <init.h>
#include <crc.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/err.h> #include <linux/err.h>
#include <bpkfs.h> #include <bpkfs.h>
@ -102,7 +103,7 @@ static struct bpkfs_handle_hw *bpkfs_get_or_add_hw_id(
INIT_LIST_HEAD(&h->list_data); INIT_LIST_HEAD(&h->list_data);
h->hw_id = hw_id; h->hw_id = hw_id;
h->name = asprintf("hw_id_%x", hw_id); h->name = basprintf("hw_id_%x", hw_id);
list_add_tail(&h->list_hw_id, &handle->list); list_add_tail(&h->list_hw_id, &handle->list);
return h; return h;
@ -430,7 +431,7 @@ static int bpkfs_probe(struct device_d *dev)
if (!type) { if (!type) {
type = "unknown"; type = "unknown";
d->name = asprintf("%s_%08x", type, d->type); d->name = basprintf("%s_%08x", type, d->type);
} else { } else {
d->name = xstrdup(type); d->name = xstrdup(type);
} }
@ -463,7 +464,7 @@ static int bpkfs_probe(struct device_d *dev)
type = d->name; type = d->name;
d = xzalloc(sizeof(*d)); d = xzalloc(sizeof(*d));
d->type = be32_to_cpu(data_header.type); d->type = be32_to_cpu(data_header.type);
d->name = asprintf("%s.crc", type); d->name = basprintf("%s.crc", type);
d->type |= (1 << 31); d->type |= (1 << 31);
d->size = 8; d->size = 8;
sprintf(d->data, "%08x", be32_to_cpu(data_header.crc)); sprintf(d->data, "%08x", be32_to_cpu(data_header.crc));

View File

@ -30,6 +30,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <wchar.h> #include <wchar.h>
#include <efi.h> #include <efi.h>
#include <libfile.h>
#include <mach/efi.h> #include <mach/efi.h>
#include <mach/efi-device.h> #include <mach/efi-device.h>
@ -530,8 +531,8 @@ int efi_fs_probe(struct efi_device *efidev)
if (efi_loaded_image && efidev->protocol == volume) if (efi_loaded_image && efidev->protocol == volume)
path = xstrdup("/boot"); path = xstrdup("/boot");
else else
path = asprintf("/efi%d", index); path = basprintf("/efi%d", index);
device = asprintf("%s", dev_name(&efidev->dev)); device = basprintf("%s", dev_name(&efidev->dev));
ret = make_directory(path); ret = make_directory(path);
if (ret) if (ret)

View File

@ -154,7 +154,7 @@ static int efivars_create(struct device_d *dev, const char *pathname, mode_t mod
name8 = xstrdup_wchar_to_char(inode->name); name8 = xstrdup_wchar_to_char(inode->name);
inode->full_name = asprintf("%s-%pUl", name8, &inode->vendor); inode->full_name = basprintf("%s-%pUl", name8, &inode->vendor);
free(name8); free(name8);
efiret = RT->set_variable(inode->name, &inode->vendor, efiret = RT->set_variable(inode->name, &inode->vendor,
@ -405,7 +405,7 @@ static int efivarfs_probe(struct device_d *dev)
inode->vendor = vendor; inode->vendor = vendor;
name8 = xstrdup_wchar_to_char(inode->name); name8 = xstrdup_wchar_to_char(inode->name);
inode->full_name = asprintf("%s-%pUl", name8, &vendor); inode->full_name = basprintf("%s-%pUl", name8, &vendor);
free(name8); free(name8);
list_add_tail(&inode->node, &priv->inodes); list_add_tail(&inode->node, &priv->inodes);

View File

@ -18,6 +18,7 @@
*/ */
#include <common.h> #include <common.h>
#include <command.h>
#include <fs.h> #include <fs.h>
#include <driver.h> #include <driver.h>
#include <errno.h> #include <errno.h>
@ -33,6 +34,7 @@
#include <environment.h> #include <environment.h>
#include <libgen.h> #include <libgen.h>
#include <block.h> #include <block.h>
#include <libfile.h>
char *mkmodestr(unsigned long mode, char *str) char *mkmodestr(unsigned long mode, char *str)
{ {
@ -1299,7 +1301,8 @@ int mount(const char *device, const char *fsname, const char *_path,
} }
if (!fsdev->linux_rootarg && fsdev->cdev && fsdev->cdev->partuuid[0] != 0) { if (!fsdev->linux_rootarg && fsdev->cdev && fsdev->cdev->partuuid[0] != 0) {
char *str = asprintf("root=PARTUUID=%s", fsdev->cdev->partuuid); char *str = basprintf("root=PARTUUID=%s",
fsdev->cdev->partuuid);
fsdev_set_linux_rootarg(fsdev, str); fsdev_set_linux_rootarg(fsdev, str);
} }
@ -1718,10 +1721,10 @@ const char *cdev_mount_default(struct cdev *cdev, const char *fsoptions)
if (path) if (path)
return path; return path;
newpath = asprintf("/mnt/%s", cdev->name); newpath = basprintf("/mnt/%s", cdev->name);
make_directory(newpath); make_directory(newpath);
devpath = asprintf("/dev/%s", cdev->name); devpath = basprintf("/dev/%s", cdev->name);
ret = mount(devpath, NULL, newpath, fsoptions); ret = mount(devpath, NULL, newpath, fsoptions);

View File

@ -1317,19 +1317,18 @@ static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev)
const char *ip; const char *ip;
ip = ip_to_string(npriv->server); ip = ip_to_string(npriv->server);
str = asprintf("root=/dev/nfs nfsroot=%s:%s%s%s", str = basprintf("root=/dev/nfs nfsroot=%s:%s%s%s", ip, npriv->path,
ip, npriv->path, rootnfsopts[0] ? "," : "", rootnfsopts[0] ? "," : "", rootnfsopts);
rootnfsopts);
/* forward specific mount options on demand */ /* forward specific mount options on demand */
if (npriv->manual_nfs_port == 1) { if (npriv->manual_nfs_port == 1) {
tmp = asprintf("%s,port=%hu", str, npriv->nfs_port); tmp = basprintf("%s,port=%hu", str, npriv->nfs_port);
free(str); free(str);
str = tmp; str = tmp;
} }
if (npriv->manual_mount_port == 1) { if (npriv->manual_mount_port == 1) {
tmp = asprintf("%s,mountport=%hu", str, npriv->mount_port); tmp = basprintf("%s,mountport=%hu", str, npriv->mount_port);
free(str); free(str);
str = tmp; str = tmp;
} }

View File

@ -1269,8 +1269,8 @@ void ubifs_set_rootarg(struct ubifs_priv *priv, struct fs_device_d *fsdev)
mtd = di.mtd; mtd = di.mtd;
str = asprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs", str = basprintf("root=ubi0:%s ubi.mtd=%s rootfstype=ubifs",
vi.name, mtd->cdev.partname); vi.name, mtd->cdev.partname);
fsdev_set_linux_rootarg(fsdev, str); fsdev_set_linux_rootarg(fsdev, str);

View File

@ -34,6 +34,7 @@
#else #else
#include <common.h> #include <common.h>
#include <lzo.h> #include <lzo.h>
#include <crc.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/ctype.h> #include <linux/ctype.h>

View File

@ -17,6 +17,7 @@
#include <uimagefs.h> #include <uimagefs.h>
#include <libbb.h> #include <libbb.h>
#include <rtc.h> #include <rtc.h>
#include <crc.h>
#include <libfile.h> #include <libfile.h>
static bool uimagefs_is_data_file(struct uimagefs_handle_data *d) static bool uimagefs_is_data_file(struct uimagefs_handle_data *d)
@ -249,7 +250,7 @@ static int uimagefs_add_name(struct uimagefs_handle *priv)
static int uimagefs_add_hex(struct uimagefs_handle *priv, enum uimagefs_type type, static int uimagefs_add_hex(struct uimagefs_handle *priv, enum uimagefs_type type,
uint32_t data) uint32_t data)
{ {
char *val = asprintf("0x%x", data); char *val = basprintf("0x%x", data);
return uimagefs_add_str(priv, type, val); return uimagefs_add_str(priv, type, val);
} }
@ -265,7 +266,7 @@ static int __uimagefs_add_data(struct uimagefs_handle *priv, size_t offset,
if (i < 0) if (i < 0)
d->name = xstrdup(name); d->name = xstrdup(name);
else else
d->name = asprintf("%s%d", name, i); d->name = basprintf("%s%d", name, i);
d->offset = offset; d->offset = offset;
d->size = size; d->size = size;
@ -303,7 +304,7 @@ static int uimagefs_add_time(struct uimagefs_handle *priv)
char *val; char *val;
to_tm(header->ih_time, &tm); to_tm(header->ih_time, &tm);
val = asprintf("%4d-%02d-%02d %2d:%02d:%02d UTC", val = basprintf("%4d-%02d-%02d %2d:%02d:%02d UTC",
tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_year, tm.tm_mon, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec); tm.tm_hour, tm.tm_min, tm.tm_sec);
@ -514,8 +515,8 @@ static int uimagefs_probe(struct device_d *dev)
dev_dbg(dev, "mount: %s\n", fsdev->backingstore); dev_dbg(dev, "mount: %s\n", fsdev->backingstore);
if (IS_BUILTIN(CONFIG_FS_TFTP)) if (IS_BUILTIN(CONFIG_FS_TFTP))
priv->tmp = asprintf("/.uImage_tmp_%08x", priv->tmp = basprintf("/.uImage_tmp_%08x",
crc32(0, fsdev->path, strlen(fsdev->path))); crc32(0, fsdev->path, strlen(fsdev->path)));
ret = __uimage_open(priv); ret = __uimage_open(priv);
if (ret) if (ret)

View File

@ -71,6 +71,7 @@ extern struct command __barebox_cmd_end;
struct command *find_cmd(const char *cmd); struct command *find_cmd(const char *cmd);
int execute_command(int argc, char **argv); int execute_command(int argc, char **argv);
void barebox_cmd_usage(struct command *cmdtp); void barebox_cmd_usage(struct command *cmdtp);
int run_command(const char *cmd);
#define COMMAND_SUCCESS 0 #define COMMAND_SUCCESS 0
#define COMMAND_ERROR 1 #define COMMAND_ERROR 1

Some files were not shown because too many files have changed in this diff Show More