diff options
Diffstat (limited to 'drivers/mtd/rfd_ftl.c')
-rw-r--r-- | drivers/mtd/rfd_ftl.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index 7b243f2b2fa3..7f5f6d247cae 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c @@ -705,6 +705,34 @@ err: return rc; } +static int rfd_ftl_discardsect(struct mtd_blktrans_dev *dev, + unsigned long sector, unsigned int nr_sects) +{ + struct partition *part = (struct partition *)dev; + u_long addr; + int rc; + + while (nr_sects) { + if (sector >= part->sector_count) + return -EIO; + + addr = part->sector_map[sector]; + + if (addr != -1) { + rc = mark_sector_deleted(part, addr); + if (rc) + return rc; + + part->sector_map[sector] = -1; + } + + sector++; + nr_sects--; + } + + return 0; +} + static int rfd_ftl_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo) { struct partition *part = (struct partition*)dev; @@ -786,6 +814,7 @@ static struct mtd_blktrans_ops rfd_ftl_tr = { .readsect = rfd_ftl_readsect, .writesect = rfd_ftl_writesect, + .discard = rfd_ftl_discardsect, .getgeo = rfd_ftl_getgeo, .add_mtd = rfd_ftl_add_mtd, .remove_dev = rfd_ftl_remove_dev, |