diff options
Diffstat (limited to 'src/udev/mtd_probe')
-rw-r--r-- | src/udev/mtd_probe/mtd_probe.c | 9 | ||||
-rw-r--r-- | src/udev/mtd_probe/probe_smartmedia.c | 19 |
2 files changed, 15 insertions, 13 deletions
diff --git a/src/udev/mtd_probe/mtd_probe.c b/src/udev/mtd_probe/mtd_probe.c index 1aa08d3851..70c04db40b 100644 --- a/src/udev/mtd_probe/mtd_probe.c +++ b/src/udev/mtd_probe/mtd_probe.c @@ -28,19 +28,22 @@ int main(int argc, char** argv) { + int mtd_fd; + int error; + mtd_info_t mtd_info; + if (argc != 2) { printf("usage: mtd_probe /dev/mtd[n]\n"); return 1; } - int mtd_fd = open(argv[1], O_RDONLY); + mtd_fd = open(argv[1], O_RDONLY); if (mtd_fd == -1) { perror("open"); exit(-1); } - mtd_info_t mtd_info; - int error = ioctl(mtd_fd, MEMGETINFO, &mtd_info); + error = ioctl(mtd_fd, MEMGETINFO, &mtd_info); if (error == -1) { perror("ioctl"); exit(-1); diff --git a/src/udev/mtd_probe/probe_smartmedia.c b/src/udev/mtd_probe/probe_smartmedia.c index b3cdefc633..feadb5076c 100644 --- a/src/udev/mtd_probe/probe_smartmedia.c +++ b/src/udev/mtd_probe/probe_smartmedia.c @@ -36,7 +36,13 @@ static const uint8_t cis_signature[] = { void probe_smart_media(int mtd_fd, mtd_info_t* info) { + int sector_size; + int block_size; + int size_in_megs; + int spare_count; char* cis_buffer = malloc(SM_SECTOR_SIZE); + int offset; + int cis_found = 0; if (!cis_buffer) return; @@ -44,11 +50,9 @@ void probe_smart_media(int mtd_fd, mtd_info_t* info) 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; - + sector_size = info->writesize; + block_size = info->erasesize; + size_in_megs = info->size / (1024 * 1024); if (sector_size != SM_SECTOR_SIZE && sector_size != SM_SMALL_PAGE) goto exit; @@ -66,13 +70,8 @@ void probe_smart_media(int mtd_fd, mtd_info_t* info) break; } - - int offset; - int cis_found = 0; - 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; |