environment: drop envfs_register_partition
The purpose of envfs_register_partition is to print an error message when the partition does not exist. Print an error message from generic code instead and drop this function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
0af79fbb67
commit
54bea204e2
|
@ -299,9 +299,7 @@ static int falconwing_devices_init(void)
|
|||
|
||||
armlinux_set_architecture(MACH_TYPE_CHUMBY);
|
||||
|
||||
rc = envfs_register_partition("disk0", 1);
|
||||
if (rc != 0)
|
||||
printf("Cannot create the 'env0' persistent environment storage (%d)\n", rc);
|
||||
default_environment_path_set("/dev/disk0.1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -135,10 +135,7 @@ static int cfa10036_devices_init(void)
|
|||
|
||||
cfa10036_detect_hw();
|
||||
|
||||
ret = envfs_register_partition("disk0", 1);
|
||||
if (ret != 0)
|
||||
printf("Cannot create the 'env0' persistent "
|
||||
"environment storage (%d)\n", ret);
|
||||
default_environment_path_set("/dev/disk0.1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -129,10 +129,7 @@ static int imx23_olinuxino_devices_init(void)
|
|||
|
||||
olinuxino_init_usb();
|
||||
|
||||
rc = envfs_register_partition("disk0", 1);
|
||||
if (rc != 0)
|
||||
printf("Cannot create the 'env0' persistent "
|
||||
"environment storage (%d)\n", rc);
|
||||
default_environment_path_set("/dev/disk0.1");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -395,7 +395,9 @@ int envfs_load(const char *filename, const char *dir, unsigned flags)
|
|||
|
||||
envfd = open(filename, O_RDONLY);
|
||||
if (envfd < 0) {
|
||||
printf("Open %s %s\n", filename, errno_str());
|
||||
printf("environment load %s: %s\n", filename, errno_str());
|
||||
if (errno == ENOENT)
|
||||
printf("Maybe you have to create the partition.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -451,49 +453,3 @@ out:
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __BAREBOX__
|
||||
/**
|
||||
* Try to register an environment storage on a device's partition
|
||||
* @return 0 on success
|
||||
*
|
||||
* We rely on the existence of a usable storage device, already attached to
|
||||
* our system, to get something like a persistent memory for our environment.
|
||||
* We need to specify the partition number to use on this device.
|
||||
* @param[in] devname Name of the device
|
||||
* @param[in] partnr Partition number
|
||||
* @return 0 on success, anything else in case of failure
|
||||
*/
|
||||
|
||||
int envfs_register_partition(const char *devname, unsigned int partnr)
|
||||
{
|
||||
struct cdev *cdev, *part;
|
||||
char *partname;
|
||||
|
||||
if (!devname)
|
||||
return -EINVAL;
|
||||
|
||||
cdev = cdev_by_name(devname);
|
||||
if (cdev == NULL) {
|
||||
pr_err("No %s present\n", devname);
|
||||
return -ENODEV;
|
||||
}
|
||||
partname = asprintf("%s.%d", devname, partnr);
|
||||
cdev = cdev_by_name(partname);
|
||||
if (cdev == NULL) {
|
||||
pr_err("No %s partition available\n", partname);
|
||||
pr_info("Please create the partition %s to store the env\n", partname);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
part = devfs_add_partition(partname, 0, cdev->size,
|
||||
DEVFS_PARTITION_FIXED, "env0");
|
||||
if (part)
|
||||
return 0;
|
||||
|
||||
free(partname);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
EXPORT_SYMBOL(envfs_register_partition);
|
||||
#endif
|
||||
|
|
|
@ -110,8 +110,6 @@ static inline char *default_environment_path_get(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int envfs_register_partition(const char *devname, unsigned int partnr);
|
||||
|
||||
#ifdef CONFIG_DEFAULT_ENVIRONMENT
|
||||
void defaultenv_append(void *buf, unsigned int size, const char *name);
|
||||
int defaultenv_load(const char *dir, unsigned flags);
|
||||
|
|
Loading…
Reference in New Issue