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

MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2012-03-01 20:25:17 +00:00
parent 9415d1e0ac
commit 0e03919dc4

View File

@ -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_config[UMASS_T_BBB_MAX] = {
.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_config[UMASS_T_BBB_MAX] = {
.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_config[UMASS_T_CBI_MAX] = {
.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_config[UMASS_T_CBI_MAX] = {
.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,9 +1045,7 @@ umass_detach(device_t dev)
usbd_transfer_unsetup(sc->sc_xfer, UMASS_T_MAX);
#if (__FreeBSD_version >= 700037)
mtx_lock(&sc->sc_mtx);
#endif
/* cancel any leftover CCB's */
@ -1063,9 +1053,8 @@ umass_detach(device_t dev)
umass_cam_detach_sim(sc);
#if (__FreeBSD_version >= 700037)
mtx_unlock(&sc->sc_mtx);
#endif
mtx_destroy(&sc->sc_mtx);
return (0); /* success */
@ -1206,7 +1195,6 @@ umass_t_bbb_reset1_callback(struct usb_xfer *xfer, usb_error_t error)
default: /* Error */
umass_tr_error(xfer, error);
return;
}
}
@ -1245,7 +1233,6 @@ umass_t_bbb_data_clear_stall_callback(struct usb_xfer *xfer,
default: /* Error */
umass_tr_error(xfer, error);
return;
}
}
@ -1331,7 +1318,6 @@ umass_t_bbb_command_callback(struct usb_xfer *xfer, usb_error_t error)
default: /* Error */
umass_tr_error(xfer, error);
return;
}
}
@ -1340,19 +1326,12 @@ umass_t_bbb_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
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;
@ -1374,12 +1353,9 @@ umass_t_bbb_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
}
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;
@ -1390,7 +1366,6 @@ umass_t_bbb_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
umass_transfer_start(sc, UMASS_T_BBB_DATA_RD_CS);
}
return;
}
}
@ -1406,9 +1381,6 @@ umass_t_bbb_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
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);
@ -1436,14 +1408,8 @@ umass_t_bbb_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
}
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;
@ -1455,7 +1421,6 @@ umass_t_bbb_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
umass_transfer_start(sc, UMASS_T_BBB_DATA_WR_CS);
}
return;
}
}
@ -1581,7 +1546,6 @@ umass_t_bbb_status_callback(struct usb_xfer *xfer, usb_error_t error)
umass_transfer_start(sc, UMASS_T_BBB_DATA_RD_CS);
}
return;
}
}
@ -1732,7 +1696,6 @@ umass_t_cbi_reset1_callback(struct usb_xfer *xfer, usb_error_t error)
else
umass_transfer_start(sc, UMASS_T_CBI_RESET2);
break;
}
}
@ -1787,7 +1750,6 @@ umass_t_cbi_data_clear_stall_callback(struct usb_xfer *xfer,
default: /* Error */
umass_tr_error(xfer, error);
break;
}
}
@ -1877,19 +1839,12 @@ umass_t_cbi_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
{
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;
@ -1911,12 +1866,9 @@ umass_t_cbi_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
}
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;
@ -1928,7 +1880,6 @@ umass_t_cbi_data_read_callback(struct usb_xfer *xfer, usb_error_t error)
umass_transfer_start(sc, UMASS_T_CBI_DATA_RD_CS);
}
break;
}
}
@ -1944,9 +1895,6 @@ umass_t_cbi_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
{
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);
@ -1974,14 +1922,8 @@ umass_t_cbi_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
}
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;
@ -1994,7 +1936,6 @@ umass_t_cbi_data_write_callback(struct usb_xfer *xfer, usb_error_t error)
umass_transfer_start(sc, UMASS_T_CBI_DATA_WR_CS);
}
break;
}
}
@ -2096,7 +2037,6 @@ umass_t_cbi_status_callback(struct usb_xfer *xfer, usb_error_t error)
usbd_errstr(error));
umass_tr_error(xfer, error);
break;
}
}
@ -2125,9 +2065,7 @@ umass_cam_attach_sim(struct umass_softc *sc)
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);
@ -2137,27 +2075,15 @@ umass_cam_attach_sim(struct umass_softc *sc)
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);
}
@ -2208,11 +2134,6 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
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
@ -2415,12 +2336,11 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
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;
@ -2472,16 +2392,12 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
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;
@ -2524,11 +2440,6 @@ umass_cam_action(struct cam_sim *sim, union ccb *ccb)
}
done:
#if (__FreeBSD_version < 700037)
if (sc) {
mtx_unlock(&sc->sc_mtx);
}
#endif
return;
}