Commit cc9d663a authored by Shubhankar Kuranagatti's avatar Shubhankar Kuranagatti Committed by Miquel Raynal

drivers: mtd: sm_ftl: Fix alignment of block comment

A star has been added to subsequent line of block comment
The closing */ has been shifted to new line
This is done to maintain code uniformity
Signed-off-by: default avatarShubhankar Kuranagatti <shubhankarvk@gmail.com>
[<miquel.raynal@bootlin.com>: Fixed the title]
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210504062059.mywqzwveyjfawreg@kewl-virtual-machine
parent feb05fae
...@@ -265,7 +265,8 @@ static int sm_read_sector(struct sm_ftl *ftl, ...@@ -265,7 +265,8 @@ static int sm_read_sector(struct sm_ftl *ftl,
again: again:
if (try++) { if (try++) {
/* Avoid infinite recursion on CIS reads, sm_recheck_media /* Avoid infinite recursion on CIS reads, sm_recheck_media
won't help anyway */ * won't help anyway
*/
if (zone == 0 && block == ftl->cis_block && boffset == if (zone == 0 && block == ftl->cis_block && boffset ==
ftl->cis_boffset) ftl->cis_boffset)
return ret; return ret;
...@@ -276,7 +277,8 @@ static int sm_read_sector(struct sm_ftl *ftl, ...@@ -276,7 +277,8 @@ static int sm_read_sector(struct sm_ftl *ftl,
} }
/* Unfortunately, oob read will _always_ succeed, /* Unfortunately, oob read will _always_ succeed,
despite card removal..... */ * despite card removal.....
*/
ret = mtd_read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops); ret = mtd_read_oob(mtd, sm_mkoffset(ftl, zone, block, boffset), &ops);
/* Test for unknown errors */ /* Test for unknown errors */
...@@ -411,9 +413,10 @@ static int sm_write_block(struct sm_ftl *ftl, uint8_t *buf, ...@@ -411,9 +413,10 @@ static int sm_write_block(struct sm_ftl *ftl, uint8_t *buf,
/* If write fails. try to erase the block */ /* If write fails. try to erase the block */
/* This is safe, because we never write in blocks /* This is safe, because we never write in blocks
that contain valuable data. * that contain valuable data.
This is intended to repair block that are marked * This is intended to repair block that are marked
as erased, but that isn't fully erased*/ * as erased, but that isn't fully erased
*/
if (sm_erase_block(ftl, zone, block, 0)) if (sm_erase_block(ftl, zone, block, 0))
return -EIO; return -EIO;
...@@ -448,7 +451,8 @@ static void sm_mark_block_bad(struct sm_ftl *ftl, int zone, int block) ...@@ -448,7 +451,8 @@ static void sm_mark_block_bad(struct sm_ftl *ftl, int zone, int block)
/* We aren't checking the return value, because we don't care */ /* We aren't checking the return value, because we don't care */
/* This also fails on fake xD cards, but I guess these won't expose /* This also fails on fake xD cards, but I guess these won't expose
any bad blocks till fail completely */ * any bad blocks till fail completely
*/
for (boffset = 0; boffset < ftl->block_size; boffset += SM_SECTOR_SIZE) for (boffset = 0; boffset < ftl->block_size; boffset += SM_SECTOR_SIZE)
sm_write_sector(ftl, zone, block, boffset, NULL, &oob); sm_write_sector(ftl, zone, block, boffset, NULL, &oob);
} }
...@@ -505,7 +509,8 @@ static int sm_check_block(struct sm_ftl *ftl, int zone, int block) ...@@ -505,7 +509,8 @@ static int sm_check_block(struct sm_ftl *ftl, int zone, int block)
/* First just check that block doesn't look fishy */ /* First just check that block doesn't look fishy */
/* Only blocks that are valid or are sliced in two parts, are /* Only blocks that are valid or are sliced in two parts, are
accepted */ * accepted
*/
for (boffset = 0; boffset < ftl->block_size; for (boffset = 0; boffset < ftl->block_size;
boffset += SM_SECTOR_SIZE) { boffset += SM_SECTOR_SIZE) {
...@@ -554,7 +559,8 @@ static const uint8_t cis_signature[] = { ...@@ -554,7 +559,8 @@ static const uint8_t cis_signature[] = {
0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20 0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20
}; };
/* Find out media parameters. /* Find out media parameters.
* This ideally has to be based on nand id, but for now device size is enough */ * This ideally has to be based on nand id, but for now device size is enough
*/
static int sm_get_media_info(struct sm_ftl *ftl, struct mtd_info *mtd) static int sm_get_media_info(struct sm_ftl *ftl, struct mtd_info *mtd)
{ {
int i; int i;
...@@ -607,7 +613,8 @@ static int sm_get_media_info(struct sm_ftl *ftl, struct mtd_info *mtd) ...@@ -607,7 +613,8 @@ static int sm_get_media_info(struct sm_ftl *ftl, struct mtd_info *mtd)
} }
/* Minimum xD size is 16MiB. Also, all xD cards have standard zone /* Minimum xD size is 16MiB. Also, all xD cards have standard zone
sizes. SmartMedia cards exist up to 128 MiB and have same layout*/ * sizes. SmartMedia cards exist up to 128 MiB and have same layout
*/
if (size_in_megs >= 16) { if (size_in_megs >= 16) {
ftl->zone_count = size_in_megs / 16; ftl->zone_count = size_in_megs / 16;
ftl->zone_size = 1024; ftl->zone_size = 1024;
...@@ -782,7 +789,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) ...@@ -782,7 +789,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
} }
/* Test to see if block is erased. It is enough to test /* Test to see if block is erased. It is enough to test
first sector, because erase happens in one shot */ * first sector, because erase happens in one shot
*/
if (sm_block_erased(&oob)) { if (sm_block_erased(&oob)) {
kfifo_in(&zone->free_sectors, kfifo_in(&zone->free_sectors,
(unsigned char *)&block, 2); (unsigned char *)&block, 2);
...@@ -792,7 +800,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) ...@@ -792,7 +800,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
/* If block is marked as bad, skip it */ /* If block is marked as bad, skip it */
/* This assumes we can trust first sector*/ /* This assumes we can trust first sector*/
/* However the way the block valid status is defined, ensures /* However the way the block valid status is defined, ensures
very low probability of failure here */ * very low probability of failure here
*/
if (!sm_block_valid(&oob)) { if (!sm_block_valid(&oob)) {
dbg("PH %04d <-> <marked bad>", block); dbg("PH %04d <-> <marked bad>", block);
continue; continue;
...@@ -803,7 +812,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) ...@@ -803,7 +812,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
/* Invalid LBA means that block is damaged. */ /* Invalid LBA means that block is damaged. */
/* We can try to erase it, or mark it as bad, but /* We can try to erase it, or mark it as bad, but
lets leave that to recovery application */ * lets leave that to recovery application
*/
if (lba == -2 || lba >= ftl->max_lba) { if (lba == -2 || lba >= ftl->max_lba) {
dbg("PH %04d <-> LBA %04d(bad)", block, lba); dbg("PH %04d <-> LBA %04d(bad)", block, lba);
continue; continue;
...@@ -811,7 +821,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) ...@@ -811,7 +821,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
/* If there is no collision, /* If there is no collision,
just put the sector in the FTL table */ * just put the sector in the FTL table
*/
if (zone->lba_to_phys_table[lba] < 0) { if (zone->lba_to_phys_table[lba] < 0) {
dbg_verbose("PH %04d <-> LBA %04d", block, lba); dbg_verbose("PH %04d <-> LBA %04d", block, lba);
zone->lba_to_phys_table[lba] = block; zone->lba_to_phys_table[lba] = block;
...@@ -834,9 +845,9 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) ...@@ -834,9 +845,9 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
} }
/* If both blocks are valid and share same LBA, it means that /* If both blocks are valid and share same LBA, it means that
they hold different versions of same data. It not * they hold different versions of same data. It not
known which is more recent, thus just erase one of them * known which is more recent, thus just erase one of them
*/ */
sm_printk("both blocks are valid, erasing the later"); sm_printk("both blocks are valid, erasing the later");
sm_erase_block(ftl, zone_num, block, 1); sm_erase_block(ftl, zone_num, block, 1);
} }
...@@ -845,7 +856,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) ...@@ -845,7 +856,8 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
zone->initialized = 1; zone->initialized = 1;
/* No free sectors, means that the zone is heavily damaged, write won't /* No free sectors, means that the zone is heavily damaged, write won't
work, but it can still can be (partially) read */ * work, but it can still can be (partially) read
*/
if (!kfifo_len(&zone->free_sectors)) { if (!kfifo_len(&zone->free_sectors)) {
sm_printk("no free blocks in zone %d", zone_num); sm_printk("no free blocks in zone %d", zone_num);
return 0; return 0;
...@@ -952,8 +964,9 @@ static int sm_cache_flush(struct sm_ftl *ftl) ...@@ -952,8 +964,9 @@ static int sm_cache_flush(struct sm_ftl *ftl)
/* If there are no spare blocks, */ /* If there are no spare blocks, */
/* we could still continue by erasing/writing the current block, /* we could still continue by erasing/writing the current block,
but for such worn out media it doesn't worth the trouble, * but for such worn out media it doesn't worth the trouble,
and the dangers */ * and the dangers
*/
if (kfifo_out(&zone->free_sectors, if (kfifo_out(&zone->free_sectors,
(unsigned char *)&write_sector, 2) != 2) { (unsigned char *)&write_sector, 2) != 2) {
dbg("no free sectors for write!"); dbg("no free sectors for write!");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment