Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x68k/dev - check bus_space_map(9) return value



details:   https://anonhg.NetBSD.org/src/rev/2855c259fa16
branches:  trunk
changeset: 779274:2855c259fa16
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Tue May 15 12:17:33 2012 +0000

description:
- check bus_space_map(9) return value
- use BUS_SPACE_MAP_SHIFTED_ODD for clarify
- define and use proper macro instead of magic

diffstat:

 sys/arch/x68k/dev/fd.c    |  16 ++++++++++------
 sys/arch/x68k/dev/fdreg.h |   3 ++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diffs (64 lines):

diff -r 9cfc8a311c3d -r 2855c259fa16 sys/arch/x68k/dev/fd.c
--- a/sys/arch/x68k/dev/fd.c    Tue May 15 12:14:59 2012 +0000
+++ b/sys/arch/x68k/dev/fd.c    Tue May 15 12:17:33 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $ */
+/*     $NetBSD: fd.c,v 1.101 2012/05/15 12:17:33 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.100 2012/05/13 03:00:40 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fd.c,v 1.101 2012/05/15 12:17:33 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "opt_m68k_arch.h"
@@ -377,7 +377,7 @@
        if ((ia->ia_intr & 0x03) != 0)
                return 0;
 
-       ia->ia_size = 0x2000;
+       ia->ia_size = FDC_MAPSIZE;
        if (intio_map_allocate_region(parent, ia, INTIO_MAP_TESTONLY))
                return 0;
 
@@ -423,12 +423,16 @@
 
        aprint_normal("\n");
 
+       /* Re-map the I/O space. */
+       if (bus_space_map(iot, ia->ia_addr, ia->ia_size,
+           BUS_SPACE_MAP_SHIFTED_ODD, &ioh) != 0) {
+               aprint_error_dev(self, "unable to map I/O space\n");
+               return;
+       }
+
        callout_init(&fdc->sc_timo_ch, 0);
        callout_init(&fdc->sc_intr_ch, 0);
 
-       /* Re-map the I/O space. */
-       bus_space_map(iot, ia->ia_addr, 0x2000, BUS_SPACE_MAP_SHIFTED, &ioh);
-
        fdc->sc_iot = iot;
        fdc->sc_ioh = ioh;
        fdc->sc_addr = (void *)ia->ia_addr;
diff -r 9cfc8a311c3d -r 2855c259fa16 sys/arch/x68k/dev/fdreg.h
--- a/sys/arch/x68k/dev/fdreg.h Tue May 15 12:14:59 2012 +0000
+++ b/sys/arch/x68k/dev/fdreg.h Tue May 15 12:17:33 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fdreg.h,v 1.4 2005/12/11 12:19:37 christos Exp $       */
+/*     $NetBSD: fdreg.h,v 1.5 2012/05/15 12:17:33 tsutsui Exp $        */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -56,6 +56,7 @@
 
 /* default attach args */
 #define FDC_ADDR 0xe94000      /* builtin fdc is here */
+#define FDC_MAPSIZE 0x2000     /* builtin fdc I/O range */
 #define FDC_INTR 96            /* interrupt vector */
 #define FDC_DMA 0              /* DMA ch# */
 #define FDC_DMAINTR 100                /* DMA interrupt vector */



Home | Main Index | Thread Index | Old Index