Module Name:    src
Committed By:   tsutsui
Date:           Sat May 16 05:51:58 UTC 2009

Modified Files:
        src/sys/dev/ic: ninjascsi32.c

Log Message:
- fix one more device_t/softc split botch in debug code
- use sc->sc_dev to get device_t
- fix inconsistent aprint_error_dev(9) usage
- some KNF and wrap long lines


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/ninjascsi32.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/dev/ic/ninjascsi32.c
diff -u src/sys/dev/ic/ninjascsi32.c:1.19 src/sys/dev/ic/ninjascsi32.c:1.20
--- src/sys/dev/ic/ninjascsi32.c:1.19	Sat May 16 05:26:31 2009
+++ src/sys/dev/ic/ninjascsi32.c	Sat May 16 05:51:58 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: ninjascsi32.c,v 1.19 2009/05/16 05:26:31 tsutsui Exp $	*/
+/*	$NetBSD: ninjascsi32.c,v 1.20 2009/05/16 05:51:58 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ninjascsi32.c,v 1.19 2009/05/16 05:26:31 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ninjascsi32.c,v 1.20 2009/05/16 05:51:58 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -459,7 +459,8 @@
 	if ((error = bus_dmamem_alloc(sc->sc_dmat,
 	    sizeof(struct njsc32_dma_page), PAGE_SIZE, 0,
 	    &sc->sc_cmdpg_seg, 1, &sc->sc_cmdpg_nsegs, BUS_DMA_NOWAIT)) != 0) {
-		aprint_error_dev(sc->sc_dev, "unable to allocate cmd page, error = %d\n",
+		aprint_error_dev(sc->sc_dev,
+		    "unable to allocate cmd page, error = %d\n",
 		    error);
 		return 0;
 	}
@@ -467,7 +468,8 @@
 	    sc->sc_cmdpg_nsegs, sizeof(struct njsc32_dma_page),
 	    (void **)&sc->sc_cmdpg,
 	    BUS_DMA_NOWAIT | BUS_DMA_COHERENT)) != 0) {
-		aprint_error_dev(sc->sc_dev, "unable to map cmd page, error = %d\n",
+		aprint_error_dev(sc->sc_dev,
+		    "unable to map cmd page, error = %d\n",
 		    error);
 		goto fail1;
 	}
@@ -475,14 +477,16 @@
 	    sizeof(struct njsc32_dma_page), 1,
 	    sizeof(struct njsc32_dma_page), 0, BUS_DMA_NOWAIT,
 	    &sc->sc_dmamap_cmdpg)) != 0) {
-		aprint_error_dev(sc->sc_dev, "unable to create cmd DMA map, error = %d\n",
+		aprint_error_dev(sc->sc_dev,
+		    "unable to create cmd DMA map, error = %d\n",
 		    error);
 		goto fail2;
 	}
 	if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap_cmdpg,
 	    sc->sc_cmdpg, sizeof(struct njsc32_dma_page),
 	    NULL, BUS_DMA_NOWAIT)) != 0) {
-		aprint_error_dev(sc->sc_dev, "unable to load cmd DMA map, error = %d\n",
+		aprint_error_dev(sc->sc_dev,
+		    "unable to load cmd DMA map, error = %d\n",
 		    error);
 		goto fail3;
 	}
@@ -509,7 +513,8 @@
 		    0,				/* boundary */
 		    BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &cmd->c_dmamap_xfer);
 		if (error) {
-			aprint_error_dev(sc->sc_dev, "only %d cmd descs available (error = %d)\n",
+			aprint_error_dev(sc->sc_dev,
+			    "only %d cmd descs available (error = %d)\n",
 			    i, error);
 			break;
 		}
@@ -1149,8 +1154,8 @@
 		default:
 			xs->error = XS_DRIVER_STUFFUP;
 		map_failed:
-			aprint_error_dev(sc->sc_dev, "njsc32_run_xfer: map failed, error %d\n",
-			    error);
+			printf("%s: njsc32_run_xfer: map failed, error %d\n",
+			    device_xname(sc->sc_dev), error);
 			/* put it back to free command list */
 			s = splbio();
 			TAILQ_INSERT_HEAD(&sc->sc_freecmd, cmd, c_q);
@@ -1352,7 +1357,8 @@
 		case NJSC32_STAT_RESET1:
 			/* print message if Bus Reset is detected twice */
 			sc->sc_stat = NJSC32_STAT_RESET2;
-			printf("%s: detected excessive bus reset --- missing termination power?\n",
+			printf("%s: detected excessive bus reset "
+			    "--- missing termination power?\n",
 			    device_xname(sc->sc_dev));
 			break;
 		default:
@@ -1499,8 +1505,8 @@
 		/* transfer done */
 #if 1 /*def DIAGNOSTIC*/
 		if (pos > cmd->c_datacnt)
-			aprint_error_dev(sc->sc_dev, "pos %u too large\n",
-			    pos - cmd->c_datacnt);
+			printf("%s: pos %u too large\n",
+			    device_xname(sc->sc_dev), pos - cmd->c_datacnt);
 #endif
 		cmd->c_xferctl = 0;	/* XXX correct? */
 
@@ -1587,7 +1593,8 @@
 			return;
 		delay(1);
 	}
-	printf("%s: njsc32_wait_req_negate: timed out\n", device_xname(sc->sc_dev));
+	printf("%s: njsc32_wait_req_negate: timed out\n",
+	    device_xname(sc->sc_dev));
 }
 
 static void
