static void mtd_concat_add_work(struct work_struct *work) { struct mtd_info *mtd; mtd = mtd_concat_create(concat_devs, ARRAY_SIZE(concat_devs), "flash"); mtd_device_register(mtd, multi_pdata->parts, multi_pdata->nr_parts); }
static struct mtd_info *flash_probe(void) { struct mtd_info *mtd_cse0; struct mtd_info *mtd_cse1; struct mtd_info *mtd_nand = NULL; struct mtd_info *mtd_total; struct mtd_info *mtds[3]; int count = 0; if ((mtd_cse0 = probe_cs(&map_cse0)) != NULL) mtds[count++] = mtd_cse0; if ((mtd_cse1 = probe_cs(&map_cse1)) != NULL) mtds[count++] = mtd_cse1; #ifdef CONFIG_ETRAX_NANDFLASH if ((mtd_nand = crisv32_nand_flash_probe()) != NULL) mtds[count++] = mtd_nand; #endif if (!mtd_cse0 && !mtd_cse1 && !mtd_nand) { /* No chip found. */ return NULL; } if (count > 1) { #ifdef CONFIG_MTD_CONCAT /* Since the concatenation layer adds a small overhead we * could try to figure out if the chips in cse0 and cse1 are * identical and reprobe the whole cse0+cse1 window. But since * flash chips are slow, the overhead is relatively small. * So we use the MTD concatenation layer instead of further * complicating the probing procedure. */ mtd_total = mtd_concat_create(mtds, count, "cse0+cse1+nand"); #else printk(KERN_ERR "%s and %s: Cannot concatenate due to kernel " "(mis)configuration!\n", map_cse0.name, map_cse1.name); mtd_toal = NULL; #endif if (!mtd_total) { printk(KERN_ERR "%s and %s: Concatenation failed!\n", map_cse0.name, map_cse1.name); /* The best we can do now is to only use what we found * at cse0. */ mtd_total = mtd_cse0; map_destroy(mtd_cse1); } } else { mtd_total = mtd_cse0? mtd_cse0 : mtd_cse1 ? mtd_cse1 : mtd_nand; } return mtd_total; }
static void mtd_concat_add_work(struct work_struct *work) { struct mtd_info *mtd; mtd = mtd_concat_create(concat_devs, ARRAY_SIZE(concat_devs), "flash"); mtd_device_register(mtd, wzrhpag300h_flash_partitions, ARRAY_SIZE(wzrhpag300h_flash_partitions)); }
static int __init init_sc520cdp(void) { int i, devices_found = 0; #ifdef REPROGRAM_PAR /* reprogram PAR registers so flash appears at the desired addresses */ sc520cdp_setup_par(); #endif for (i = 0; i < NUM_FLASH_BANKS; i++) { #ifdef CONFIG_DEBUG_PRINTK printk(KERN_NOTICE "SC520 CDP flash device: 0x%Lx at 0x%Lx\n", (unsigned long long)sc520cdp_map[i].size, (unsigned long long)sc520cdp_map[i].phys); #else ; #endif sc520cdp_map[i].virt = ioremap_nocache(sc520cdp_map[i].phys, sc520cdp_map[i].size); if (!sc520cdp_map[i].virt) { #ifdef CONFIG_DEBUG_PRINTK printk("Failed to ioremap_nocache\n"); #else ; #endif return -EIO; } simple_map_init(&sc520cdp_map[i]); mymtd[i] = do_map_probe("cfi_probe", &sc520cdp_map[i]); if(!mymtd[i]) mymtd[i] = do_map_probe("jedec_probe", &sc520cdp_map[i]); if(!mymtd[i]) mymtd[i] = do_map_probe("map_rom", &sc520cdp_map[i]); if (mymtd[i]) { mymtd[i]->owner = THIS_MODULE; ++devices_found; } else { iounmap(sc520cdp_map[i].virt); } } if(devices_found >= 2) { /* Combine the two flash banks into a single MTD device & register it: */ merged_mtd = mtd_concat_create(mymtd, 2, "SC520CDP Flash Banks #0 and #1"); if(merged_mtd) mtd_device_register(merged_mtd, NULL, 0); } if(devices_found == 3) /* register the third (DIL-Flash) device */ mtd_device_register(mymtd[2], NULL, 0); return(devices_found ? 0 : -ENXIO); }
/* * Probe each chip select individually for flash chips. If there are chips on * both cse0 and cse1, the mtd_info structs will be concatenated to one struct * so that MTD partitions can cross chip boundries. * * The only known restriction to how you can mount your chips is that each * chip select must hold similar flash chips. But you need external hardware * to do that anyway and you can put totally different chips on cse0 and cse1 * so it isn't really much of a restriction. */ static struct mtd_info *flash_probe(void) { struct mtd_info *mtd_cse0; struct mtd_info *mtd_cse1; struct mtd_info *mtd_cse; mtd_cse0 = probe_cs(&map_cse0); mtd_cse1 = probe_cs(&map_cse1); if (!mtd_cse0 && !mtd_cse1) { /* No chip found. */ return NULL; } if (mtd_cse0 && mtd_cse1) { #ifdef CONFIG_MTD_CONCAT struct mtd_info *mtds[] = { mtd_cse0, mtd_cse1 }; /* Since the concatenation layer adds a small overhead we * could try to figure out if the chips in cse0 and cse1 are * identical and reprobe the whole cse0+cse1 window. But since * flash chips are slow, the overhead is relatively small. * So we use the MTD concatenation layer instead of further * complicating the probing procedure. */ mtd_cse = mtd_concat_create(mtds, sizeof(mtds) / sizeof(mtds[0]), "cse0+cse1"); #else printk(KERN_ERR "%s and %s: Cannot concatenate due to kernel " "(mis)configuration!\n", map_cse0.name, map_cse1.name); mtd_cse = NULL; #endif if (!mtd_cse) { printk(KERN_ERR "%s and %s: Concatenation failed!\n", map_cse0.name, map_cse1.name); /* The best we can do now is to only use what we found * at cse0. */ mtd_cse = mtd_cse0; map_destroy(mtd_cse1); } } else { mtd_cse = mtd_cse0? mtd_cse0 : mtd_cse1; } return mtd_cse; }
static struct mtd_info *flash_probe(void) { struct mtd_info *mtd_cse0; struct mtd_info *mtd_cse1; struct mtd_info *mtd_total; struct mtd_info *mtds[2]; int count = 0; if ((mtd_cse0 = probe_cs(&map_cse0)) != NULL) mtds[count++] = mtd_cse0; if ((mtd_cse1 = probe_cs(&map_cse1)) != NULL) mtds[count++] = mtd_cse1; if (!mtd_cse0 && !mtd_cse1) { /* No chip found. */ return NULL; } if (count > 1) { /* Since the concatenation layer adds a small overhead we * could try to figure out if the chips in cse0 and cse1 are * identical and reprobe the whole cse0+cse1 window. But since * flash chips are slow, the overhead is relatively small. * So we use the MTD concatenation layer instead of further * complicating the probing procedure. */ mtd_total = mtd_concat_create(mtds, count, "cse0+cse1"); if (!mtd_total) { printk(KERN_ERR "%s and %s: Concatenation failed!\n", map_cse0.name, map_cse1.name); /* The best we can do now is to only use what we found * at cse0. */ mtd_total = mtd_cse0; map_destroy(mtd_cse1); } } else mtd_total = mtd_cse0 ? mtd_cse0 : mtd_cse1; return mtd_total; }
static int __init init_ppmc280(void) { int dev_cnt = 0, i = 0; for (i = 0; i < NUM_FLASH_BANKS; i++) { printk(KERN_NOTICE "PPMC280 flash device: 0x%lx at 0x%lx\n", ppmc280_map[i].size, ppmc280_map[i].phys); ppmc280_map[i].virt = ioremap_nocache(ppmc280_map[i].phys, ppmc280_map[i].size); if (!ppmc280_map[i].virt) { printk("Failed to ioremap_nocache\n"); return -EIO; } simple_map_init(&ppmc280_map[i]); flash[i] = do_map_probe("cfi_probe", &ppmc280_map[i]); if(!flash[i]) flash[i] = do_map_probe("jedec_probe", &ppmc280_map[i]); if(!flash[i]) flash[i] = do_map_probe("map_rom", &ppmc280_map[i]); if (flash[i]) { flash[i]->owner = THIS_MODULE; ++dev_cnt; } else { iounmap((void *)ppmc280_map[i].virt); } } if(dev_cnt >= 2) { /* Combine the two flash banks into a single MTD device & register it: */ if(NULL != (chunk = mtd_concat_create(flash, 2, "PPMC280 Flash Banks 0 and 1"))) { add_mtd_device(chunk); add_mtd_partitions(chunk, ppmc280_part, ARRAY_SIZE(ppmc280_part)); } } return(dev_cnt ? 0 : -ENXIO); }
static int physmap_flash_probe(struct platform_device *dev) { struct physmap_flash_data *physmap_data; struct physmap_flash_info *info; const char **probe_type; int err = 0; int i; int devices_found = 0; physmap_data = dev->dev.platform_data; if (physmap_data == NULL) return -ENODEV; info = devm_kzalloc(&dev->dev, sizeof(struct physmap_flash_info), GFP_KERNEL); if (info == NULL) { err = -ENOMEM; goto err_out; } if (physmap_data->init) { err = physmap_data->init(dev); if (err) goto err_out; } platform_set_drvdata(dev, info); for (i = 0; i < dev->num_resources; i++) { // printk(KERN_NOTICE "physmap platform flash device: %.8llx at %.8llx\n", // (unsigned long long)resource_size(&dev->resource[i]), ; if (!devm_request_mem_region(&dev->dev, dev->resource[i].start, resource_size(&dev->resource[i]), dev_name(&dev->dev))) { dev_err(&dev->dev, "Could not reserve memory region\n"); err = -ENOMEM; goto err_out; } info->map[i].name = dev_name(&dev->dev); info->map[i].phys = dev->resource[i].start; info->map[i].size = resource_size(&dev->resource[i]); info->map[i].bankwidth = physmap_data->width; info->map[i].set_vpp = physmap_set_vpp; info->map[i].pfow_base = physmap_data->pfow_base; info->map[i].map_priv_1 = (unsigned long)dev; info->map[i].virt = devm_ioremap(&dev->dev, info->map[i].phys, info->map[i].size); if (info->map[i].virt == NULL) { dev_err(&dev->dev, "Failed to ioremap flash region\n"); err = -EIO; goto err_out; } simple_map_init(&info->map[i]); probe_type = rom_probe_types; if (physmap_data->probe_type == NULL) { for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++) info->mtd[i] = do_map_probe(*probe_type, &info->map[i]); } else info->mtd[i] = do_map_probe(physmap_data->probe_type, &info->map[i]); if (info->mtd[i] == NULL) { dev_err(&dev->dev, "map_probe failed\n"); err = -ENXIO; goto err_out; } else { devices_found++; } info->mtd[i]->owner = THIS_MODULE; info->mtd[i]->dev.parent = &dev->dev; } if (devices_found == 1) { info->cmtd = info->mtd[0]; } else if (devices_found > 1) { /* * We detected multiple devices. Concatenate them together. */ info->cmtd = mtd_concat_create(info->mtd, devices_found, dev_name(&dev->dev)); if (info->cmtd == NULL) err = -ENXIO; } if (err) goto err_out; err = parse_mtd_partitions(info->cmtd, part_probe_types, &info->parts, 0); if (err > 0) { mtd_device_register(info->cmtd, info->parts, err); info->nr_parts = err; return 0; } if (physmap_data->nr_parts) { ; mtd_device_register(info->cmtd, physmap_data->parts, physmap_data->nr_parts); return 0; } mtd_device_register(info->cmtd, NULL, 0); return 0; err_out: physmap_flash_remove(dev); return err; }
static int __devinit of_flash_probe(struct platform_device *dev, const struct of_device_id *match) { #ifdef CONFIG_MTD_PARTITIONS const char **part_probe_types; #endif struct device_node *dp = dev->dev.of_node; struct resource res; struct of_flash *info; const char *probe_type = match->data; const u32 *width; int err; int i; int count; const u32 *p; int reg_tuple_size; struct mtd_info **mtd_list = NULL; resource_size_t res_size; reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32); /* * Get number of "reg" tuples. Scan for MTD devices on area's * described by each "reg" region. This makes it possible (including * the concat support) to support the Intel P30 48F4400 chips which * consists internally of 2 non-identical NOR chips on one die. */ p = of_get_property(dp, "reg", &count); if (count % reg_tuple_size != 0) { dev_err(&dev->dev, "Malformed reg property on %s\n", dev->dev.of_node->full_name); err = -EINVAL; goto err_flash_remove; } count /= reg_tuple_size; err = -ENOMEM; info = kzalloc(sizeof(struct of_flash) + sizeof(struct of_flash_list) * count, GFP_KERNEL); if (!info) goto err_flash_remove; dev_set_drvdata(&dev->dev, info); mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL); if (!mtd_list) goto err_flash_remove; for (i = 0; i < count; i++) { err = -ENXIO; if (of_address_to_resource(dp, i, &res)) { dev_err(&dev->dev, "Can't get IO address from device" " tree\n"); goto err_out; } dev_dbg(&dev->dev, "of_flash device: %.8llx-%.8llx\n", (unsigned long long)res.start, (unsigned long long)res.end); err = -EBUSY; res_size = resource_size(&res); info->list[i].res = request_mem_region(res.start, res_size, dev_name(&dev->dev)); if (!info->list[i].res) goto err_out; err = -ENXIO; width = of_get_property(dp, "bank-width", NULL); if (!width) { dev_err(&dev->dev, "Can't get bank width from device" " tree\n"); goto err_out; } info->list[i].map.name = dev_name(&dev->dev); info->list[i].map.phys = res.start; info->list[i].map.size = res_size; info->list[i].map.bankwidth = *width; err = -ENOMEM; info->list[i].map.virt = ioremap(info->list[i].map.phys, info->list[i].map.size); if (!info->list[i].map.virt) { dev_err(&dev->dev, "Failed to ioremap() flash" " region\n"); goto err_out; } simple_map_init(&info->list[i].map); if (probe_type) { info->list[i].mtd = do_map_probe(probe_type, &info->list[i].map); } else { info->list[i].mtd = obsolete_probe(dev, &info->list[i].map); } mtd_list[i] = info->list[i].mtd; err = -ENXIO; if (!info->list[i].mtd) { dev_err(&dev->dev, "do_map_probe() failed\n"); goto err_out; } else { info->list_size++; } info->list[i].mtd->owner = THIS_MODULE; info->list[i].mtd->dev.parent = &dev->dev; } err = 0; if (info->list_size == 1) { info->cmtd = info->list[0].mtd; } else if (info->list_size > 1) { /* * We detected multiple devices. Concatenate them together. */ #ifdef CONFIG_MTD_CONCAT info->cmtd = mtd_concat_create(mtd_list, info->list_size, dev_name(&dev->dev)); if (info->cmtd == NULL) err = -ENXIO; #else printk(KERN_ERR "physmap_of: multiple devices " "found but MTD concat support disabled.\n"); err = -ENXIO; #endif } if (err) goto err_out; #ifdef CONFIG_MTD_PARTITIONS part_probe_types = of_get_probes(dp); err = parse_mtd_partitions(info->cmtd, part_probe_types, &info->parts, 0); if (err < 0) { of_free_probes(part_probe_types); goto err_out; } of_free_probes(part_probe_types); #ifdef CONFIG_MTD_OF_PARTS if (err == 0) { err = of_mtd_parse_partitions(&dev->dev, dp, &info->parts); if (err < 0) goto err_out; } #endif if (err == 0) { err = parse_obsolete_partitions(dev, info, dp); if (err < 0) goto err_out; } if (err > 0) add_mtd_partitions(info->cmtd, info->parts, err); else #endif add_mtd_device(info->cmtd); kfree(mtd_list); return 0; err_out: kfree(mtd_list); err_flash_remove: of_flash_remove(dev); return err; }
static int physmap_flash_probe(struct platform_device *dev) { struct physmap_flash_data *physmap_data; struct physmap_flash_info *info; const char **probe_type; int err = 0; int i; int devices_found = 0; physmap_data = dev->dev.platform_data; if (physmap_data == NULL) return -ENODEV; info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL); if (info == NULL) { err = -ENOMEM; goto err_out; } platform_set_drvdata(dev, info); for (i = 0; i < dev->num_resources; i++) { printk(KERN_NOTICE "physmap platform flash device: %.8llx at %.8llx\n", (unsigned long long)(dev->resource[i].end - dev->resource[i].start + 1), (unsigned long long)dev->resource[i].start); info->res = request_mem_region(dev->resource[i].start, dev->resource[i].end - dev->resource[i].start + 1, dev->dev.bus_id); if (info->res == NULL) { dev_err(&dev->dev, "Could not reserve memory region\n"); err = -ENOMEM; goto err_out; } info->map[i].name = dev->dev.bus_id; info->map[i].phys = dev->resource[i].start; info->map[i].size = dev->resource[i].end - dev->resource[i].start + 1; info->map[i].bankwidth = physmap_data->width; info->map[i].set_vpp = physmap_data->set_vpp; info->map[i].virt = ioremap(info->map[i].phys, info->map[i].size); if (info->map[i].virt == NULL) { dev_err(&dev->dev, "Failed to ioremap flash region\n"); err = EIO; goto err_out; } simple_map_init(&info->map[i]); probe_type = rom_probe_types; for (; info->mtd[i] == NULL && *probe_type != NULL; probe_type++) info->mtd[i] = do_map_probe(*probe_type, &info->map[i]); if (info->mtd[i] == NULL) { dev_err(&dev->dev, "map_probe failed\n"); err = -ENXIO; goto err_out; } else { devices_found++; } info->mtd[i]->owner = THIS_MODULE; } if (devices_found == 1) { info->cmtd = info->mtd[0]; } else if (devices_found > 1) { /* * We detected multiple devices. Concatenate them together. */ #ifdef CONFIG_MTD_CONCAT info->cmtd = mtd_concat_create(info->mtd, devices_found, dev->dev.bus_id); if (info->cmtd == NULL) err = -ENXIO; #else printk(KERN_ERR "physmap-flash: multiple devices " "found but MTD concat support disabled.\n"); err = -ENXIO; #endif } if (err) goto err_out; #ifdef CONFIG_MTD_PARTITIONS err = parse_mtd_partitions(info->cmtd, part_probe_types, &info->parts, 0); if (err > 0) { add_mtd_partitions(info->cmtd, info->parts, err); return 0; } if (physmap_data->nr_parts) { printk(KERN_NOTICE "Using physmap partition information\n"); add_mtd_partitions(info->cmtd, physmap_data->parts, physmap_data->nr_parts); return 0; } #endif add_mtd_device(info->cmtd); return 0; err_out: physmap_flash_remove(dev); return err; }
static int __init init_dnpc(void) { int is_dnp; /* ** determine hardware (DNP/ADNP/invalid) */ if((is_dnp = dnp_adnp_probe()) < 0) return -ENXIO; /* ** Things are set up for ADNP by default ** -> modify all that needs to be different for DNP */ if(is_dnp) { /* ** Adjust window size, select correct set_vpp function. ** The partitioning scheme is identical on both DNP ** and ADNP except for the size of the third partition. */ int i; dnpc_map.size = DNP_WINDOW_SIZE; dnpc_map.set_vpp = dnp_set_vpp; partition_info[2].size = 0xf0000; /* ** increment all string pointers so the leading 'A' gets skipped, ** thus turning all occurrences of "ADNP ..." into "DNP ..." */ ++dnpc_map.name; for(i = 0; i < NUM_PARTITIONS; i++) ++partition_info[i].name; higlvl_partition_info[1].size = DNP_WINDOW_SIZE - CONFIG_MTD_DILNETPC_BOOTSIZE - 0x20000; for(i = 0; i < NUM_HIGHLVL_PARTITIONS; i++) ++higlvl_partition_info[i].name; } printk(KERN_NOTICE "DIL/Net %s flash: 0x%lx at 0x%llx\n", is_dnp ? "DNPC" : "ADNP", dnpc_map.size, (unsigned long long)dnpc_map.phys); dnpc_map.virt = ioremap_nocache(dnpc_map.phys, dnpc_map.size); dnpc_map_flash(dnpc_map.phys, dnpc_map.size); if (!dnpc_map.virt) { printk("Failed to ioremap_nocache\n"); return -EIO; } simple_map_init(&dnpc_map); printk("FLASH virtual address: 0x%p\n", dnpc_map.virt); mymtd = do_map_probe("jedec_probe", &dnpc_map); if (!mymtd) mymtd = do_map_probe("cfi_probe", &dnpc_map); /* ** If flash probes fail, try to make flashes accessible ** at least as ROM. Ajust erasesize in this case since ** the default one (128M) will break our partitioning */ if (!mymtd) if((mymtd = do_map_probe("map_rom", &dnpc_map))) mymtd->erasesize = 0x10000; if (!mymtd) { iounmap(dnpc_map.virt); return -ENXIO; } mymtd->owner = THIS_MODULE; /* ** Supply pointers to lowlvl_parts[] array to add_mtd_partitions() ** -> add_mtd_partitions() will _not_ register MTD devices for ** the partitions, but will instead store pointers to the MTD ** objects it creates into our lowlvl_parts[] array. ** NOTE: we arrange the pointers such that the sequence of the ** partitions gets re-arranged: partition #2 follows ** partition #0. */ partition_info[0].mtdp = &lowlvl_parts[0]; partition_info[1].mtdp = &lowlvl_parts[2]; partition_info[2].mtdp = &lowlvl_parts[1]; partition_info[3].mtdp = &lowlvl_parts[3]; add_mtd_partitions(mymtd, partition_info, NUM_PARTITIONS); /* ** now create a virtual MTD device by concatenating the for partitions ** (in the sequence given by the lowlvl_parts[] array. */ merged_mtd = mtd_concat_create(lowlvl_parts, NUM_PARTITIONS, "(A)DNP Flash Concatenated"); if(merged_mtd) { /* ** now partition the new device the way we want it. This time, ** we do not supply mtd pointers in higlvl_partition_info, so ** add_mtd_partitions() will register the devices. */ add_mtd_partitions(merged_mtd, higlvl_partition_info, NUM_HIGHLVL_PARTITIONS); } return 0; }
static int of_flash_probe(struct platform_device *dev) { const char * const *part_probe_types; const struct of_device_id *match; struct device_node *dp = dev->dev.of_node; struct resource res; struct of_flash *info; const char *probe_type; const __be32 *width; int err; int i; int count; const __be32 *p; int reg_tuple_size; struct mtd_info **mtd_list = NULL; resource_size_t res_size; struct mtd_part_parser_data ppdata; bool map_indirect; const char *mtd_name = NULL; match = of_match_device(of_flash_match, &dev->dev); if (!match) return -EINVAL; probe_type = match->data; reg_tuple_size = (of_n_addr_cells(dp) + of_n_size_cells(dp)) * sizeof(u32); of_property_read_string(dp, "linux,mtd-name", &mtd_name); /* * Get number of "reg" tuples. Scan for MTD devices on area's * described by each "reg" region. This makes it possible (including * the concat support) to support the Intel P30 48F4400 chips which * consists internally of 2 non-identical NOR chips on one die. */ p = of_get_property(dp, "reg", &count); if (count % reg_tuple_size != 0) { dev_err(&dev->dev, "Malformed reg property on %s\n", dev->dev.of_node->full_name); err = -EINVAL; goto err_flash_remove; } count /= reg_tuple_size; map_indirect = of_property_read_bool(dp, "no-unaligned-direct-access"); err = -ENOMEM; info = devm_kzalloc(&dev->dev, sizeof(struct of_flash) + sizeof(struct of_flash_list) * count, GFP_KERNEL); if (!info) goto err_flash_remove; dev_set_drvdata(&dev->dev, info); mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL); if (!mtd_list) goto err_flash_remove; for (i = 0; i < count; i++) { err = -ENXIO; if (of_address_to_resource(dp, i, &res)) { /* * Continue with next register tuple if this * one is not mappable */ continue; } dev_dbg(&dev->dev, "of_flash device: %pR\n", &res); err = -EBUSY; res_size = resource_size(&res); info->list[i].res = request_mem_region(res.start, res_size, dev_name(&dev->dev)); if (!info->list[i].res) goto err_out; err = -ENXIO; width = of_get_property(dp, "bank-width", NULL); if (!width) { dev_err(&dev->dev, "Can't get bank width from device" " tree\n"); goto err_out; } info->list[i].map.name = mtd_name ?: dev_name(&dev->dev); info->list[i].map.phys = res.start; info->list[i].map.size = res_size; info->list[i].map.bankwidth = be32_to_cpup(width); info->list[i].map.device_node = dp; err = -ENOMEM; info->list[i].map.virt = ioremap(info->list[i].map.phys, info->list[i].map.size); if (!info->list[i].map.virt) { dev_err(&dev->dev, "Failed to ioremap() flash" " region\n"); goto err_out; } simple_map_init(&info->list[i].map); /* * On some platforms (e.g. MPC5200) a direct 1:1 mapping * may cause problems with JFFS2 usage, as the local bus (LPB) * doesn't support unaligned accesses as implemented in the * JFFS2 code via memcpy(). By setting NO_XIP, the * flash will not be exposed directly to the MTD users * (e.g. JFFS2) any more. */ if (map_indirect) info->list[i].map.phys = NO_XIP; if (probe_type) { info->list[i].mtd = do_map_probe(probe_type, &info->list[i].map); } else { info->list[i].mtd = obsolete_probe(dev, &info->list[i].map); } mtd_list[i] = info->list[i].mtd; err = -ENXIO; if (!info->list[i].mtd) { dev_err(&dev->dev, "do_map_probe() failed\n"); goto err_out; } else { info->list_size++; } info->list[i].mtd->owner = THIS_MODULE; info->list[i].mtd->dev.parent = &dev->dev; } err = 0; info->cmtd = NULL; if (info->list_size == 1) { info->cmtd = info->list[0].mtd; } else if (info->list_size > 1) { /* * We detected multiple devices. Concatenate them together. */ info->cmtd = mtd_concat_create(mtd_list, info->list_size, dev_name(&dev->dev)); } if (info->cmtd == NULL) err = -ENXIO; if (err) goto err_out; ppdata.of_node = dp; part_probe_types = of_get_probes(dp); mtd_device_parse_register(info->cmtd, part_probe_types, &ppdata, NULL, 0); of_free_probes(part_probe_types); kfree(mtd_list); return 0; err_out: kfree(mtd_list); err_flash_remove: of_flash_remove(dev); return err; }