Module Name:    src
Committed By:   rkujawa
Date:           Sat Nov  5 17:44:25 UTC 2011

Modified Files:
        src/sys/arch/amiga/dev: efa.c

Log Message:
Simplify bus space mapping.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/amiga/dev/efa.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/dev/efa.c
diff -u src/sys/arch/amiga/dev/efa.c:1.4 src/sys/arch/amiga/dev/efa.c:1.5
--- src/sys/arch/amiga/dev/efa.c:1.4	Sun Oct 30 11:10:42 2011
+++ src/sys/arch/amiga/dev/efa.c	Sat Nov  5 17:44:25 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: efa.c,v 1.4 2011/10/30 11:10:42 rkujawa Exp $ */
+/*	$NetBSD: efa.c,v 1.5 2011/11/05 17:44:25 rkujawa Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -104,10 +104,6 @@ static const unsigned int	wdr_offsets_pi
     { FATA1_PION_OFF_DATA, FATA1_PION_OFF_ERROR, FATA1_PION_OFF_SECCNT,
       FATA1_PION_OFF_SECTOR, FATA1_PION_OFF_CYL_LO, FATA1_PION_OFF_CYL_HI,
       FATA1_PION_OFF_SDH, FATA1_PION_OFF_COMMAND };
-static const unsigned int	wdr_offsets_pion32[] =
-    { FATA1_PION_OFF_DATA32, FATA1_PION_OFF_ERROR, FATA1_PION_OFF_SECCNT,
-      FATA1_PION_OFF_SECTOR, FATA1_PION_OFF_CYL_LO, FATA1_PION_OFF_CYL_HI,
-      FATA1_PION_OFF_SDH, FATA1_PION_OFF_COMMAND };
 
 int
 efa_probe(device_t parent, cfdata_t cfp, void *aux)
@@ -439,48 +435,27 @@ efa_mapreg_native(struct efa_softc *sc) 
 static void
 efa_fata_subregion_pio0(struct wdc_regs *wdr_fata) 
 {
+	int i;
 
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_DATA, 4, &wdr_fata->cmd_iohs[wd_data]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_ERROR, 1, &wdr_fata->cmd_iohs[wd_error]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_SECCNT, 1, &wdr_fata->cmd_iohs[wd_seccnt]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_SECTOR, 1, &wdr_fata->cmd_iohs[wd_sector]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_CYL_LO, 1, &wdr_fata->cmd_iohs[wd_cyl_lo]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_CYL_HI, 1, &wdr_fata->cmd_iohs[wd_cyl_hi]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_SDH, 1, &wdr_fata->cmd_iohs[wd_sdh]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PIO0_OFF_COMMAND, 1, &wdr_fata->cmd_iohs[wd_command]);
+	for (i = 0; i < WDC_NREG; i++) 
+		bus_space_subregion(wdr_fata->cmd_iot,
+		    wdr_fata->cmd_baseioh, wdr_offsets_pio0[i], 
+		    i == 0 ? 4 : 1, &wdr_fata->cmd_iohs[i]);
 }
 
 static void
 efa_fata_subregion_pion(struct wdc_regs *wdr_fata, bool data32) 
 {
+	int i;
+
 	if (data32)
 		bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
 		    FATA1_PION_OFF_DATA32, 8, &wdr_fata->data32ioh);
 
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-    	    FATA1_PION_OFF_DATA, 4, &wdr_fata->cmd_iohs[wd_data]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PION_OFF_ERROR, 1, &wdr_fata->cmd_iohs[wd_error]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PION_OFF_SECCNT, 1, &wdr_fata->cmd_iohs[wd_seccnt]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PION_OFF_SECTOR, 1, &wdr_fata->cmd_iohs[wd_sector]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PION_OFF_CYL_LO, 1, &wdr_fata->cmd_iohs[wd_cyl_lo]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PION_OFF_CYL_HI, 1, &wdr_fata->cmd_iohs[wd_cyl_hi]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PION_OFF_SDH, 1, &wdr_fata->cmd_iohs[wd_sdh]);
-	bus_space_subregion(wdr_fata->cmd_iot, wdr_fata->cmd_baseioh, 
-	    FATA1_PION_OFF_COMMAND, 1, &wdr_fata->cmd_iohs[wd_command]);
+	for (i = 0; i < WDC_NREG; i++) 
+		bus_space_subregion(wdr_fata->cmd_iot,
+		    wdr_fata->cmd_baseioh, wdr_offsets_pion[i], 
+		    i == 0 ? 4 : 1, &wdr_fata->cmd_iohs[i]);
 }
 
 static void

Reply via email to