summaryrefslogtreecommitdiff
path: root/bus.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-22 07:43:42 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-22 07:43:42 -0400
commitd51639c91c2aca7db6df8150ab438b6cbf62227a (patch)
treee203a99dd75820a0276b3c6b4961fed0ed673cba /bus.c
parentb3dd947ffd8b1b8c54313a848c203cbe3afeec94 (diff)
Don't crash due to gpmc failure on desktop
Diffstat (limited to 'bus.c')
-rw-r--r--bus.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/bus.c b/bus.c
index c45fda6..da5243a 100644
--- a/bus.c
+++ b/bus.c
@@ -183,19 +183,21 @@ static void gpmc_setup(int chipselect, int accesscycles, int size, bool enablecs
gpmc_mapregisters();
- // disable before playing with the registers..
- *(registers + displacement + GPMC_CONFIG7) = 0x0;
-
- *(registers + displacement + GPMC_CONFIG1) = 0x0;
- *(registers + displacement + GPMC_CONFIG2) = (accesscycles << CSWROFFTIME) | (accesscycles << CSRDOFFTIME);
- *(registers + displacement + GPMC_CONFIG3) = 0x0; // not using ADV so we can ignore this guy
- *(registers + displacement + GPMC_CONFIG4) = (accesscycles << OEOFFTIME);
- *(registers + displacement + GPMC_CONFIG5) = (accesscycles << RDACCESSTIME) | (accesscycles << WRCYCLETIME)
- | (accesscycles << RDCYCLETIME);
- *(registers + displacement + GPMC_CONFIG6) = (accesscycles << WRACCESSTIME);
- *(registers + displacement + GPMC_CONFIG7) = size << 8 | (enablecs ? 1 << 6 : 0) | baseaddress;
-
- gpmc_unmapregisters();
+ if (registers != MAP_FAILED) {
+ // disable before playing with the registers..
+ *(registers + displacement + GPMC_CONFIG7) = 0x0;
+
+ *(registers + displacement + GPMC_CONFIG1) = 0x0;
+ *(registers + displacement + GPMC_CONFIG2) = (accesscycles << CSWROFFTIME) | (accesscycles << CSRDOFFTIME);
+ *(registers + displacement + GPMC_CONFIG3) = 0x0; // not using ADV so we can ignore this guy
+ *(registers + displacement + GPMC_CONFIG4) = (accesscycles << OEOFFTIME);
+ *(registers + displacement + GPMC_CONFIG5) = (accesscycles << RDACCESSTIME) | (accesscycles << WRCYCLETIME)
+ | (accesscycles << RDCYCLETIME);
+ *(registers + displacement + GPMC_CONFIG6) = (accesscycles << WRACCESSTIME);
+ *(registers + displacement + GPMC_CONFIG7) = size << 8 | (enablecs ? 1 << 6 : 0) | baseaddress;
+
+ gpmc_unmapregisters();
+ }
}
/*