9
0
Fork 0

Merge branch 'for-next/mtd'

This commit is contained in:
Sascha Hauer 2013-11-07 08:31:47 +01:00
commit 398cdf212d
10 changed files with 36 additions and 23 deletions

View File

@ -1,10 +1,10 @@
#!/bin/sh
# Page+OOB specific partitions
addpart /dev/mtdraw0 1081344@3649536(msipl)
addpart /dev/mtdraw0 270336@3649536(barebox)
addpart /dev/mtd0.raw 1081344@3649536(msipl)
addpart /dev/mtd0.raw 270336@3649536(barebox)
if [ -r /barebox.BIP0 ]; then
erase /dev/mtdraw0.barebox
cp -v /barebox.BIP0 /dev/mtdraw0.barebox
erase /dev/mtd0.raw.barebox
cp -v /barebox.BIP0 /dev/mtd0.raw.barebox
fi

View File

@ -1,12 +1,12 @@
#!/bin/sh
# Page+OOB specific partitions
addpart /dev/mtdraw0 67584@202752(dps1)
addpart /dev/mtd0.raw 67584@202752(dps1)
uncompress /env/data/dps1.raw.gz /dps1.raw
if [ -r /dps1.raw ]; then
dps1_unlock
erase /dev/mtdraw0.dps1
cp -v /dps1.raw /dev/mtdraw0.dps1
erase /dev/mtd0.raw.dps1
cp -v /dps1.raw /dev/mtd0.raw.dps1
dps1_unlock
fi

View File

@ -359,21 +359,25 @@ static struct file_operations mtd_ops = {
.lseek = dev_lseek_default,
};
int add_mtd_device(struct mtd_info *mtd, char *devname)
int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id)
{
struct mtddev_hook *hook;
if (!devname)
devname = "mtd";
strcpy(mtd->class_dev.name, devname);
mtd->class_dev.id = DEVICE_ID_DYNAMIC;
mtd->class_dev.id = device_id;
if (mtd->parent)
mtd->class_dev.parent = mtd->parent;
register_device(&mtd->class_dev);
mtd->cdev.ops = &mtd_ops;
mtd->cdev.size = mtd->size;
mtd->cdev.name = asprintf("%s%d", devname, mtd->class_dev.id);
if (device_id == DEVICE_ID_SINGLE)
mtd->cdev.name = xstrdup(devname);
else
mtd->cdev.name = asprintf("%s%d", devname, mtd->class_dev.id);
mtd->cdev.priv = mtd;
mtd->cdev.dev = &mtd->class_dev;
mtd->cdev.mtd = mtd;

View File

@ -1173,7 +1173,7 @@ static int __init docg3_probe(struct device_d *dev)
}
docg3_floors[floor] = mtd;
mtd->parent = dev;
ret = add_mtd_device(mtd, NULL);
ret = add_mtd_device(mtd, NULL, DEVICE_ID_DYNAMIC);
if (ret)
goto err_probe;
found++;

View File

@ -808,6 +808,8 @@ static int m25p_probe(struct device_d *dev)
struct flash_info *info = NULL;
unsigned i;
unsigned do_jdec_probe = 1;
char *flashname = NULL;
int device_id;
/* Platform data helps sort out which chip type we have, as
* well as how this board partitions it. If we don't have
@ -876,10 +878,19 @@ static int m25p_probe(struct device_d *dev)
write_sr(flash, 0);
}
if (data && data->name)
flash->mtd.name = data->name;
else
flash->mtd.name = "m25p";
device_id = DEVICE_ID_SINGLE;
if (dev->device_node) {
const char *alias = of_alias_get(dev->device_node);
if (alias)
flashname = xstrdup(alias);
} else if (data && data->name) {
flashname = data->name;
}
if (!flashname) {
device_id = DEVICE_ID_DYNAMIC;
flashname = "m25p";
}
flash->mtd.type = MTD_NORFLASH;
flash->mtd.writesize = 1;
@ -942,9 +953,7 @@ static int m25p_probe(struct device_d *dev)
flash->mtd.eraseregions[i].erasesize / 1024,
flash->mtd.eraseregions[i].numblocks);
return add_mtd_device(&flash->mtd, flash->mtd.name);
return add_mtd_device(&flash->mtd, flashname, device_id);
}
static __maybe_unused struct of_device_id m25p80_dt_ids[] = {

View File

@ -643,7 +643,7 @@ add_dataflash_otp(struct spi_device *spi, char *name,
name, (long long)((device->size + 1023) >> 10),
pagesize, otp_tag);
err = add_mtd_device(device, device->name);
err = add_mtd_device(device, device->name, DEVICE_ID_DYNAMIC);
if (!err)
return 0;

View File

@ -293,7 +293,7 @@ static int add_mtdraw_device(struct mtd_info *mtd, char *devname, void **priv)
mtdraw->cdev.ops = (struct file_operations *)&mtd_raw_fops;
mtdraw->cdev.size = mtd->size / mtd->writesize *
(mtd->writesize + mtd->oobsize);
mtdraw->cdev.name = asprintf("%sraw%d", devname, mtd->class_dev.id);
mtdraw->cdev.name = asprintf("%s.raw", mtd->cdev.name);
mtdraw->cdev.priv = mtdraw;
mtdraw->cdev.dev = &mtd->class_dev;
mtdraw->cdev.mtd = mtd;

View File

@ -3690,7 +3690,7 @@ int add_mtd_nand_device(struct mtd_info *mtd, char *devname)
{
int ret;
ret = add_mtd_device(mtd, devname);
ret = add_mtd_device(mtd, devname, DEVICE_ID_DYNAMIC);
if (ret)
return ret;

View File

@ -965,7 +965,7 @@ static void cfi_init_mtd(struct flash_info *info)
mtd->type = MTD_NORFLASH;
mtd->parent = info->dev;
add_mtd_device(mtd, "nor");
add_mtd_device(mtd, "nor", DEVICE_ID_DYNAMIC);
}
static int cfi_probe (struct device_d *dev)

View File

@ -254,7 +254,7 @@ static inline uint32_t mtd_mod_by_eb(uint64_t sz, struct mtd_info *mtd)
}
/* Kernel-side ioctl definitions */
extern int add_mtd_device(struct mtd_info *mtd, char *devname);
extern int add_mtd_device(struct mtd_info *mtd, char *devname, int device_id);
extern int del_mtd_device (struct mtd_info *mtd);
extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);