Merge branch 'for-next/env'
This commit is contained in:
commit
2274c6ea77
|
@ -1 +0,0 @@
|
|||
nand -a /dev/nand0.*
|
|
@ -7,10 +7,6 @@ export PATH
|
|||
|
||||
if [ -e /dev/nand0 ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
|
||||
# Uh, oh, hush first expands wildcards and then starts executing
|
||||
# commands. What a bug!
|
||||
source /env/bin/hush_hack
|
||||
fi
|
||||
|
||||
if [ -z $eth0.ethaddr ]; then
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
nand -a /dev/nand0.*
|
|
@ -7,10 +7,6 @@ export PATH
|
|||
|
||||
if [ -e /dev/nand0 ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
|
||||
# Uh, oh, hush first expands wildcards and then starts executing
|
||||
# commands. What a bug!
|
||||
source /env/bin/hush_hack
|
||||
fi
|
||||
|
||||
if [ -z $eth0.ethaddr ]; then
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
nand -a /dev/nand0.*
|
|
@ -10,10 +10,6 @@ fi
|
|||
|
||||
if [ -e /dev/nand0 ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
|
||||
# Uh, oh, hush first expands wildcards and then starts executing
|
||||
# commands. What a bug!
|
||||
source /env/bin/hush_hack
|
||||
fi
|
||||
|
||||
if [ -f /env/logo.bmp ]; then
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
nand -a /dev/nand0.*
|
|
@ -10,10 +10,6 @@ fi
|
|||
|
||||
if [ -e /dev/nand0 ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
|
||||
# Uh, oh, hush first expands wildcards and then starts executing
|
||||
# commands. What a bug!
|
||||
source /env/bin/hush_hack
|
||||
fi
|
||||
|
||||
echo
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
nand -a /dev/nand0.*
|
|
@ -10,10 +10,6 @@ fi
|
|||
|
||||
if [ -e /dev/nand0 ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
|
||||
# Uh, oh, hush first expands wildcards and then starts executing
|
||||
# commands. What a bug!
|
||||
source /env/bin/hush_hack
|
||||
fi
|
||||
|
||||
if [ -z $eth0.ethaddr ]; then
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
nand -a /dev/nand0.*
|
|
@ -10,10 +10,6 @@ fi
|
|||
|
||||
if [ -e /dev/nand0 ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
|
||||
# Uh, oh, hush first expands wildcards and then starts executing
|
||||
# commands. What a bug!
|
||||
source /env/bin/hush_hack
|
||||
fi
|
||||
|
||||
if [ -z $eth0.ethaddr ]; then
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
static int do_saveenv(int argc, char *argv[])
|
||||
{
|
||||
int ret, fd;
|
||||
int ret;
|
||||
char *filename, *dirname;
|
||||
|
||||
printf("saving environment\n");
|
||||
|
@ -42,52 +42,8 @@ static int do_saveenv(int argc, char *argv[])
|
|||
else
|
||||
filename = argv[1];
|
||||
|
||||
fd = open(filename, O_WRONLY | O_CREAT);
|
||||
if (fd < 0) {
|
||||
printf("could not open %s: %s\n", filename, errno_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = protect(fd, ~0, 0, 0);
|
||||
|
||||
/* ENOSYS is no error here, many devices do not need it */
|
||||
if (ret && errno != ENOSYS) {
|
||||
printf("could not unprotect %s: %s\n", filename, errno_str());
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = erase(fd, ~0, 0);
|
||||
|
||||
/* ENOSYS is no error here, many devices do not need it */
|
||||
if (ret && errno != ENOSYS) {
|
||||
printf("could not erase %s: %s\n", filename, errno_str());
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
ret = envfs_save(filename, dirname);
|
||||
if (ret) {
|
||||
printf("saveenv failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
fd = open(filename, O_WRONLY | O_CREAT);
|
||||
|
||||
ret = protect(fd, ~0, 0, 1);
|
||||
|
||||
/* ENOSYS is no error here, many devices do not need it */
|
||||
if (ret && errno != ENOSYS) {
|
||||
printf("could not protect %s: %s\n", filename, errno_str());
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
out:
|
||||
close(fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,16 @@ char *default_environment_path_get(void)
|
|||
{
|
||||
return default_environment_path;
|
||||
}
|
||||
#else
|
||||
static inline int protect(int fd, size_t count, unsigned long offset, int prot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int erase(int fd, size_t count, unsigned long offset)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int file_size_action(const char *filename, struct stat *statbuf,
|
||||
|
@ -196,11 +206,27 @@ int envfs_save(const char *filename, const char *dirname)
|
|||
|
||||
envfd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (envfd < 0) {
|
||||
printf("Open %s %s\n", filename, errno_str());
|
||||
ret = envfd;
|
||||
printf("could not open %s: %s\n", filename, errno_str());
|
||||
ret = -errno;
|
||||
goto out1;
|
||||
}
|
||||
|
||||
ret = protect(envfd, ~0, 0, 0);
|
||||
|
||||
/* ENOSYS is no error here, many devices do not need it */
|
||||
if (ret && errno != ENOSYS) {
|
||||
printf("could not unprotect %s: %s\n", filename, errno_str());
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = erase(envfd, ~0, 0);
|
||||
|
||||
/* ENOSYS is no error here, many devices do not need it */
|
||||
if (ret && errno != ENOSYS) {
|
||||
printf("could not erase %s: %s\n", filename, errno_str());
|
||||
goto out;
|
||||
}
|
||||
|
||||
size += sizeof(struct envfs_super);
|
||||
|
||||
wbuf = buf;
|
||||
|
@ -216,6 +242,14 @@ int envfs_save(const char *filename, const char *dirname)
|
|||
size -= now;
|
||||
}
|
||||
|
||||
ret = protect(envfd, ~0, 0, 1);
|
||||
|
||||
/* ENOSYS is no error here, many devices do not need it */
|
||||
if (ret && errno != ENOSYS) {
|
||||
printf("could not protect %s: %s\n", filename, errno_str());
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
|
@ -395,7 +429,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 +487,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
|
||||
|
|
|
@ -16,7 +16,6 @@ fi
|
|||
|
||||
if [ -e /dev/nand0 -a -n "$nand_parts" ]; then
|
||||
addpart /dev/nand0 $nand_parts
|
||||
nand -a /dev/nand0.*
|
||||
fi
|
||||
|
||||
if [ -f /env/bin/init_board ]; then
|
||||
|
|
|
@ -39,10 +39,6 @@ fi
|
|||
addpart -n /dev/${device} "$parts" || exit
|
||||
mkdir -p /tmp/mtdparts/${device}
|
||||
|
||||
if [ -n "${bbdev}" ]; then
|
||||
nand -a /dev/${device}.*
|
||||
fi
|
||||
|
||||
if [ -n ${kernelname} ]; then
|
||||
global linux.mtdparts.${device}
|
||||
global.linux.mtdparts.${device}="${kernelname}:${parts}"
|
||||
|
|
|
@ -409,6 +409,9 @@ int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id)
|
|||
|
||||
devfs_create(&mtd->cdev);
|
||||
|
||||
if (mtd_can_have_bb(mtd))
|
||||
mtd->cdev_bb = mtd_add_bb(mtd, NULL);
|
||||
|
||||
if (mtd->parent && !mtd->master)
|
||||
of_parse_partitions(&mtd->cdev, mtd->parent->device_node);
|
||||
|
||||
|
|
|
@ -25,22 +25,19 @@
|
|||
#include <init.h>
|
||||
#include <ioctl.h>
|
||||
#include <nand.h>
|
||||
#include <linux/mtd/mtd-abi.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <fcntl.h>
|
||||
#include <libgen.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
struct nand_bb {
|
||||
char cdevname[MAX_DRIVER_NAME];
|
||||
struct cdev *cdev_parent;
|
||||
char *name;
|
||||
int open;
|
||||
int needs_write;
|
||||
|
||||
struct mtd_info_user info;
|
||||
struct mtd_info *mtd;
|
||||
|
||||
loff_t raw_size;
|
||||
loff_t size;
|
||||
loff_t offset;
|
||||
unsigned long flags;
|
||||
void *writebuf;
|
||||
|
@ -54,31 +51,28 @@ static ssize_t nand_bb_read(struct cdev *cdev, void *buf, size_t count,
|
|||
loff_t offset, ulong flags)
|
||||
{
|
||||
struct nand_bb *bb = cdev->priv;
|
||||
struct cdev *parent = bb->cdev_parent;
|
||||
size_t retlen;
|
||||
int ret, bytes = 0, now;
|
||||
|
||||
debug("%s 0x%08llx %d\n", __func__, offset, count);
|
||||
|
||||
while(count) {
|
||||
ret = cdev_ioctl(parent, MEMGETBADBLOCK, &bb->offset);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (ret) {
|
||||
while (count) {
|
||||
if (mtd_block_isbad(bb->mtd, offset)) {
|
||||
printf("skipping bad block at 0x%08llx\n", bb->offset);
|
||||
bb->offset += bb->info.erasesize;
|
||||
bb->offset += bb->mtd->erasesize;
|
||||
continue;
|
||||
}
|
||||
|
||||
now = min(count, (size_t)(bb->info.erasesize -
|
||||
((size_t)bb->offset % bb->info.erasesize)));
|
||||
ret = cdev_read(parent, buf, now, bb->offset, 0);
|
||||
now = min(count, (size_t)(bb->mtd->erasesize -
|
||||
((size_t)bb->offset % bb->mtd->erasesize)));
|
||||
|
||||
ret = mtd_read(bb->mtd, bb->offset, now, &retlen, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
buf += now;
|
||||
count -= now;
|
||||
bb->offset += now;
|
||||
bytes += now;
|
||||
buf += retlen;
|
||||
count -= retlen;
|
||||
bb->offset += retlen;
|
||||
bytes += retlen;
|
||||
};
|
||||
|
||||
return bytes;
|
||||
|
@ -91,29 +85,25 @@ static ssize_t nand_bb_read(struct cdev *cdev, void *buf, size_t count,
|
|||
static int nand_bb_write_buf(struct nand_bb *bb, size_t count)
|
||||
{
|
||||
int ret, now;
|
||||
struct cdev *parent = bb->cdev_parent;
|
||||
size_t retlen;
|
||||
void *buf = bb->writebuf;
|
||||
loff_t cur_ofs = bb->offset & ~(BB_WRITEBUF_SIZE - 1);
|
||||
|
||||
while (count) {
|
||||
ret = cdev_ioctl(parent, MEMGETBADBLOCK, &cur_ofs);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
if (ret) {
|
||||
if (mtd_block_isbad(bb->mtd, cur_ofs)) {
|
||||
debug("skipping bad block at 0x%08llx\n", cur_ofs);
|
||||
bb->offset += bb->info.erasesize;
|
||||
cur_ofs += bb->info.erasesize;
|
||||
bb->offset += bb->mtd->erasesize;
|
||||
cur_ofs += bb->mtd->erasesize;
|
||||
continue;
|
||||
}
|
||||
|
||||
now = min(count, (size_t)(bb->info.erasesize));
|
||||
ret = cdev_write(parent, buf, now, cur_ofs, 0);
|
||||
now = min(count, (size_t)(bb->mtd->erasesize));
|
||||
ret = mtd_write(bb->mtd, cur_ofs, now, &retlen, buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
buf += now;
|
||||
count -= now;
|
||||
cur_ofs += now;
|
||||
buf += retlen;
|
||||
count -= retlen;
|
||||
cur_ofs += retlen;
|
||||
};
|
||||
|
||||
return 0;
|
||||
|
@ -152,13 +142,17 @@ static ssize_t nand_bb_write(struct cdev *cdev, const void *buf, size_t count,
|
|||
static int nand_bb_erase(struct cdev *cdev, size_t count, loff_t offset)
|
||||
{
|
||||
struct nand_bb *bb = cdev->priv;
|
||||
struct erase_info erase = {};
|
||||
|
||||
if (offset != 0) {
|
||||
printf("can only erase from beginning of device\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return cdev_erase(bb->cdev_parent, bb->raw_size, 0);
|
||||
erase.addr = 0;
|
||||
erase.len = bb->mtd->size;
|
||||
|
||||
return mtd_erase(bb->mtd, &erase);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -195,16 +189,12 @@ static int nand_bb_close(struct cdev *cdev)
|
|||
static int nand_bb_calc_size(struct nand_bb *bb)
|
||||
{
|
||||
loff_t pos = 0;
|
||||
int ret;
|
||||
|
||||
while (pos < bb->raw_size) {
|
||||
ret = cdev_ioctl(bb->cdev_parent, MEMGETBADBLOCK, &pos);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!ret)
|
||||
bb->cdev.size += bb->info.erasesize;
|
||||
while (pos < bb->mtd->size) {
|
||||
if (!mtd_block_isbad(bb->mtd, pos))
|
||||
bb->cdev.size += bb->mtd->erasesize;
|
||||
|
||||
pos += bb->info.erasesize;
|
||||
pos += bb->mtd->erasesize;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -215,22 +205,18 @@ static loff_t nand_bb_lseek(struct cdev *cdev, loff_t __offset)
|
|||
struct nand_bb *bb = cdev->priv;
|
||||
loff_t raw_pos = 0;
|
||||
uint32_t offset = __offset;
|
||||
int ret;
|
||||
|
||||
/* lseek only in readonly mode */
|
||||
if (bb->flags & O_ACCMODE)
|
||||
return -ENOSYS;
|
||||
while (raw_pos < bb->raw_size) {
|
||||
off_t now = min(offset, bb->info.erasesize);
|
||||
while (raw_pos < bb->mtd->size) {
|
||||
off_t now = min(offset, bb->mtd->erasesize);
|
||||
|
||||
ret = cdev_ioctl(bb->cdev_parent, MEMGETBADBLOCK, &raw_pos);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (!ret) {
|
||||
if (mtd_block_isbad(bb->mtd, raw_pos)) {
|
||||
raw_pos += bb->mtd->erasesize;
|
||||
} else {
|
||||
offset -= now;
|
||||
raw_pos += now;
|
||||
} else {
|
||||
raw_pos += bb->info.erasesize;
|
||||
}
|
||||
|
||||
if (!offset) {
|
||||
|
@ -255,6 +241,36 @@ static struct file_operations nand_bb_ops = {
|
|||
|
||||
static LIST_HEAD(bb_list);
|
||||
|
||||
struct cdev *mtd_add_bb(struct mtd_info *mtd, const char *name)
|
||||
{
|
||||
struct nand_bb *bb;
|
||||
int ret;
|
||||
|
||||
bb = xzalloc(sizeof(*bb));
|
||||
bb->mtd = mtd;
|
||||
|
||||
if (name)
|
||||
bb->cdev.name = xstrdup(name);
|
||||
else
|
||||
bb->cdev.name = asprintf("%s.bb", mtd->cdev.name);
|
||||
|
||||
nand_bb_calc_size(bb);
|
||||
bb->cdev.ops = &nand_bb_ops;
|
||||
bb->cdev.priv = bb;
|
||||
|
||||
ret = devfs_create(&bb->cdev);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
list_add_tail(&bb->list, &bb_list);
|
||||
|
||||
return &bb->cdev;
|
||||
|
||||
err:
|
||||
free(bb);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a bad block aware device ontop of another (NAND) device
|
||||
* @param[in] dev The device to add a partition on
|
||||
|
@ -263,47 +279,18 @@ static LIST_HEAD(bb_list);
|
|||
*/
|
||||
int dev_add_bb_dev(const char *path, const char *name)
|
||||
{
|
||||
struct nand_bb *bb;
|
||||
int ret = -ENOMEM;
|
||||
struct cdev *parent, *cdev;
|
||||
|
||||
bb = xzalloc(sizeof(*bb));
|
||||
parent = cdev_by_name(path);
|
||||
if (!parent)
|
||||
return -ENODEV;
|
||||
|
||||
bb->cdev_parent = cdev_open(path, O_RDWR);
|
||||
if (!bb->cdev_parent)
|
||||
goto out1;
|
||||
if (!parent->mtd)
|
||||
return -EINVAL;
|
||||
|
||||
if (name) {
|
||||
strcpy(bb->cdevname, name);
|
||||
} else {
|
||||
strcpy(bb->cdevname, path);
|
||||
strcat(bb->cdevname, ".bb");
|
||||
}
|
||||
cdev = mtd_add_bb(parent->mtd, name);
|
||||
|
||||
bb->cdev.name = bb->cdevname;
|
||||
|
||||
bb->raw_size = bb->cdev_parent->size;
|
||||
|
||||
ret = cdev_ioctl(bb->cdev_parent, MEMGETINFO, &bb->info);
|
||||
if (ret)
|
||||
goto out4;
|
||||
|
||||
nand_bb_calc_size(bb);
|
||||
bb->cdev.ops = &nand_bb_ops;
|
||||
bb->cdev.priv = bb;
|
||||
|
||||
ret = devfs_create(&bb->cdev);
|
||||
if (ret)
|
||||
goto out4;
|
||||
|
||||
list_add_tail(&bb->list, &bb_list);
|
||||
|
||||
return 0;
|
||||
|
||||
out4:
|
||||
cdev_close(bb->cdev_parent);
|
||||
out1:
|
||||
free(bb);
|
||||
return ret;
|
||||
return PTR_ERR(cdev);
|
||||
}
|
||||
|
||||
int dev_remove_bb_dev(const char *name)
|
||||
|
@ -313,8 +300,8 @@ int dev_remove_bb_dev(const char *name)
|
|||
list_for_each_entry_safe(bb, tmp, &bb_list, list) {
|
||||
if (!strcmp(bb->cdev.name, name)) {
|
||||
devfs_remove(&bb->cdev);
|
||||
cdev_close(bb->cdev_parent);
|
||||
list_del_init(&bb->list);
|
||||
free(bb->name);
|
||||
free(bb);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <malloc.h>
|
||||
#include <partition.h>
|
||||
#include <envfs.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
|
||||
struct of_partition {
|
||||
struct list_head list;
|
||||
|
@ -57,6 +58,24 @@ static int environment_probe(struct device_d *dev)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* The environment support is not bad block aware, hence we
|
||||
* have to use the .bb device. Test if we have a nand device
|
||||
* and if yes, append .bb to the filename.
|
||||
*/
|
||||
if (!strncmp(path, "/dev/", 5)) {
|
||||
struct cdev *cdev;
|
||||
char *cdevname;
|
||||
|
||||
cdevname = path + 5;
|
||||
cdev = cdev_by_name(cdevname);
|
||||
if (cdev && cdev->mtd && mtd_can_have_bb(cdev->mtd)) {
|
||||
char *bbpath = asprintf("%s.bb", path);
|
||||
free(path);
|
||||
path = bbpath;
|
||||
}
|
||||
}
|
||||
|
||||
dev_info(dev, "setting default environment path to %s\n", path);
|
||||
|
||||
default_environment_path_set(path);
|
||||
|
|
|
@ -61,9 +61,6 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
|
|||
|
||||
new = devfs_add_partition(cdev->name, offset, size, flags, filename);
|
||||
|
||||
if (cdev->mtd && cdev->mtd->type == MTD_NANDFLASH)
|
||||
dev_add_bb_dev(filename, NULL);
|
||||
|
||||
free(filename);
|
||||
|
||||
return new;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -211,6 +211,8 @@ struct mtd_info {
|
|||
struct device_d *parent;
|
||||
struct cdev cdev;
|
||||
|
||||
struct cdev *cdev_bb;
|
||||
|
||||
struct param_d param_size;
|
||||
char *size_str;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ struct nand_bb;
|
|||
#ifdef CONFIG_NAND
|
||||
int dev_add_bb_dev(const char *filename, const char *name);
|
||||
int dev_remove_bb_dev(const char *name);
|
||||
struct cdev *mtd_add_bb(struct mtd_info *mtd, const char *name);
|
||||
#else
|
||||
static inline int dev_add_bb_dev(const char *filename, const char *name) {
|
||||
return 0;
|
||||
|
@ -15,6 +16,11 @@ static inline int dev_remove_bb_dev(const char *name)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct cdev *mtd_add_bb(struct mtd_info *mtd, const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __NAND_H__ */
|
||||
|
|
Loading…
Reference in New Issue