Lines Matching refs:mtd

26 #include <linux/mtd/partitions.h>
35 /* Maximum length of the 'mtd=' parameter */
38 /* Maximum number of comma-separated items in the 'mtd=' parameter */
383 ret = sprintf(buf, "%d\n", ubi->mtd->index);
558 limit = mtd_max_bad_blocks(ubi->mtd, 0, ubi->mtd->size);
571 * the MTD partition we are attaching (ubi->mtd).
573 device_size = mtd_get_device_size(ubi->mtd);
574 device_pebs = mtd_div_by_eb(device_size, ubi->mtd);
605 if (ubi->mtd->numeraseregions != 0) {
627 ubi->peb_size = ubi->mtd->erasesize;
628 ubi->peb_count = mtd_div_by_eb(ubi->mtd->size, ubi->mtd);
629 ubi->flash_size = ubi->mtd->size;
631 if (mtd_can_have_bb(ubi->mtd)) {
636 if (ubi->mtd->type == MTD_NORFLASH)
639 ubi->min_io_size = ubi->mtd->writesize;
640 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
657 ubi->max_write_size = ubi->mtd->writebufsize;
753 if (!(ubi->mtd->flags & MTD_WRITEABLE)) {
755 ubi->mtd->index);
762 * over all physical eraseblocks and invoke mtd->block_is_bad() for
829 * @mtd: MTD device description object
849 int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
870 if (ubi && mtd->index == ubi->mtd->index) {
871 pr_err("ubi: mtd%d is already attached to ubi%d\n",
872 mtd->index, i);
885 if (mtd->type == MTD_UBIVOLUME) {
886 pr_err("ubi: refuse attaching mtd%d - it is already emulated on top of UBI\n",
887 mtd->index);
898 if (mtd->type == MTD_MLCNANDFLASH &&
899 !(mtd->flags & MTD_SLC_ON_MLC_EMULATION)) {
900 pr_err("ubi: refuse attaching mtd%d - MLC NAND is not supported\n",
901 mtd->index);
906 if (!mtd->erasesize) {
907 pr_err("ubi: refuse attaching mtd%d - zero erasesize flash is not supported\n",
908 mtd->index);
941 ubi->dev.parent = &mtd->dev;
943 ubi->mtd = mtd;
956 ubi->fm_pool.max_size = min(((int)mtd_div_by_eb(ubi->mtd->size,
957 ubi->mtd) / 100) * 5, UBI_FM_MAX_POOL_SIZE);
967 if (!ubi->fm_disabled && (int)mtd_div_by_eb(ubi->mtd->size, ubi->mtd)
987 ubi_msg(ubi, "attaching mtd%d", mtd->index);
1006 ubi_err(ubi, "failed to attach mtd%d, error %d",
1007 mtd->index, err);
1033 ubi_msg(ubi, "attached mtd%d (name \"%s\", size %llu MiB)",
1034 mtd->index, mtd->name, ubi->flash_size >> 20);
1127 ubi_msg(ubi, "detaching mtd%d", ubi->mtd->index);
1154 ubi_msg(ubi, "mtd%d is detached", ubi->mtd->index);
1155 put_mtd_device(ubi->mtd);
1212 struct mtd_info *mtd;
1222 mtd = get_mtd_device_nm(mtd_dev);
1223 if (PTR_ERR(mtd) == -ENODEV)
1225 mtd = open_mtd_by_chdev(mtd_dev);
1227 mtd = get_mtd_device(NULL, mtd_num);
1229 return mtd;
1232 static void ubi_notify_add(struct mtd_info *mtd)
1234 struct device_node *np = mtd_get_of_node(mtd);
1244 err = __get_mtd_device(mtd);
1250 err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 0, 0, false, false);
1253 __put_mtd_device(mtd);
1256 static void ubi_notify_remove(struct mtd_info *mtd)
1273 struct mtd_info *mtd;
1277 mtd = open_mtd_device(p->name);
1278 if (IS_ERR(mtd)) {
1279 err = PTR_ERR(mtd);
1280 pr_err("UBI error: cannot open mtd %s, error %d\n",
1289 err = ubi_attach_mtd_dev(mtd, p->ubi_num,
1295 pr_err("UBI error: cannot attach mtd%d\n",
1296 mtd->index);
1297 put_mtd_device(mtd);
1461 * ubi_mtd_param_parse - parse the 'mtd=' UBI parameter.
1493 pr_warn("UBI warning: empty 'mtd=' parameter - ignored\n");
1573 module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 0400);
1574 MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n"
1575 "Multiple \"mtd\" parameters may be specified.\n"
1584 "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n"
1585 "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n"
1586 "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n"
1587 "Example 4: mtd=/dev/mtd1,0,0,5 - attach MTD device /dev/mtd1 to UBI 5 and using default values for the other fields.\n"
1588 "example 5: mtd=1,0,0,5 mtd=2,0,0,6,1 - attach MTD device /dev/mtd1 to UBI 5 and disable fastmap; attach MTD device /dev/mtd2 to UBI 6 and enable fastmap.(only works when fastmap is enabled and fm_autoconvert=Y).\n"