mtd/drivers/mtd ftl.c,1.46,1.47
David Woodhouse
dwmw2 at infradead.org
Sun May 18 16:58:00 EDT 2003
Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv12869
Modified Files:
ftl.c
Log Message:
Convert to mtd_blktrans
Index: ftl.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/ftl.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- ftl.c 2 Mar 2003 18:45:07 -0000 1.46
+++ ftl.c 18 May 2003 20:57:57 -0000 1.47
@@ -55,8 +55,8 @@
contact M-Systems (http://www.m-sys.com) directly.
======================================================================*/
+#include <linux/mtd/blktrans.h>
#include <linux/module.h>
-#include <linux/mtd/compatmac.h>
#include <linux/mtd/mtd.h>
/*#define PSYCHO_DEBUG */
@@ -70,41 +70,10 @@
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/hdreg.h>
-
-#if (LINUX_VERSION_CODE >= 0x20100)
#include <linux/vmalloc.h>
-#endif
-#if (LINUX_VERSION_CODE >= 0x20303)
#include <linux/blkpg.h>
-#endif
#include <linux/mtd/ftl.h>
-/*====================================================================*/
-/* Stuff which really ought to be in compatmac.h */
-
-#if (LINUX_VERSION_CODE < 0x20328)
-#define register_disk(dev, drive, minors, ops, size) \
- do { (dev)->part[(drive)*(minors)].nr_sects = size; \
- if (size == 0) (dev)->part[(drive)*(minors)].start_sect = -1; \
- resetup_one_dev(dev, drive); } while (0)
-#endif
-
-#if (LINUX_VERSION_CODE < 0x20320)
-#define BLK_DEFAULT_QUEUE(n) blk_dev[n].request_fn
-#define blk_init_queue(q, req) q = (req)
-#define blk_cleanup_queue(q) q = NULL
-#define request_arg_t void
-#else
-#define request_arg_t request_queue_t *q
-#endif
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,14)
-#define BLK_INC_USE_COUNT MOD_INC_USE_COUNT
-#define BLK_DEC_USE_COUNT MOD_DEC_USE_COUNT
-#else
-#define BLK_INC_USE_COUNT do {} while(0)
-#define BLK_DEC_USE_COUNT do {} while(0)
-#endif
/*====================================================================*/
@@ -119,19 +88,6 @@
#define FTL_MAJOR 44
#endif
-/* Funky stuff for setting up a block device */
-#define MAJOR_NR FTL_MAJOR
-#define DEVICE_NAME "ftl"
-#define DEVICE_REQUEST do_ftl_request
-#define DEVICE_ON(device)
-#define DEVICE_OFF(device)
-
-#define DEVICE_NR(minor) ((minor)>>5)
-#define REGION_NR(minor) (((minor)>>3)&3)
-#define PART_NR(minor) ((minor)&7)
-#define MINOR_NR(dev,reg,part) (((dev)<<5)+((reg)<<3)+(part))
-
-#include <linux/blk.h>
/*====================================================================*/
@@ -154,7 +110,7 @@
/* Each memory region corresponds to a minor device */
typedef struct partition_t {
- struct mtd_info *mtd;
+ struct mtd_blktrans_dev mbd;
u_int32_t state;
u_int32_t *VirtualBlockMap;
u_int32_t *VirtualPageMap;
@@ -179,21 +135,10 @@
region_info_t region;
memory_handle_t handle;
#endif
- atomic_t open;
} partition_t;
-partition_t *myparts[MAX_MTD_DEVICES];
-
-static void ftl_notify_add(struct mtd_info *mtd);
-static void ftl_notify_remove(struct mtd_info *mtd);
-
void ftl_freepart(partition_t *part);
-static struct mtd_notifier ftl_notifier = {
- .add = ftl_notify_add,
- .remove = ftl_notify_remove,
-};
-
/* Partition state flags */
#define FTL_FORMATTED 0x01
@@ -204,51 +149,11 @@
#define XFER_PREPARED 0x03
#define XFER_FAILED 0x04
-static struct hd_struct ftl_hd[MINOR_NR(MAX_DEV, 0, 0)];
-static int ftl_sizes[MINOR_NR(MAX_DEV, 0, 0)];
-static int ftl_blocksizes[MINOR_NR(MAX_DEV, 0, 0)];
-
-static struct gendisk ftl_gendisk = {
- major: FTL_MAJOR,
- major_name: "ftl",
- minor_shift: PART_BITS,
- max_p: MAX_PART,
-#if (LINUX_VERSION_CODE < 0x20328)
- max_nr: MAX_DEV*MAX_PART,
-#endif
- part: ftl_hd,
- sizes: ftl_sizes,
-};
-
/*====================================================================*/
-static int ftl_ioctl(struct inode *inode, struct file *file,
- u_int cmd, u_long arg);
-static int ftl_open(struct inode *inode, struct file *file);
-static release_t ftl_close(struct inode *inode, struct file *file);
-static int ftl_reread_partitions(int minor);
static void ftl_erase_callback(struct erase_info *done);
-#if LINUX_VERSION_CODE < 0x20326
-static struct file_operations ftl_blk_fops = {
- open: ftl_open,
- release: ftl_close,
- ioctl: ftl_ioctl,
- read: block_read,
- write: block_write,
- fsync: block_fsync
-};
-#else
-static struct block_device_operations ftl_blk_fops = {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,14)
- owner: THIS_MODULE,
-#endif
- open: ftl_open,
- release: ftl_close,
- ioctl: ftl_ioctl,
-};
-#endif
/*======================================================================
@@ -264,13 +169,13 @@
loff_t offset, max_offset;
int ret;
part->header.FormattedSize = 0;
- max_offset = (0x100000<part->mtd->size)?0x100000:part->mtd->size;
+ max_offset = (0x100000<part->mbd.mtd->size)?0x100000:part->mbd.mtd->size;
/* Search first megabyte for a valid FTL header */
for (offset = 0;
(offset + sizeof(header)) < max_offset;
- offset += part->mtd->erasesize ? : 0x2000) {
+ offset += part->mbd.mtd->erasesize ? : 0x2000) {
- ret = part->mtd->read(part->mtd, offset, sizeof(header), &ret,
+ ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &ret,
(unsigned char *)&header);
if (ret)
@@ -289,9 +194,9 @@
printk(KERN_NOTICE "ftl_cs: FTL header corrupt!\n");
return -1;
}
- if ((1 << header.EraseUnitSize) != part->mtd->erasesize) {
+ if ((1 << header.EraseUnitSize) != part->mbd.mtd->erasesize) {
printk(KERN_NOTICE "ftl: FTL EraseUnitSize %x != MTD erasesize %x\n",
- 1 << header.EraseUnitSize,part->mtd->erasesize);
+ 1 << header.EraseUnitSize,part->mbd.mtd->erasesize);
return -1;
}
part->header = header;
@@ -326,7 +231,7 @@
for (i = 0; i < le16_to_cpu(part->header.NumEraseUnits); i++) {
offset = ((i + le16_to_cpu(part->header.FirstPhysicalEUN))
<< part->header.EraseUnitSize);
- ret = part->mtd->read(part->mtd, offset, sizeof(header), &retval,
+ ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(header), &retval,
(unsigned char *)&header);
if (ret)
@@ -391,7 +296,7 @@
part->EUNInfo[i].Deleted = 0;
offset = part->EUNInfo[i].Offset + le32_to_cpu(header.BAMOffset);
- ret = part->mtd->read(part->mtd, offset,
+ ret = part->mbd.mtd->read(part->mbd.mtd, offset,
part->BlocksPerUnit * sizeof(u_int32_t), &retval,
(unsigned char *)part->bam_cache);
@@ -456,7 +361,7 @@
erase->len = 1 << part->header.EraseUnitSize;
erase->priv = (u_long)part;
- ret = part->mtd->erase(part->mtd, erase);
+ ret = part->mbd.mtd->erase(part->mbd.mtd, erase);
if (!ret)
xfer->EraseCount++;
@@ -523,7 +428,7 @@
header.LogicalEUN = cpu_to_le16(0xffff);
header.EraseCount = cpu_to_le32(xfer->EraseCount);
- ret = part->mtd->write(part->mtd, xfer->Offset, sizeof(header),
+ ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset, sizeof(header),
&retlen, (u_char *)&header);
if (ret) {
@@ -539,7 +444,7 @@
for (i = 0; i < nbam; i++, offset += sizeof(u_int32_t)) {
- ret = part->mtd->write(part->mtd, offset, sizeof(u_int32_t),
+ ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t),
&retlen, (u_char *)&ctl);
if (ret)
@@ -586,7 +491,7 @@
offset = eun->Offset + le32_to_cpu(part->header.BAMOffset);
- ret = part->mtd->read(part->mtd, offset,
+ ret = part->mbd.mtd->read(part->mbd.mtd, offset,
part->BlocksPerUnit * sizeof(u_int32_t),
&retlen, (u_char *) (part->bam_cache));
@@ -604,7 +509,7 @@
offset = xfer->Offset + 20; /* Bad! */
unit = cpu_to_le16(0x7fff);
- ret = part->mtd->write(part->mtd, offset, sizeof(u_int16_t),
+ ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int16_t),
&retlen, (u_char *) &unit);
if (ret) {
@@ -624,7 +529,7 @@
break;
case BLOCK_DATA:
case BLOCK_REPLACEMENT:
- ret = part->mtd->read(part->mtd, src, SECTOR_SIZE,
+ ret = part->mbd.mtd->read(part->mbd.mtd, src, SECTOR_SIZE,
&retlen, (u_char *) buf);
if (ret) {
printk(KERN_WARNING "ftl: Error reading old xfer unit in copy_erase_unit\n");
@@ -632,7 +537,7 @@
}
- ret = part->mtd->write(part->mtd, dest, SECTOR_SIZE,
+ ret = part->mbd.mtd->write(part->mbd.mtd, dest, SECTOR_SIZE,
&retlen, (u_char *) buf);
if (ret) {
printk(KERN_WARNING "ftl: Error writing new xfer unit in copy_erase_unit\n");
@@ -651,7 +556,7 @@
}
/* Write the BAM to the transfer unit */
- ret = part->mtd->write(part->mtd, xfer->Offset + le32_to_cpu(part->header.BAMOffset),
+ ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + le32_to_cpu(part->header.BAMOffset),
part->BlocksPerUnit * sizeof(int32_t), &retlen,
(u_char *)part->bam_cache);
if (ret) {
@@ -661,7 +566,7 @@
/* All clear? Then update the LogicalEUN again */
- ret = part->mtd->write(part->mtd, xfer->Offset + 20, sizeof(u_int16_t),
+ ret = part->mbd.mtd->write(part->mbd.mtd, xfer->Offset + 20, sizeof(u_int16_t),
&retlen, (u_char *)&srcunitswap);
if (ret) {
@@ -749,8 +654,8 @@
if (queued) {
DEBUG(1, "ftl_cs: waiting for transfer "
"unit to be prepared...\n");
- if (part->mtd->sync)
- part->mtd->sync(part->mtd);
+ if (part->mbd.mtd->sync)
+ part->mbd.mtd->sync(part->mbd.mtd);
} else {
static int ne = 0;
if (++ne < 5)
@@ -848,7 +753,7 @@
/* Invalidate cache */
part->bam_index = 0xffff;
- ret = part->mtd->read(part->mtd,
+ ret = part->mbd.mtd->read(part->mbd.mtd,
part->EUNInfo[eun].Offset + le32_to_cpu(part->header.BAMOffset),
part->BlocksPerUnit * sizeof(u_int32_t),
&retlen, (u_char *) (part->bam_cache));
@@ -877,78 +782,6 @@
} /* find_free */
-/*======================================================================
-
- This gets a memory handle for the region corresponding to the
- minor device number.
-
-======================================================================*/
-
-static int ftl_open(struct inode *inode, struct file *file)
-{
- int minor = MINOR(inode->i_rdev);
- partition_t *partition;
-
- if (minor>>4 >= MAX_MTD_DEVICES)
- return -ENODEV;
-
- partition = myparts[minor>>4];
-
- if (!partition)
- return -ENODEV;
-
- if (partition->state != FTL_FORMATTED)
- return -ENXIO;
-
- if (ftl_gendisk.part[minor].nr_sects == 0)
- return -ENXIO;
-
- BLK_INC_USE_COUNT;
-
- if (!get_mtd_device(partition->mtd, -1)) {
- BLK_DEC_USE_COUNT;
- return -ENXIO;
- }
-
- if ((file->f_mode & 2) && !(partition->mtd->flags & MTD_CLEAR_BITS) ) {
- put_mtd_device(partition->mtd);
- BLK_DEC_USE_COUNT;
- return -EROFS;
- }
-
- DEBUG(0, "ftl_cs: ftl_open(%d)\n", minor);
-
- atomic_inc(&partition->open);
-
- return 0;
-}
-
-/*====================================================================*/
-
-static release_t ftl_close(struct inode *inode, struct file *file)
-{
- int minor = MINOR(inode->i_rdev);
- partition_t *part = myparts[minor >> 4];
- int i;
-
- DEBUG(0, "ftl_cs: ftl_close(%d)\n", minor);
-
- /* Wait for any pending erase operations to complete */
- if (part->mtd->sync)
- part->mtd->sync(part->mtd);
-
- for (i = 0; i < part->header.NumTransferUnits; i++) {
- if (part->XferInfo[i].state == XFER_ERASED)
- prepare_xfer(part, i);
- }
-
- atomic_dec(&part->open);
-
- put_mtd_device(part->mtd);
- BLK_DEC_USE_COUNT;
- release_return(0);
-} /* ftl_close */
-
/*======================================================================
@@ -983,7 +816,7 @@
else {
offset = (part->EUNInfo[log_addr / bsize].Offset
+ (log_addr % bsize));
- ret = part->mtd->read(part->mtd, offset, SECTOR_SIZE,
+ ret = part->mbd.mtd->read(part->mbd.mtd, offset, SECTOR_SIZE,
&retlen, (u_char *) buffer);
if (ret) {
@@ -1022,7 +855,7 @@
le32_to_cpu(part->header.BAMOffset));
#ifdef PSYCHO_DEBUG
- ret = part->mtd->read(part->mtd, offset, sizeof(u_int32_t),
+ ret = part->mbd.mtd->read(part->mbd.mtd, offset, sizeof(u_int32_t),
&retlen, (u_char *)&old_addr);
if (ret) {
printk(KERN_WARNING"ftl: Error reading old_addr in set_bam_entry: %d\n",ret);
@@ -1059,7 +892,7 @@
#endif
part->bam_cache[blk] = le_virt_addr;
}
- ret = part->mtd->write(part->mtd, offset, sizeof(u_int32_t),
+ ret = part->mbd.mtd->write(part->mbd.mtd, offset, sizeof(u_int32_t),
&retlen, (u_char *)&le_virt_addr);
if (ret) {
@@ -1119,7 +952,7 @@
part->EUNInfo[part->bam_index].Deleted++;
offset = (part->EUNInfo[part->bam_index].Offset +
blk * SECTOR_SIZE);
- ret = part->mtd->write(part->mtd, offset, SECTOR_SIZE, &retlen,
+ ret = part->mbd.mtd->write(part->mbd.mtd, offset, SECTOR_SIZE, &retlen,
buffer);
if (ret) {
@@ -1157,158 +990,43 @@
======================================================================*/
-static int ftl_ioctl(struct inode *inode, struct file *file,
- u_int cmd, u_long arg)
+static int ftl_ioctl(struct mtd_blktrans_dev *dev, struct inode *inode,
+ struct file *file, u_int cmd, u_long arg)
{
struct hd_geometry *geo = (struct hd_geometry *)arg;
- int ret = 0, minor = MINOR(inode->i_rdev);
- partition_t *part= myparts[minor >> 4];
+ partition_t *part = (void *)dev;
u_long sect;
- if (!part)
- return -ENODEV; /* How? */
-
switch (cmd) {
case HDIO_GETGEO:
- ret = verify_area(VERIFY_WRITE, (long *)arg, sizeof(*geo));
- if (ret) return ret;
/* Sort of arbitrary: round size down to 4K boundary */
sect = le32_to_cpu(part->header.FormattedSize)/SECTOR_SIZE;
- put_user(1, (char *)&geo->heads);
- put_user(8, (char *)&geo->sectors);
- put_user((sect>>3), (short *)&geo->cylinders);
- put_user(ftl_hd[minor].start_sect, (u_long *)&geo->start);
- break;
- case BLKGETSIZE:
- ret = put_user(ftl_hd[minor].nr_sects, (unsigned long *)arg);
- break;
-#ifdef BLKGETSIZE64
- case BLKGETSIZE64:
- ret = put_user((u64)ftl_hd[minor].nr_sects << 9, (u64 *)arg);
- break;
-#endif
- case BLKRRPART:
- ret = ftl_reread_partitions(minor);
- break;
-#if (LINUX_VERSION_CODE < 0x20303)
- case BLKFLSBUF:
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
- if (!capable(CAP_SYS_ADMIN)) return -EACCES;
-#endif
- fsync_dev(inode->i_rdev);
- invalidate_buffers(inode->i_rdev);
- break;
- RO_IOCTLS(inode->i_rdev, arg);
-#else
- case BLKROSET:
- case BLKROGET:
+ if (put_user(1, (char *)&geo->heads) ||
+ put_user(8, (char *)&geo->sectors) ||
+ put_user((sect>>3), (short *)&geo->cylinders) ||
+ put_user(0, (u_long *)&geo->start))
+ return -EFAULT;
+
case BLKFLSBUF:
- ret = blk_ioctl(inode->i_rdev, cmd, arg);
- break;
-#endif
- default:
- ret = -EINVAL;
+ return 0;
}
-
- return ret;
+ return -ENOTTY;
} /* ftl_ioctl */
-/*======================================================================
-
- Handler for block device requests
-======================================================================*/
+/*======================================================================*/
-static int ftl_reread_partitions(int minor)
+static int ftl_readsect(struct mtd_blktrans_dev *dev,
+ unsigned long block, char *buf)
{
- partition_t *part = myparts[minor >> 4];
- int i, whole;
-
- DEBUG(0, "ftl_cs: ftl_reread_partition(%d)\n", minor);
- if ((atomic_read(&part->open) > 1)) {
- return -EBUSY;
- }
- whole = minor & ~(MAX_PART-1);
-
- i = MAX_PART - 1;
- while (i-- > 0) {
- if (ftl_hd[whole+i].nr_sects > 0) {
- kdev_t rdev = MKDEV(FTL_MAJOR, whole+i);
-
- invalidate_device(rdev, 1);
- }
- ftl_hd[whole+i].start_sect = 0;
- ftl_hd[whole+i].nr_sects = 0;
- }
-
- scan_header(part);
-
- register_disk(&ftl_gendisk, whole >> PART_BITS, MAX_PART,
- &ftl_blk_fops, le32_to_cpu(part->header.FormattedSize)/SECTOR_SIZE);
-
-#ifdef PCMCIA_DEBUG
- for (i = 0; i < MAX_PART; i++) {
- if (ftl_hd[whole+i].nr_sects > 0)
- printk(KERN_INFO " %d: start %ld size %ld\n", i,
- ftl_hd[whole+i].start_sect,
- ftl_hd[whole+i].nr_sects);
- }
-#endif
- return 0;
+ return ftl_read((void *)dev, buf, block, 1);
}
-/*======================================================================
-
- Handler for block device requests
-
-======================================================================*/
-
-static void do_ftl_request(request_arg_t)
+static int ftl_writesect(struct mtd_blktrans_dev *dev,
+ unsigned long block, char *buf)
{
- int ret, minor;
- partition_t *part;
-
- do {
- // sti();
- INIT_REQUEST;
-
- minor = MINOR(CURRENT->rq_dev);
-
- part = myparts[minor >> 4];
- if (part) {
- ret = 0;
-
- switch (CURRENT->cmd) {
- case READ:
- ret = ftl_read(part, CURRENT->buffer,
- CURRENT->sector+ftl_hd[minor].start_sect,
- CURRENT->current_nr_sectors);
- if (ret) printk("ftl_read returned %d\n", ret);
- break;
-
- case WRITE:
- ret = ftl_write(part, CURRENT->buffer,
- CURRENT->sector+ftl_hd[minor].start_sect,
- CURRENT->current_nr_sectors);
- if (ret) printk("ftl_write returned %d\n", ret);
- break;
-
- default:
- panic("ftl_cs: unknown block command!\n");
-
- }
- } else {
- ret = 1;
- printk("NULL part in ftl_request\n");
- }
-
- if (!ret) {
- CURRENT->sector += CURRENT->current_nr_sectors;
- }
-
- end_request((ret == 0) ? 1 : 0);
- } while (1);
-} /* do_ftl_request */
+ return ftl_write((void *)dev, buf, block, 1);
+}
/*====================================================================*/
@@ -1337,19 +1055,9 @@
} /* ftl_freepart */
-static void ftl_notify_add(struct mtd_info *mtd)
+static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
{
partition_t *partition;
- int device;
-
- for (device=0; device < MAX_MTD_DEVICES && myparts[device]; device++)
- ;
-
- if (device == MAX_MTD_DEVICES) {
- printk(KERN_NOTICE "Maximum number of FTL partitions reached\n"
- "Not scanning <%s>\n", mtd->name);
- return;
- }
partition = kmalloc(sizeof(partition_t), GFP_KERNEL);
@@ -1361,92 +1069,55 @@
memset(partition, 0, sizeof(partition_t));
- partition->mtd = mtd;
+ partition->mbd.mtd = mtd;
if ((scan_header(partition) == 0) &&
(build_maps(partition) == 0)) {
partition->state = FTL_FORMATTED;
- atomic_set(&partition->open, 0);
- myparts[device] = partition;
- ftl_reread_partitions(device << 4);
#ifdef PCMCIA_DEBUG
- printk(KERN_INFO "ftl_cs: opening %d kb FTL partition\n",
+ printk(KERN_INFO "ftl_cs: opening %d KiB FTL partition\n",
le32_to_cpu(partition->header.FormattedSize) >> 10);
#endif
+ partition->mbd.size = le32_to_cpu(partition->header.FormattedSize) >> 9;
+ partition->mbd.blksize = 512;
+ partition->mbd.tr = tr;
+ partition->mbd.devnum = -1;
+ if (add_mtd_blktrans_dev((void *)partition))
+ kfree(partition);
+
} else
kfree(partition);
}
-static void ftl_notify_remove(struct mtd_info *mtd)
+static void ftl_remove_dev(struct mtd_blktrans_dev *dev)
{
- int i,j;
-
- /* Q: What happens if you try to remove a device which has
- * a currently-open FTL partition on it?
- *
- * A: You don't. The ftl_open routine is responsible for
- * increasing the use count of the driver module which
- * it uses.
- */
-
- /* That's the theory, anyway :) */
-
- for (i=0; i< MAX_MTD_DEVICES; i++)
- if (myparts[i] && myparts[i]->mtd == mtd) {
-
- if (myparts[i]->state == FTL_FORMATTED)
- ftl_freepart(myparts[i]);
-
- myparts[i]->state = 0;
- for (j=0; j<16; j++) {
- ftl_gendisk.part[j].nr_sects=0;
- ftl_gendisk.part[j].start_sect=0;
- }
- kfree(myparts[i]);
- myparts[i] = NULL;
- }
+ del_mtd_blktrans_dev(dev);
+ kfree(dev);
}
+struct mtd_blktrans_ops ftl_tr = {
+ .name = "ftl",
+ .major = FTL_MAJOR,
+ .part_bits = 4,
+ .readsect = ftl_readsect,
+ .writesect = ftl_writesect,
+ .ioctl = ftl_ioctl,
+ .add_mtd = ftl_add_mtd,
+ .remove_dev = ftl_remove_dev,
+ .owner = THIS_MODULE,
+};
+
int init_ftl(void)
{
- int i;
+ DEBUG(0, "$Id$\n");
- memset(myparts, 0, sizeof(myparts));
-
- DEBUG(0, "$Id$\n");
-
- if (register_blkdev(FTL_MAJOR, "ftl", &ftl_blk_fops)) {
- printk(KERN_NOTICE "ftl_cs: unable to grab major "
- "device number!\n");
- return -EAGAIN;
- }
-
- for (i = 0; i < MINOR_NR(MAX_DEV, 0, 0); i++)
- ftl_blocksizes[i] = 1024;
- for (i = 0; i < MAX_DEV*MAX_PART; i++) {
- ftl_hd[i].nr_sects = 0;
- ftl_hd[i].start_sect = 0;
- }
- blksize_size[FTL_MAJOR] = ftl_blocksizes;
- ftl_gendisk.major = FTL_MAJOR;
- blk_init_queue(BLK_DEFAULT_QUEUE(FTL_MAJOR), &do_ftl_request);
- add_gendisk(&ftl_gendisk);
-
- register_mtd_user(&ftl_notifier);
-
- return 0;
+ return register_mtd_blktrans(&ftl_tr);
}
static void __exit cleanup_ftl(void)
{
- unregister_mtd_user(&ftl_notifier);
-
- unregister_blkdev(FTL_MAJOR, "ftl");
- blk_cleanup_queue(BLK_DEFAULT_QUEUE(FTL_MAJOR));
- blksize_size[FTL_MAJOR] = NULL;
-
- del_gendisk(&ftl_gendisk);
+ deregister_mtd_blktrans(&ftl_tr);
}
module_init(init_ftl);
More information about the linux-mtd-cvs
mailing list