static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return; dev->mtd = mtd; dev->devnum = mtd->index; dev->size = mtd->size >> 9; dev->tr = tr; if (!(mtd->flags & MTD_WRITEABLE)) dev->readonly = 1; #ifdef CONFIG_ARCH_MV88DE3010 if (mtd->name && strcmp(mtd->name, "mv_nand")) { add_mtd_blktrans_dev(dev); } #else add_mtd_blktrans_dev(dev); #endif }
static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return; dev->mtd = mtd; dev->devnum = mtd->index; dev->size = mtd->size >> 9; dev->tr = tr; dev->readonly = 1; add_mtd_blktrans_dev(dev); }
static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct partition *part; if (mtd->type != MTD_NORFLASH) return; part = kcalloc(1, sizeof(struct partition), GFP_KERNEL); if (!part) return; part->mbd.mtd = mtd; if (block_size) part->block_size = block_size; else { if (!mtd->erasesize) { printk(KERN_NOTICE PREFIX "please provide block_size"); return; } else part->block_size = mtd->erasesize; } if (scan_header(part) == 0) { part->mbd.size = part->sector_count; part->mbd.blksize = SECTOR_SIZE; part->mbd.tr = tr; part->mbd.devnum = -1; if (!(mtd->flags & MTD_WRITEABLE)) part->mbd.readonly = 1; else if (part->errors) { printk(KERN_NOTICE PREFIX "'%s': errors found, " "setting read-only", mtd->name); part->mbd.readonly = 1; } printk(KERN_INFO PREFIX "name: '%s' type: %d flags %x\n", mtd->name, mtd->type, mtd->flags); if (!add_mtd_blktrans_dev((void*)part)) return; } kfree(part); }
static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct mtdblk_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return; dev->mbd.mtd = mtd; dev->mbd.devnum = mtd->index; dev->mbd.size = mtd->size >> 9; dev->mbd.tr = tr; if (!(mtd->flags & MTD_WRITEABLE)) dev->mbd.readonly = 1; if (add_mtd_blktrans_dev(&dev->mbd)) kfree(dev); }
static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct innotab_blockro *blockro = vmalloc(sizeof(struct innotab_blockro)+MTD_BBT_BLOCK_SIZE);//kzalloc(sizeof(struct innotab_blockro), GFP_KERNEL); struct mtd_blktrans_dev *dev; if (!blockro) return; memset( blockro, 0, sizeof(struct innotab_blockro) ); sema_init( &blockro->open_lock, 1 ); blockro->open_cnt = 0; // For clarity. In theory redundant since we've memset() the whole structure to 0x00 before. blockro->bbt_buf = (char *)(&blockro[1]); memset( blockro->bbt_buf, 0, MTD_BBT_BLOCK_SIZE ); blockro->logical_offset = 0; // For clarity. In theory redundant since we've memset() the whole structure to 0x00 before. dev = &blockro->dev; dev->mtd = mtd; dev->devnum = mtd->index; dev->size = mtd->size >> 9; dev->tr = tr; dev->readonly = 1; blockro->map.numOfGoodBlock = -1; blockro->map.logicalToPhysical = vmalloc( sizeof(int) * (((unsigned int)mtd->size)/mtd->erasesize) );//kzalloc( sizeof(int) * (((unsigned int)mtd->size)/mtd->erasesize), GFP_KERNEL); if ( blockro->map.logicalToPhysical == NULL ) { printk ( "%s() - %d: Allocation for logical to physical mapping failed!\n", __PRETTY_FUNCTION__, __LINE__ ); vfree(blockro); return; } /* memset( blockro->map.logicalToPhysical, 0, sizeof(int) * (((unsigned int)mtd->size)/mtd->erasesize) ); if ( rescan_logic_to_phys_table( mtd, &blockro->map ) ) { vfree(blockro->map.logicalToPhysical); vfree(blockro); return; } */ add_mtd_blktrans_dev(dev); }
static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return; memset(dev, 0, sizeof(*dev)); dev->mtd = mtd; dev->devnum = mtd->index; dev->blksize = 512; dev->size = mtd->size >> 9; dev->tr = tr; if (!(mtd->flags & MTD_WRITEABLE)) dev->readonly = 1; add_mtd_blktrans_dev(dev); }
static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct mtdblock_priv *priv = kzalloc(sizeof(*priv), GFP_KERNEL); struct mtd_blktrans_dev *dev; if (!priv) return; dev = &priv->dev; dev->mtd = mtd; dev->devnum = mtd->index; dev->size = mtd->size >> 9; dev->tr = tr; if (!(mtd->flags & MTD_WRITEABLE)) dev->readonly = 1; if (unlikely(mtdblock_bb_init(priv))) { kfree(priv); return; } add_mtd_blktrans_dev(dev); }
static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct NFTLrecord *nftl; unsigned long temp; if (mtd->type != MTD_NANDFLASH) return; /* OK, this is moderately ugly. But probably safe. Alternatives? */ if (memcmp(mtd->name, "DiskOnChip", 10)) return; if (!mtd->block_isbad) { printk(KERN_ERR "NFTL no longer supports the old DiskOnChip drivers loaded via docprobe.\n" "Please use the new diskonchip driver under the NAND subsystem.\n"); return; } DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name); nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL); if (!nftl) { printk(KERN_WARNING "NFTL: out of memory for data structures\n"); return; } memset(nftl, 0, sizeof(*nftl)); nftl->mbd.mtd = mtd; nftl->mbd.devnum = -1; nftl->mbd.blksize = 512; nftl->mbd.tr = tr; memcpy(&nftl->oobinfo, &mtd->oobinfo, sizeof(struct nand_oobinfo)); nftl->oobinfo.useecc = MTD_NANDECC_PLACEONLY; if (NFTL_mount(nftl) < 0) { printk(KERN_WARNING "NFTL: could not mount device\n"); kfree(nftl); return; } /* OK, it's a new one. Set up all the data structures. */ /* Calculate geometry */ nftl->cylinders = 1024; nftl->heads = 16; temp = nftl->cylinders * nftl->heads; nftl->sectors = nftl->mbd.size / temp; if (nftl->mbd.size % temp) { nftl->sectors++; temp = nftl->cylinders * nftl->sectors; nftl->heads = nftl->mbd.size / temp; if (nftl->mbd.size % temp) { nftl->heads++; temp = nftl->heads * nftl->sectors; nftl->cylinders = nftl->mbd.size / temp; } } if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) { /* Oh no we don't have mbd.size == heads * cylinders * sectors */ printk(KERN_WARNING "NFTL: cannot calculate a geometry to " "match size of 0x%lx.\n", nftl->mbd.size); printk(KERN_WARNING "NFTL: using C:%d H:%d S:%d " "(== 0x%lx sects)\n", nftl->cylinders, nftl->heads , nftl->sectors, (long)nftl->cylinders * (long)nftl->heads * (long)nftl->sectors ); } if (add_mtd_blktrans_dev(&nftl->mbd)) { if (nftl->ReplUnitTable) kfree(nftl->ReplUnitTable); if (nftl->EUNtable) kfree(nftl->EUNtable); kfree(nftl); return; } #ifdef PSYCHO_DEBUG printk(KERN_INFO "NFTL: Found new nftl%c\n", nftl->mbd.devnum + 'a'); #endif }
static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct INFTLrecord *inftl; unsigned long temp; if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX) return; /* OK, this is moderately ugly. But probably safe. Alternatives? */ if (memcmp(mtd->name, "DiskOnChip", 10)) return; if (!mtd->block_isbad) { printk(KERN_ERR "INFTL no longer supports the old DiskOnChip drivers loaded via docprobe.\n" "Please use the new diskonchip driver under the NAND subsystem.\n"); return; } DEBUG(MTD_DEBUG_LEVEL3, "INFTL: add_mtd for %s\n", mtd->name); inftl = kzalloc(sizeof(*inftl), GFP_KERNEL); if (!inftl) { printk(KERN_WARNING "INFTL: Out of memory for data structures\n"); return; } inftl->mbd.mtd = mtd; inftl->mbd.devnum = -1; inftl->mbd.tr = tr; if (INFTL_mount(inftl) < 0) { printk(KERN_WARNING "INFTL: could not mount device\n"); kfree(inftl); return; } /* OK, it's a new one. Set up all the data structures. */ /* Calculate geometry */ inftl->cylinders = 1024; inftl->heads = 16; temp = inftl->cylinders * inftl->heads; inftl->sectors = inftl->mbd.size / temp; if (inftl->mbd.size % temp) { inftl->sectors++; temp = inftl->cylinders * inftl->sectors; inftl->heads = inftl->mbd.size / temp; if (inftl->mbd.size % temp) { inftl->heads++; temp = inftl->heads * inftl->sectors; inftl->cylinders = inftl->mbd.size / temp; } } if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) { /* Oh no we don't have mbd.size == heads * cylinders * sectors */ printk(KERN_WARNING "INFTL: cannot calculate a geometry to " "match size of 0x%lx.\n", inftl->mbd.size); printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d " "(== 0x%lx sects)\n", inftl->cylinders, inftl->heads , inftl->sectors, (long)inftl->cylinders * (long)inftl->heads * (long)inftl->sectors ); } if (add_mtd_blktrans_dev(&inftl->mbd)) { kfree(inftl->PUtable); kfree(inftl->VUtable); kfree(inftl); return; } #ifdef PSYCHO_DEBUG printk(KERN_INFO "INFTL: Found new inftl%c\n", inftl->mbd.devnum + 'a'); #endif return; }
static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct NFTLrecord *nftl; unsigned long temp; if (mtd->ecctype != MTD_ECC_RS_DiskOnChip) return; DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name); nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL); if (!nftl) { printk(KERN_WARNING "NFTL: out of memory for data structures\n"); return; } memset(nftl, 0, sizeof(*nftl)); nftl->mbd.mtd = mtd; nftl->mbd.devnum = -1; nftl->mbd.blksize = 512; nftl->mbd.tr = tr; if (NFTL_mount(nftl) < 0) { printk(KERN_WARNING "NFTL: could not mount device\n"); kfree(nftl); return; } /* OK, it's a new one. Set up all the data structures. */ /* Calculate geometry */ nftl->cylinders = 1024; nftl->heads = 16; temp = nftl->cylinders * nftl->heads; nftl->sectors = nftl->mbd.size / temp; if (nftl->mbd.size % temp) { nftl->sectors++; temp = nftl->cylinders * nftl->sectors; nftl->heads = nftl->mbd.size / temp; if (nftl->mbd.size % temp) { nftl->heads++; temp = nftl->heads * nftl->sectors; nftl->cylinders = nftl->mbd.size / temp; } } if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) { /* Oh no we don't have mbd.size == heads * cylinders * sectors */ printk(KERN_WARNING "NFTL: cannot calculate a geometry to " "match size of 0x%lx.\n", nftl->mbd.size); printk(KERN_WARNING "NFTL: using C:%d H:%d S:%d " "(== 0x%lx sects)\n", nftl->cylinders, nftl->heads , nftl->sectors, (long)nftl->cylinders * (long)nftl->heads * (long)nftl->sectors ); } if (add_mtd_blktrans_dev(&nftl->mbd)) { if (nftl->ReplUnitTable) kfree(nftl->ReplUnitTable); if (nftl->EUNtable) kfree(nftl->EUNtable); kfree(nftl); return; } #ifdef PSYCHO_DEBUG printk(KERN_INFO "NFTL: Found new nftl%c\n", nftl->mbd.devnum + 'a'); #endif }
static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct INFTLrecord *inftl; unsigned long temp; if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX) return; if (memcmp(mtd->name, "DiskOnChip", 10)) return; if (!mtd->_block_isbad) { printk(KERN_ERR "INFTL no longer supports the old DiskOnChip drivers loaded via docprobe.\n" "Please use the new diskonchip driver under the NAND subsystem.\n"); return; } pr_debug("INFTL: add_mtd for %s\n", mtd->name); inftl = kzalloc(sizeof(*inftl), GFP_KERNEL); if (!inftl) return; inftl->mbd.mtd = mtd; inftl->mbd.devnum = -1; inftl->mbd.tr = tr; if (INFTL_mount(inftl) < 0) { printk(KERN_WARNING "INFTL: could not mount device\n"); kfree(inftl); return; } inftl->cylinders = 1024; inftl->heads = 16; temp = inftl->cylinders * inftl->heads; inftl->sectors = inftl->mbd.size / temp; if (inftl->mbd.size % temp) { inftl->sectors++; temp = inftl->cylinders * inftl->sectors; inftl->heads = inftl->mbd.size / temp; if (inftl->mbd.size % temp) { inftl->heads++; temp = inftl->heads * inftl->sectors; inftl->cylinders = inftl->mbd.size / temp; } } if (inftl->mbd.size != inftl->heads * inftl->cylinders * inftl->sectors) { printk(KERN_WARNING "INFTL: cannot calculate a geometry to " "match size of 0x%lx.\n", inftl->mbd.size); printk(KERN_WARNING "INFTL: using C:%d H:%d S:%d " "(== 0x%lx sects)\n", inftl->cylinders, inftl->heads , inftl->sectors, (long)inftl->cylinders * (long)inftl->heads * (long)inftl->sectors ); } if (add_mtd_blktrans_dev(&inftl->mbd)) { kfree(inftl->PUtable); kfree(inftl->VUtable); kfree(inftl); return; } #ifdef PSYCHO_DEBUG printk(KERN_INFO "INFTL: Found new inftl%c\n", inftl->mbd.devnum + 'a'); #endif return; }
static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) { struct NFTLrecord *nftl; unsigned long temp; if (mtd->type != MTD_NANDFLASH || mtd->size > UINT_MAX) return; /* OK, this is moderately ugly. But probably safe. Alternatives? */ if (memcmp(mtd->name, "DiskOnChip", 10)) return; pr_debug("NFTL: add_mtd for %s\n", mtd->name); nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL); if (!nftl) return; nftl->mbd.mtd = mtd; nftl->mbd.devnum = -1; nftl->mbd.tr = tr; if (NFTL_mount(nftl) < 0) { printk(KERN_WARNING "NFTL: could not mount device\n"); kfree(nftl); return; } /* OK, it's a new one. Set up all the data structures. */ /* Calculate geometry */ nftl->cylinders = 1024; nftl->heads = 16; temp = nftl->cylinders * nftl->heads; nftl->sectors = nftl->mbd.size / temp; if (nftl->mbd.size % temp) { nftl->sectors++; temp = nftl->cylinders * nftl->sectors; nftl->heads = nftl->mbd.size / temp; if (nftl->mbd.size % temp) { nftl->heads++; temp = nftl->heads * nftl->sectors; nftl->cylinders = nftl->mbd.size / temp; } } if (nftl->mbd.size != nftl->heads * nftl->cylinders * nftl->sectors) { /* Oh no we don't have mbd.size == heads * cylinders * sectors */ printk(KERN_WARNING "NFTL: cannot calculate a geometry to " "match size of 0x%lx.\n", nftl->mbd.size); printk(KERN_WARNING "NFTL: using C:%d H:%d S:%d " "(== 0x%lx sects)\n", nftl->cylinders, nftl->heads , nftl->sectors, (long)nftl->cylinders * (long)nftl->heads * (long)nftl->sectors ); } if (add_mtd_blktrans_dev(&nftl->mbd)) { kfree(nftl->ReplUnitTable); kfree(nftl->EUNtable); kfree(nftl); return; } #ifdef PSYCHO_DEBUG printk(KERN_INFO "NFTL: Found new nftl%c\n", nftl->mbd.devnum + 'a'); #endif }