Skip to content

Commit 133fa8c

Browse files
maximlevitskyDavid Woodhouse
authored andcommitted
mtd: Few follow up cleanups for Smartmedia/xD support
* Test results of few functions that were declared with __must_check * Fix bogus gcc warning about uinitialized variable 'ret' * Remove unused variable from mtdblock_remove_dev * Don't use deprecated DMA_32BIT_MASK Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 67e054e commit 133fa8c

4 files changed

Lines changed: 18 additions & 12 deletions

File tree

‎drivers/mtd/mtd_blkdevs.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,11 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
380380

381381
add_disk(gd);
382382

383-
if (new->disk_attributes)
384-
sysfs_create_group(&disk_to_dev(gd)->kobj,
383+
if (new->disk_attributes) {
384+
ret = sysfs_create_group(&disk_to_dev(gd)->kobj,
385385
new->disk_attributes);
386+
WARN_ON(ret);
387+
}
386388
return 0;
387389
error4:
388390
module_put(tr->owner);

‎drivers/mtd/mtdblock.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
354354

355355
static void mtdblock_remove_dev(struct mtd_blktrans_dev *dev)
356356
{
357-
struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
358357
del_mtd_blktrans_dev(dev);
359358
}
360359

‎drivers/mtd/nand/r852.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,9 @@ int r852_register_nand_device(struct r852_device *dev)
654654
if (sm_register_device(dev->mtd))
655655
goto error2;
656656

657-
device_create_file(&dev->mtd->dev, &dev_attr_media_type);
657+
if (device_create_file(&dev->mtd->dev, &dev_attr_media_type))
658+
message("can't create media type sysfs attribute");
659+
658660
dev->card_registred = 1;
659661
return 0;
660662
error2:
@@ -838,7 +840,7 @@ int r852_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
838840

839841
pci_set_master(pci_dev);
840842

841-
error = pci_set_dma_mask(pci_dev, DMA_32BIT_MASK);
843+
error = pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32));
842844
if (error)
843845
goto error2;
844846

‎drivers/mtd/sm_ftl.c‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int sm_read_sector(struct sm_ftl *ftl,
228228
struct mtd_info *mtd = ftl->trans->mtd;
229229
struct mtd_oob_ops ops;
230230
struct sm_oob tmp_oob;
231-
int ret;
231+
int ret = -EIO;
232232
int try = 0;
233233

234234
/* FTL can contain -1 entries that are by default filled with bits */
@@ -753,6 +753,7 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
753753
uint16_t block;
754754
int lba;
755755
int i = 0;
756+
int len;
756757

757758
dbg("initializing zone %d", zone_num);
758759

@@ -856,7 +857,9 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
856857
i %= (kfifo_len(&zone->free_sectors) / 2);
857858

858859
while (i--) {
859-
kfifo_out(&zone->free_sectors, (unsigned char *)&block, 2);
860+
len = kfifo_out(&zone->free_sectors,
861+
(unsigned char *)&block, 2);
862+
WARN_ON(len != 2);
860863
kfifo_in(&zone->free_sectors, (const unsigned char *)&block, 2);
861864
}
862865
return 0;
@@ -947,17 +950,17 @@ int sm_cache_flush(struct sm_ftl *ftl)
947950

948951
if (ftl->unstable)
949952
return -EIO;
950-
/* No spare blocks */
951-
/* We could still continue by erasing the current block,
953+
954+
/* If there are no spare blocks, */
955+
/* we could still continue by erasing/writing the current block,
952956
but for such worn out media it doesn't worth the trouble,
953957
and the dangers */
954-
955-
if (!kfifo_len(&zone->free_sectors)) {
958+
if (kfifo_out(&zone->free_sectors,
959+
(unsigned char *)&write_sector, 2) != 2) {
956960
dbg("no free sectors for write!");
957961
return -EIO;
958962
}
959963

960-
kfifo_out(&zone->free_sectors, (unsigned char *)&write_sector, 2);
961964

962965
if (sm_write_block(ftl, ftl->cache_data, zone_num, write_sector,
963966
ftl->cache_block, ftl->cache_data_invalid_bitmap))

0 commit comments

Comments
 (0)