svn commit: r240661 - stable/9/sys/dev/usb/storage

Hans Petter Selasky hselasky at FreeBSD.org
Tue Sep 18 16:37:12 UTC 2012


Author: hselasky
Date: Tue Sep 18 16:37:11 2012
New Revision: 240661
URL: http://svn.freebsd.org/changeset/base/240661

Log:
  MFC r232361:
  Style change: Expand redundant #if's. Remove a couple of empty lines.

Modified:
  stable/9/sys/dev/usb/storage/umass.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/usb/storage/umass.c
==============================================================================
--- stable/9/sys/dev/usb/storage/umass.c	Tue Sep 18 16:33:53 2012	(r240660)
+++ stable/9/sys/dev/usb/storage/umass.c	Tue Sep 18 16:37:11 2012	(r240661)
@@ -137,14 +137,6 @@ __FBSDID("$FreeBSD$");
 
 #include <cam/cam_periph.h>
 
-#define UMASS_EXT_BUFFER
-#ifdef UMASS_EXT_BUFFER
-/* this enables loading of virtual buffers into DMA */
-#define	UMASS_USB_FLAGS .ext_buffer=1,
-#else
-#define	UMASS_USB_FLAGS
-#endif
-
 #ifdef USB_DEBUG
 #define	DIF(m, x)				\
   do {						\
@@ -542,7 +534,7 @@ static struct usb_config umass_bbb_confi
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
 		.bufsize = UMASS_BULK_SIZE,
-		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1, UMASS_USB_FLAGS},
+		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1,.ext_buffer=1,},
 		.callback = &umass_t_bbb_data_read_callback,
 		.timeout = 0,	/* overwritten later */
 	},
@@ -561,7 +553,7 @@ static struct usb_config umass_bbb_confi
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
 		.bufsize = UMASS_BULK_SIZE,
-		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1, UMASS_USB_FLAGS},
+		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1,.ext_buffer=1,},
 		.callback = &umass_t_bbb_data_write_callback,
 		.timeout = 0,	/* overwritten later */
 	},
@@ -634,7 +626,7 @@ static struct usb_config umass_cbi_confi
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
 		.bufsize = UMASS_BULK_SIZE,
-		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1, UMASS_USB_FLAGS},
+		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1,.ext_buffer=1,},
 		.callback = &umass_t_cbi_data_read_callback,
 		.timeout = 0,	/* overwritten later */
 	},
@@ -653,7 +645,7 @@ static struct usb_config umass_cbi_confi
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
 		.bufsize = UMASS_BULK_SIZE,
-		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1, UMASS_USB_FLAGS},
+		.flags = {.proxy_buffer = 1,.short_xfer_ok = 1,.ext_buffer=1,},
 		.callback = &umass_t_cbi_data_write_callback,
 		.timeout = 0,	/* overwritten later */
 	},
@@ -1053,14 +1045,11 @@ umass_detach(device_t dev)
 
 	usbd_transfer_unsetup(sc->sc_xfer, UMASS_T_MAX);
 
-#if (__FreeBSD_version >= 700037)
 	mtx_lock(&sc->sc_mtx);
-#endif
 	umass_cam_detach_sim(sc);
 
-#if (__FreeBSD_version >= 700037)
 	mtx_unlock(&sc->sc_mtx);
-#endif
+
 	mtx_destroy(&sc->sc_mtx);
 
 	return (0);			/* success */
@@ -1201,7 +1190,6 @@ umass_t_bbb_reset1_callback(struct usb_x
 	default:			/* Error */
 		umass_tr_error(xfer, error);
 		return;
-
 	}
 }
 
@@ -1240,7 +1228,6 @@ tr_transferred:
 	default:			/* Error */
 		umass_tr_error(xfer, error);
 		return;
-
 	}
 }
 
@@ -1326,7 +1313,6 @@ umass_t_bbb_command_callback(struct usb_
 	default:			/* Error */
 		umass_tr_error(xfer, error);
 		return;
-
 	}
 }
 
