summaryrefslogtreecommitdiff
path: root/src/extras/mtd_probe/probe_smartmedia.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/extras/mtd_probe/probe_smartmedia.c')
-rw-r--r--src/extras/mtd_probe/probe_smartmedia.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/extras/mtd_probe/probe_smartmedia.c b/src/extras/mtd_probe/probe_smartmedia.c
index 49704e380a..b3cdefc633 100644
--- a/src/extras/mtd_probe/probe_smartmedia.c
+++ b/src/extras/mtd_probe/probe_smartmedia.c
@@ -30,68 +30,68 @@
#include "mtd_probe.h"
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
};
void probe_smart_media(int mtd_fd, mtd_info_t* info)
{
- char* cis_buffer = malloc(SM_SECTOR_SIZE);
+ char* cis_buffer = malloc(SM_SECTOR_SIZE);
- if (!cis_buffer)
- return;
+ if (!cis_buffer)
+ return;
- if (info->type != MTD_NANDFLASH)
- goto exit;
+ if (info->type != MTD_NANDFLASH)
+ goto exit;
- int sector_size = info->writesize;
- int block_size = info->erasesize;
- int size_in_megs = info->size / (1024 * 1024);
- int spare_count;
+ int sector_size = info->writesize;
+ int block_size = info->erasesize;
+ int size_in_megs = info->size / (1024 * 1024);
+ int spare_count;
- if (sector_size != SM_SECTOR_SIZE && sector_size != SM_SMALL_PAGE)
- goto exit;
+ if (sector_size != SM_SECTOR_SIZE && sector_size != SM_SMALL_PAGE)
+ goto exit;
- switch(size_in_megs) {
- case 1:
- case 2:
- spare_count = 6;
- break;
- case 4:
- spare_count = 12;
- break;
- default:
- spare_count = 24;
- break;
- }
+ switch(size_in_megs) {
+ case 1:
+ case 2:
+ spare_count = 6;
+ break;
+ case 4:
+ spare_count = 12;
+ break;
+ default:
+ spare_count = 24;
+ break;
+ }
- int offset;
- int cis_found = 0;
+ int offset;
+ int cis_found = 0;
- for (offset = 0 ; offset < block_size * spare_count ;
- offset += sector_size) {
+ for (offset = 0 ; offset < block_size * spare_count ;
+ offset += sector_size) {
- lseek(mtd_fd, SEEK_SET, offset);
- if (read(mtd_fd, cis_buffer, SM_SECTOR_SIZE) == SM_SECTOR_SIZE){
- cis_found = 1;
- break;
- }
- }
+ lseek(mtd_fd, SEEK_SET, offset);
+ if (read(mtd_fd, cis_buffer, SM_SECTOR_SIZE) == SM_SECTOR_SIZE){
+ cis_found = 1;
+ break;
+ }
+ }
- if (!cis_found)
- goto exit;
+ if (!cis_found)
+ goto exit;
- if (memcmp(cis_buffer, cis_signature, sizeof(cis_signature)) != 0 &&
- (memcmp(cis_buffer + SM_SMALL_PAGE, cis_signature,
- sizeof(cis_signature)) != 0))
- goto exit;
+ if (memcmp(cis_buffer, cis_signature, sizeof(cis_signature)) != 0 &&
+ (memcmp(cis_buffer + SM_SMALL_PAGE, cis_signature,
+ sizeof(cis_signature)) != 0))
+ goto exit;
- printf("MTD_FTL=smartmedia\n");
- free(cis_buffer);
- exit(0);
+ printf("MTD_FTL=smartmedia\n");
+ free(cis_buffer);
+ exit(0);
exit:
- free(cis_buffer);
- return;
+ free(cis_buffer);
+ return;
}