@@ -1629,7 +1636,8 @@
 		    NJSC32_RESEL_THROUGH : NJSC32_RESEL_ERROR;
 
 	default:
-		aprint_error_dev(sc->sc_dev, "njsc32_resel_identify: not in reselection\n");
+		printf("%s: njsc32_resel_identify: not in reselection\n",
+		    device_xname(sc->sc_dev));
 		return NJSC32_RESEL_ERROR;
 	}
 
@@ -1775,7 +1783,7 @@
 	if (njsc32_read_1(sc, NJSC32_REG_PARITY_STATUS) &
 	    NJSC32_PARITYSTATUS_ERROR_LSB) {
 
-		aprint_error_dev(sc->sc_dev, "msgin: parity error\n");
+		printf("%s: msgin: parity error\n", device_xname(sc->sc_dev));
 
 		/* clear parity error */
 		njsc32_write_1(sc, NJSC32_REG_PARITY_CONTROL,
@@ -1821,7 +1829,8 @@
 			/*
 			 * invalid Simple Queue Tag -> Abort Tag
 			 */
-			printf("%s: msgin: invalid tag\n", device_xname(sc->sc_dev));
+			printf("%s: msgin: invalid tag\n",
+			    device_xname(sc->sc_dev));
 			njsc32_add_msgout(sc, MSG_ABORT_TAG);
 			goto reply;
 		}
@@ -1922,7 +1931,8 @@
 			offset = sc->sc_msginbuf[EXTCODEOFF + 2];
 			if (offset > NJSC32_SYNCOFFSET_MAX) {
 				if (target->t_state == NJSC32_TARST_SDTR) {
-					aprint_error_dev(cmd->c_xs->xs_periph->periph_dev, "wrong sync offset: %d\n", offset);
+					printf("%s: wrong sync offset: %d\n",
+					    device_xname(sc->sc_dev), offset);
 					/* XXX what to do? */
 				}
 				offset = NJSC32_SYNCOFFSET_MAX;
@@ -1978,7 +1988,8 @@
 			case NJSC32_TARST_WDTR:
 				if (sc->sc_msginbuf[EXTCODEOFF + 1] !=
 				    MSG_EXT_WDTR_BUS_8_BIT) {
-					aprint_error_dev(cmd->c_xs->xs_periph->periph_dev, "unexpected transfer width: %#x\n",
+					printf("%s: unexpected transfer width:"
+					    " %#x\n", device_xname(sc->sc_dev),
 					    sc->sc_msginbuf[EXTCODEOFF + 1]);
 					/* XXX what to do? */
 				}
@@ -2059,8 +2070,8 @@
 #ifdef NJSC32_DUALEDGE
 		target = cmd->c_target;
 		if (target->t_state == NJSC32_TARST_DE) {
-			aprint_normal_dev(&cmd->c_xs->xs_periph->periph_dev,
-				"%s: DualEdge transfer\n");
+			printf("%s: DualEdge transfer\n",
+			    device_xname(sc->sc_dev));
 			target->t_xferctl = NJSC32_XFR_DUALEDGE_ENABLE;
 			/* go to next negotiation */
 			target->t_state = NJSC32_TARST_SDTR;
@@ -2417,7 +2428,8 @@
 		njsc32_arbitration_failed(sc);	/* just in case */
 		if ((cmd = sc->sc_curcmd) != NULL) {
 			/* ? */
-			aprint_error_dev(sc->sc_dev, "unexpected reselection\n");
+			printf("%s: unexpected reselection\n",
+			    device_xname(sc->sc_dev));
 			sc->sc_curcmd = NULL;
 			sc->sc_stat = NJSC32_STAT_IDLE;
 			njsc32_end_cmd(sc, cmd, XS_DRIVER_STUFFUP);
@@ -2427,8 +2439,8 @@
 		if ((idbit & (1 << NJSC32_INITIATOR_ID)) == 0 ||
 		    (sc->sc_reselid =
 		     ffs(idbit & ~(1 << NJSC32_INITIATOR_ID)) - 1) < 0) {
-			aprint_error_dev(sc->sc_dev, "invalid reselection (id: %#x)\n",
-			    idbit);
+			printf("%s: invalid reselection (id: %#x)\n",
+			    device_xname(sc->sc_dev), idbit);
 			sc->sc_stat = NJSC32_STAT_IDLE;	/* XXX ? */
 		} else {
 			sc->sc_stat = NJSC32_STAT_RESEL;
@@ -2468,7 +2480,8 @@
 			}
 			break;
 		case NJSC32_PHASE_BUSFREE:
-			aprint_error_dev(sc->sc_dev, "unexpected bus phase: Bus Free\n");
+			printf("%s: unexpected bus phase: Bus Free\n",
+			    device_xname(sc->sc_dev));
 			if ((cmd = sc->sc_curcmd) != NULL) {
 				sc->sc_curcmd = NULL;
 				sc->sc_stat = NJSC32_STAT_IDLE;
@@ -2484,20 +2497,27 @@
 			    device_xname(sc->sc_dev));
 			switch (bus_phase) {
 			case NJSC32_PHASE_COMMAND:
-				printf("Command\n");	break;
+				printf("Command\n");
+				break;
 			case NJSC32_PHASE_MESSAGE_OUT:
-				printf("Message Out\n");break;
+				printf("Message Out\n");
+				break;
 			case NJSC32_PHASE_DATA_IN:
-				printf("Data In\n");	break;
+				printf("Data In\n");
+				break;
 			case NJSC32_PHASE_DATA_OUT:
-				printf("Data Out\n");	break;
+				printf("Data Out\n");
+				break;
 			case NJSC32_PHASE_RESELECT:
-				printf("Reselect\n");break;
-			default: printf("%#x\n", bus_phase);	break;
+				printf("Reselect\n");
+				break;
+			default:
+				printf("%#x\n", bus_phase);
+				break;
 			}
 #else
-			aprint_error_dev(sc->sc_dev, "unexpected bus phase: %#x",
-			    bus_phase);
+			printf("%s: unexpected bus phase: %#x",
+			    device_xname(sc->sc_dev), bus_phase);
 #endif
 			break;
 		}
@@ -2515,7 +2535,8 @@
 		if (auto_phase & NJSC32_XPHASE_SEL_TIMEOUT) {
 			cmd = sc->sc_curcmd;
 			if (cmd == NULL) {
-				aprint_error_dev(sc->sc_dev, "sel no cmd\n");
+				printf("%s: sel no cmd\n",
+				    device_xname(sc->sc_dev));
 				goto out;
 			}
 			DPRINTC(cmd, ("njsc32_intr: selection timeout\n"));
@@ -2570,10 +2591,10 @@
 			if (auto_phase & NJSC32_XPHASE_DATA_OUT)
 				PRINTC(cmd, ("njsc32_intr: data out done\n"));
 			printf("BM %u, SGT %u, SACK %u, SAVED_ACK %u\n",
-				njsc32_read_4(sc, NJSC32_REG_BM_CNT),
-				njsc32_read_4(sc, NJSC32_REG_SGT_ADR),
-				njsc32_read_4(sc, NJSC32_REG_SACK_CNT),
-				njsc32_read_4(sc, NJSC32_REG_SAVED_ACK_CNT));
+			    njsc32_read_4(sc, NJSC32_REG_BM_CNT),
+			    njsc32_read_4(sc, NJSC32_REG_SGT_ADR),
+			    njsc32_read_4(sc, NJSC32_REG_SACK_CNT),
+			    njsc32_read_4(sc, NJSC32_REG_SAVED_ACK_CNT));
 #endif
 
 			/*
@@ -2602,7 +2623,8 @@
 				} else {
 					/* XXX does this case occur? */
 #if 1
-					aprint_error_dev(sc->sc_dev, "datain: parity error\n");
+					printf("%s: datain: parity error\n",
+					    device_xname(sc->sc_dev));
 #endif
 					/*
 					 * Make attention condition and try

Reply via email to