aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgermeier <germeier>2003-04-03 21:48:25 +0000
committergermeier <germeier>2003-04-03 21:48:25 +0000
commit457cdc53d0f5220e67b0418ca232c380c12abe1e (patch)
tree8e3beaf18fdb44ca1657467de6e14cd5d2b784aa
parente53a7d08e57f6e770b0809ced22cc61d87a5d173 (diff)
downloadmpiosh-457cdc53d0f5220e67b0418ca232c380c12abe1e.tar.gz
mpiosh-457cdc53d0f5220e67b0418ca232c380c12abe1e.tar.bz2
mpiosh-457cdc53d0f5220e67b0418ca232c380c12abe1e.zip
try to fix/find a problem with the FD100/256MB
-rw-r--r--libmpio/mpio.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/libmpio/mpio.c b/libmpio/mpio.c
index b112143..6727490 100644
--- a/libmpio/mpio.c
+++ b/libmpio/mpio.c
@@ -1,6 +1,6 @@
/*
*
- * $Id: mpio.c,v 1.45 2003/03/25 23:56:52 germeier Exp $
+ * $Id: mpio.c,v 1.46 2003/04/03 21:48:25 germeier Exp $
*
* Library for USB MPIO-*
*
@@ -128,10 +128,8 @@ mpio_init_internal(mpio_t *m)
sm->manufacturer = m->version[i_offset];
sm->id = m->version[i_offset + 1];
sm->chips = 1;
- if (mpio_id_valid(m->version[i_offset]))
- {
- sm->size = mpio_id2mem(sm->id);
- } else {
+ if (!(mpio_id_valid(m->version[i_offset])))
+ {
sm->manufacturer = 0;
sm->id = 0;
sm->size = 0;
@@ -163,21 +161,30 @@ mpio_init_internal(mpio_t *m)
}
sm->size = sm->chips * mpio_id2mem(sm->id);
+ debugn(2, "found %d chip(s) with %d MB => %d MB internal mem\n",
+ sm->chips, mpio_id2mem(sm->id), sm->size);
/* used for size calculations (see mpio_memory_free) */
mpio_id2geo(sm->id, &sm->geo);
/* read FAT information from spare area */
- sm->max_cluster = sm->size / 16 * 1024; /* 1 cluster == 16 KB */
+ sm->max_cluster = (sm->size * 1024) / 16; /* 1 cluster == 16 KB */
sm->max_blocks = sm->max_cluster;
debugn(2, "max_cluster: %d\n", sm->max_cluster);
/* 16 bytes per cluster */
- sm->fat_size = sm->max_cluster * 16 / SECTOR_SIZE;
+ sm->fat_size = (sm->max_cluster * 16) / SECTOR_SIZE;
debugn(2, "fat_size: %04x\n", sm->fat_size * SECTOR_SIZE);
sm->fat = malloc(sm->fat_size * SECTOR_SIZE);
/* fat will be read in mpio_init, so we can more easily handle
a callback function */
+ if (!(sm->fat_size))
+ {
+ printf("Some values on the way to the FAT calculations did not compute. :-(\n");
+ mpio_bail_out();
+ }
+
+
/* Read directory from internal memory */
sm->dir_offset=0;
mpio_rootdir_read(m, MPIO_INTERNAL_MEM);