@@ -1335,19 +1321,12 @@ umass_t_bbb_data_read_callback(struct us
 {
 	struct umass_softc *sc = usbd_xfer_softc(xfer);
 	uint32_t max_bulk = usbd_xfer_max_len(xfer);
-#ifndef UMASS_EXT_BUFFER
-	struct usb_page_cache *pc;
-#endif
 	int actlen, sumlen;
 
 	usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
 
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
-#ifndef UMASS_EXT_BUFFER
-		pc = usbd_xfer_get_frame(xfer, 0);
-		usbd_copy_out(pc, 0, sc->sc_transfer.data_ptr, actlen);
-#endif
 		sc->sc_transfer.data_rem -= actlen;
 		sc->sc_transfer.data_ptr += actlen;
 		sc->sc_transfer.actlen += actlen;
@@ -1369,12 +1348,9 @@ umass_t_bbb_data_read_callback(struct us
 		}
 		usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
 
-#ifdef UMASS_EXT_BUFFER
 		usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
 		    max_bulk);
-#else
-		usbd_xfer_set_frame_len(xfer, 0, max_bulk);
-#endif
+
 		usbd_transfer_submit(xfer);
 		return;
 
@@ -1385,7 +1361,6 @@ umass_t_bbb_data_read_callback(struct us
 			umass_transfer_start(sc, UMASS_T_BBB_DATA_RD_CS);
 		}
 		return;
-
 	}
 }
 
@@ -1401,9 +1376,6 @@ umass_t_bbb_data_write_callback(struct u
 {
 	struct umass_softc *sc = usbd_xfer_softc(xfer);
 	uint32_t max_bulk = usbd_xfer_max_len(xfer);
-#ifndef UMASS_EXT_BUFFER
-	struct usb_page_cache *pc;
-#endif
 	int actlen, sumlen;
 
 	usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
@@ -1431,14 +1403,8 @@ umass_t_bbb_data_write_callback(struct u
 		}
 		usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
 
-#ifdef UMASS_EXT_BUFFER
 		usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
 		    max_bulk);
-#else
-		pc = usbd_xfer_get_frame(xfer, 0);
-		usbd_copy_in(pc, 0, sc->sc_transfer.data_ptr, max_bulk);
-		usbd_xfer_set_frame_len(xfer, 0, max_bulk);
-#endif
 
 		usbd_transfer_submit(xfer);
 		return;
@@ -1450,7 +1416,6 @@ umass_t_bbb_data_write_callback(struct u
 			umass_transfer_start(sc, UMASS_T_BBB_DATA_WR_CS);
 		}
 		return;
-
 	}
 }
 
@@ -1576,7 +1541,6 @@ tr_error:
 			umass_transfer_start(sc, UMASS_T_BBB_DATA_RD_CS);
 		}
 		return;
-
 	}
 }
 
@@ -1728,7 +1692,6 @@ umass_t_cbi_reset1_callback(struct usb_x
 		else
 			umass_transfer_start(sc, UMASS_T_CBI_RESET2);
 		break;
-
 	}
 }
 
@@ -1783,7 +1746,6 @@ tr_transferred:
 	default:			/* Error */
 		umass_tr_error(xfer, error);
 		break;
-
 	}
 }
 
@@ -1873,19 +1835,12 @@ umass_t_cbi_data_read_callback(struct us
 {
 	struct umass_softc *sc = usbd_xfer_softc(xfer);
 	uint32_t max_bulk = usbd_xfer_max_len(xfer);
-#ifndef UMASS_EXT_BUFFER
-	struct usb_page_cache *pc;
-#endif
 	int actlen, sumlen;
 
 	usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
 
 	switch (USB_GET_STATE(xfer)) {
 	case USB_ST_TRANSFERRED:
-#ifndef UMASS_EXT_BUFFER
-		pc = usbd_xfer_get_frame(xfer, 0);
-		usbd_copy_out(pc, 0, sc->sc_transfer.data_ptr, actlen);
-#endif
 		sc->sc_transfer.data_rem -= actlen;
 		sc->sc_transfer.data_ptr += actlen;
 		sc->sc_transfer.actlen += actlen;
@@ -1907,12 +1862,9 @@ umass_t_cbi_data_read_callback(struct us
 		}
 		usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
 
-#ifdef UMASS_EXT_BUFFER
 		usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
 		    max_bulk);
-#else
-		usbd_xfer_set_frame_len(xfer, 0, max_bulk);
-#endif
+
 		usbd_transfer_submit(xfer);
 		break;
 
@@ -1924,7 +1876,6 @@ umass_t_cbi_data_read_callback(struct us
 			umass_transfer_start(sc, UMASS_T_CBI_DATA_RD_CS);
 		}
 		break;
-
 	}
 }
 
@@ -1940,9 +1891,6 @@ umass_t_cbi_data_write_callback(struct u
 {
 	struct umass_softc *sc = usbd_xfer_softc(xfer);
 	uint32_t max_bulk = usbd_xfer_max_len(xfer);
-#ifndef UMASS_EXT_BUFFER
-	struct usb_page_cache *pc;
-#endif
 	int actlen, sumlen;
 
 	usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
@@ -1970,14 +1918,8 @@ umass_t_cbi_data_write_callback(struct u
 		}
 		usbd_xfer_set_timeout(xfer, sc->sc_transfer.data_timeout);
 
-#ifdef UMASS_EXT_BUFFER
 		usbd_xfer_set_frame_data(xfer, 0, sc->sc_transfer.data_ptr,
 		    max_bulk);
-#else
-		pc = usbd_xfer_get_frame(xfer, 0);
-		usbd_copy_in(pc, 0, sc->sc_transfer.data_ptr, max_bulk);
-		usbd_xfer_set_frame_len(xfer, 0, max_bulk);
-#endif
 
 		usbd_transfer_submit(xfer);
 		break;
@@ -1990,7 +1932,6 @@ umass_t_cbi_data_write_callback(struct u
 			umass_transfer_start(sc, UMASS_T_CBI_DATA_WR_CS);
 		}
 		break;
-
 	}
 }
 
@@ -2092,7 +2033,6 @@ tr_setup:
 		    usbd_errstr(error));
 		umass_tr_error(xfer, error);
 		break;
-
 	}
 }
 
@@ -2121,9 +2061,7 @@ umass_cam_attach_sim(struct umass_softc 
 	    DEVNAME_SIM,
 	    sc /* priv */ ,
 	    sc->sc_unit /* unit number */ ,
-#if (__FreeBSD_version >= 700037)
 	    &sc->sc_mtx /* mutex */ ,
-#endif
 	    1 /* maximum device openings */ ,
 	    0 /* maximum tagged device openings */ ,
 	    devq);
@@ -2133,27 +2071,15 @@ umass_cam_attach_sim(struct umass_softc 
 		return (ENOMEM);
 	}
 
-#if (__FreeBSD_version >= 700037)
 	mtx_lock(&sc->sc_mtx);
-#endif
 
-#if (__FreeBSD_version >= 700048)
-	if (xpt_bus_register(sc->sc_sim, sc->sc_dev, sc->sc_unit) != CAM_SUCCESS) {
+	if (xpt_bus_register(sc->sc_sim, sc->sc_dev,
+	    sc->sc_unit) != CAM_SUCCESS) {
 		mtx_unlock(&sc->sc_mtx);
 		return (ENOMEM);
 	}
-#else
-	if (xpt_bus_register(sc->sc_sim, sc->sc_unit) != CAM_SUCCESS) {
-#if (__FreeBSD_version >= 700037)
-		mtx_unlock(&sc->sc_mtx);
-#endif
-		return (ENOMEM);
-	}
-#endif
-
-#if (__FreeBSD_version >= 700037)
 	mtx_unlock(&sc->sc_mtx);
-#endif
+
 	return (0);
 }
 
@@ -2204,11 +2130,6 @@ umass_cam_action(struct cam_sim *sim, un
 		xpt_done(ccb);
 		return;
 	}
-	if (sc) {
-#if (__FreeBSD_version < 700037)
-		mtx_lock(&sc->sc_mtx);
-#endif
-	}
 	/*
 	 * Verify, depending on the operation to perform, that we either got
 	 * a valid sc, because an existing target was referenced, or
@@ -2411,12 +2332,11 @@ umass_cam_action(struct cam_sim *sim, un
 			strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
 			cpi->unit_number = cam_sim_unit(sim);
 			cpi->bus_id = sc->sc_unit;
-#if (__FreeBSD_version >= 700025)
 			cpi->protocol = PROTO_SCSI;
 			cpi->protocol_version = SCSI_REV_2;
 			cpi->transport = XPORT_USB;
 			cpi->transport_version = 0;
-#endif
+
 			if (sc == NULL) {
 				cpi->base_transfer_speed = 0;
 				cpi->max_lun = 0;
@@ -2468,16 +2388,12 @@ umass_cam_action(struct cam_sim *sim, un
 			    cam_sim_path(sc->sc_sim), ccb->ccb_h.target_id,
 			    ccb->ccb_h.target_lun);
 
-#if (__FreeBSD_version >= 700025)
 			cts->protocol = PROTO_SCSI;
 			cts->protocol_version = SCSI_REV_2;
 			cts->transport = XPORT_USB;
 			cts->transport_version = 0;
 			cts->xport_specific.valid = 0;
-#else
-			cts->valid = 0;
-			cts->flags = 0;	/* no disconnection, tagging */
-#endif
+
 			ccb->ccb_h.status = CAM_REQ_CMP;
 			xpt_done(ccb);
 			break;
@@ -2520,11 +2436,6 @@ umass_cam_action(struct cam_sim *sim, un
 	}
 
 done:
-#if (__FreeBSD_version < 700037)
-	if (sc) {
-		mtx_unlock(&sc->sc_mtx);
-	}
-#endif
 	return;
 }
 


More information about the svn-src-stable-9 mailing list