Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Aug 2008 18:25:39 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 147166 for review
Message-ID:  <200808111825.m7BIPdcQ056877@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=147166

Change 147166 by hselasky@hselasky_laptop001 on 2008/08/11 18:25:37

	
	Result from running "usb_style.sh", which is based on the 
	"indent" system utility.

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_generic.c#18 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_generic.c#18 (text+ko) ====

@@ -1398,8 +1398,8 @@
 		struct usb2_fs_open *popen;
 		struct usb2_fs_close *pclose;
 		struct usb2_fs_clear_stall_sync *pstall;
-		void *addr;
-	} u;
+		void   *addr;
+	}     u;
 	struct usb2_pipe *pipe;
 	struct usb2_endpoint_descriptor *ed;
 	int error = 0;
@@ -1411,237 +1411,237 @@
 
 	switch (cmd) {
 	case USB_FS_COMPLETE:
-			mtx_lock(f->priv_mtx);
-			error = ugen_fs_get_complete(f, &ep_index);
-			mtx_unlock(f->priv_mtx);
+		mtx_lock(f->priv_mtx);
+		error = ugen_fs_get_complete(f, &ep_index);
+		mtx_unlock(f->priv_mtx);
 
-			if (error) {
-				error = EBUSY;
-				break;
-			}
-			u.pcomp->ep_index = ep_index;
-			error = ugen_fs_copy_out(f, u.pcomp->ep_index);
+		if (error) {
+			error = EBUSY;
 			break;
+		}
+		u.pcomp->ep_index = ep_index;
+		error = ugen_fs_copy_out(f, u.pcomp->ep_index);
+		break;
 
 	case USB_FS_START:
-			error = ugen_fs_copy_in(f, u.pstart->ep_index);
-			if (error) {
-				break;
-			}
-			mtx_lock(f->priv_mtx);
-			usb2_transfer_start(f->fs_xfer[u.pstart->ep_index]);
-			mtx_unlock(f->priv_mtx);
+		error = ugen_fs_copy_in(f, u.pstart->ep_index);
+		if (error) {
 			break;
+		}
+		mtx_lock(f->priv_mtx);
+		usb2_transfer_start(f->fs_xfer[u.pstart->ep_index]);
+		mtx_unlock(f->priv_mtx);
+		break;
 
 	case USB_FS_STOP:
-			if (u.pstop->ep_index >= f->fs_ep_max) {
-				error = EINVAL;
-				break;
-			}
-			mtx_lock(f->priv_mtx);
-			usb2_transfer_stop(f->fs_xfer[u.pstop->ep_index]);
-			mtx_unlock(f->priv_mtx);
+		if (u.pstop->ep_index >= f->fs_ep_max) {
+			error = EINVAL;
 			break;
+		}
+		mtx_lock(f->priv_mtx);
+		usb2_transfer_stop(f->fs_xfer[u.pstop->ep_index]);
+		mtx_unlock(f->priv_mtx);
+		break;
 
 	case USB_FS_INIT:
-			/* verify input parameters */
-			if (u.pinit->pEndpoints == NULL) {
-				error = EINVAL;
-				break;
-			}
-			if (u.pinit->ep_index_max > 127) {
-				error = EINVAL;
-				break;
-			}
-			if (u.pinit->ep_index_max == 0) {
-				error = EINVAL;
-				break;
-			}
-			if (f->fs_xfer != NULL) {
-				error = EBUSY;
-				break;
-			}
-			if (f->flag_no_uref) {
-				error = EINVAL;
-				break;
-			}
-			if (f->dev_ep_index != 0) {
-				error = EINVAL;
-				break;
-			}
-			if (ugen_fifo_in_use(f, fflags)) {
-				error = EBUSY;
-				break;
-			}
-			error = usb2_fifo_alloc_buffer(f, 1, u.pinit->ep_index_max);
-			if (error) {
-				break;
-			}
-			f->fs_xfer = malloc(sizeof(f->fs_xfer[0]) *
-			    u.pinit->ep_index_max, M_USB, M_WAITOK | M_ZERO);
-			if (f->fs_xfer == NULL) {
-				usb2_fifo_free_buffer(f);
-				error = ENOMEM;
-				break;
-			}
-			f->fs_ep_max = u.pinit->ep_index_max;
-			f->fs_ep_ptr = u.pinit->pEndpoints;
+		/* verify input parameters */
+		if (u.pinit->pEndpoints == NULL) {
+			error = EINVAL;
+			break;
+		}
+		if (u.pinit->ep_index_max > 127) {
+			error = EINVAL;
+			break;
+		}
+		if (u.pinit->ep_index_max == 0) {
+			error = EINVAL;
+			break;
+		}
+		if (f->fs_xfer != NULL) {
+			error = EBUSY;
+			break;
+		}
+		if (f->flag_no_uref) {
+			error = EINVAL;
+			break;
+		}
+		if (f->dev_ep_index != 0) {
+			error = EINVAL;
+			break;
+		}
+		if (ugen_fifo_in_use(f, fflags)) {
+			error = EBUSY;
+			break;
+		}
+		error = usb2_fifo_alloc_buffer(f, 1, u.pinit->ep_index_max);
+		if (error) {
+			break;
+		}
+		f->fs_xfer = malloc(sizeof(f->fs_xfer[0]) *
+		    u.pinit->ep_index_max, M_USB, M_WAITOK | M_ZERO);
+		if (f->fs_xfer == NULL) {
+			usb2_fifo_free_buffer(f);
+			error = ENOMEM;
 			break;
+		}
+		f->fs_ep_max = u.pinit->ep_index_max;
+		f->fs_ep_ptr = u.pinit->pEndpoints;
+		break;
 
 	case USB_FS_UNINIT:
-			if (u.puninit->dummy != 0) {
-				error = EINVAL;
-				break;
-			}
-			error = ugen_fs_uninit(f);
+		if (u.puninit->dummy != 0) {
+			error = EINVAL;
 			break;
+		}
+		error = ugen_fs_uninit(f);
+		break;
 
 	case USB_FS_OPEN:
-			if (u.popen->ep_index >= f->fs_ep_max) {
+		if (u.popen->ep_index >= f->fs_ep_max) {
+			error = EINVAL;
+			break;
+		}
+		if (f->fs_xfer[u.popen->ep_index] != NULL) {
+			error = EBUSY;
+			break;
+		}
+		if (u.popen->max_bufsize > USB_FS_MAX_BUFSIZE) {
+			u.popen->max_bufsize = USB_FS_MAX_BUFSIZE;
+		}
+		if (u.popen->max_frames > USB_FS_MAX_FRAMES) {
+			u.popen->max_frames = USB_FS_MAX_FRAMES;
+			break;
+		}
+		if (u.popen->max_frames == 0) {
+			error = EINVAL;
+			break;
+		}
+		pipe = usb2_get_pipe_by_addr(f->udev, u.popen->ep_no);
+		if (pipe == NULL) {
+			error = EINVAL;
+			break;
+		}
+		ed = pipe->edesc;
+		if (ed == NULL) {
+			error = ENXIO;
+			break;
+		}
+		iface_index = pipe->iface_index;
+
+		error = usb2_check_thread_perm(f->udev, curthread, fflags,
+		    iface_index, u.popen->ep_no);
+		if (error) {
+			break;
+		}
+		bzero(usb2_config, sizeof(usb2_config));
+
+		usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE;
+		usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR;
+		usb2_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN);
+		usb2_config[0].mh.interval = USB_DEFAULT_INTERVAL;
+		usb2_config[0].mh.flags.proxy_buffer = 1;
+		usb2_config[0].mh.callback = &ugen_default_fs_callback;
+		usb2_config[0].mh.timeout = 0;	/* no timeout */
+		usb2_config[0].mh.frames = u.popen->max_frames;
+		usb2_config[0].mh.bufsize = u.popen->max_bufsize;
+		usb2_config[0].md = usb2_config[0].mh;	/* symmetric config */
+
+		if (usb2_config[0].type == UE_CONTROL) {
+			if (f->udev->flags.usb2_mode != USB_MODE_HOST) {
 				error = EINVAL;
 				break;
 			}
-			if (f->fs_xfer[u.popen->ep_index] != NULL) {
-				error = EBUSY;
-				break;
-			}
-			if (u.popen->max_bufsize > USB_FS_MAX_BUFSIZE) {
-				u.popen->max_bufsize = USB_FS_MAX_BUFSIZE;
-			}
-			if (u.popen->max_frames > USB_FS_MAX_FRAMES) {
-				u.popen->max_frames = USB_FS_MAX_FRAMES;
-				break;
-			}
-			if (u.popen->max_frames == 0) {
-				error = EINVAL;
-				break;
-			}
-			pipe = usb2_get_pipe_by_addr(f->udev, u.popen->ep_no);
-			if (pipe == NULL) {
-				error = EINVAL;
-				break;
-			}
-			ed = pipe->edesc;
-			if (ed == NULL) {
-				error = ENXIO;
-				break;
-			}
-			iface_index = pipe->iface_index;
+		} else {
+
+			isread = ((usb2_config[0].endpoint &
+			    (UE_DIR_IN | UE_DIR_OUT)) == UE_DIR_IN);
 
-			error = usb2_check_thread_perm(f->udev, curthread, fflags,
-			    iface_index, u.popen->ep_no);
-			if (error) {
-				break;
+			if (f->udev->flags.usb2_mode != USB_MODE_HOST) {
+				isread = !isread;
 			}
-			bzero(usb2_config, sizeof(usb2_config));
-
-			usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE;
-			usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR;
-			usb2_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN);
-			usb2_config[0].mh.interval = USB_DEFAULT_INTERVAL;
-			usb2_config[0].mh.flags.proxy_buffer = 1;
-			usb2_config[0].mh.callback = &ugen_default_fs_callback;
-			usb2_config[0].mh.timeout = 0;	/* no timeout */
-			usb2_config[0].mh.frames = u.popen->max_frames;
-			usb2_config[0].mh.bufsize = u.popen->max_bufsize;
-			usb2_config[0].md = usb2_config[0].mh;	/* symmetric config */
-
-			if (usb2_config[0].type == UE_CONTROL) {
-				if (f->udev->flags.usb2_mode != USB_MODE_HOST) {
-					error = EINVAL;
+			/* check permissions */
+			if (isread) {
+				if (!(fflags & FREAD)) {
+					error = EPERM;
 					break;
 				}
 			} else {
-
-				isread = ((usb2_config[0].endpoint &
-				    (UE_DIR_IN | UE_DIR_OUT)) == UE_DIR_IN);
-
-				if (f->udev->flags.usb2_mode != USB_MODE_HOST) {
-					isread = !isread;
-				}
-				/* check permissions */
-				if (isread) {
-					if (!(fflags & FREAD)) {
-						error = EPERM;
-						break;
-					}
-				} else {
-					if (!(fflags & FWRITE)) {
-						error = EPERM;
-						break;
-					}
+				if (!(fflags & FWRITE)) {
+					error = EPERM;
+					break;
 				}
 			}
-			error = usb2_transfer_setup(f->udev, &iface_index,
-			    f->fs_xfer + u.popen->ep_index, usb2_config, 1,
-			    f, f->priv_mtx);
-			if (error == 0) {
-				/* update maximums */
-				u.popen->max_packet_length =
-				    f->fs_xfer[u.popen->ep_index]->max_frame_size;
-				u.popen->max_bufsize =
-				    f->fs_xfer[u.popen->ep_index]->max_data_length;
-				f->fs_xfer[u.popen->ep_index]->priv_fifo =
-				    ((uint8_t *)0) + u.popen->ep_index;
-				/*
-				 * Increase performance by dropping locks we
-				 * don't need:
-				 */
-				f->flag_no_uref = 1;
-			} else {
-				error = ENOMEM;
-			}
-			break;
+		}
+		error = usb2_transfer_setup(f->udev, &iface_index,
+		    f->fs_xfer + u.popen->ep_index, usb2_config, 1,
+		    f, f->priv_mtx);
+		if (error == 0) {
+			/* update maximums */
+			u.popen->max_packet_length =
+			    f->fs_xfer[u.popen->ep_index]->max_frame_size;
+			u.popen->max_bufsize =
+			    f->fs_xfer[u.popen->ep_index]->max_data_length;
+			f->fs_xfer[u.popen->ep_index]->priv_fifo =
+			    ((uint8_t *)0) + u.popen->ep_index;
+			/*
+			 * Increase performance by dropping locks we
+			 * don't need:
+			 */
+			f->flag_no_uref = 1;
+		} else {
+			error = ENOMEM;
+		}
+		break;
 
 	case USB_FS_CLOSE:
-			if (u.pclose->ep_index >= f->fs_ep_max) {
-				error = EINVAL;
-				break;
-			}
-			if (f->fs_xfer[u.pclose->ep_index] == NULL) {
-				error = EINVAL;
-				break;
-			}
-			usb2_transfer_unsetup(f->fs_xfer + u.pclose->ep_index, 1);
+		if (u.pclose->ep_index >= f->fs_ep_max) {
+			error = EINVAL;
+			break;
+		}
+		if (f->fs_xfer[u.pclose->ep_index] == NULL) {
+			error = EINVAL;
 			break;
+		}
+		usb2_transfer_unsetup(f->fs_xfer + u.pclose->ep_index, 1);
+		break;
 
 	case USB_FS_CLEAR_STALL_SYNC:
-			if (u.pstall->ep_index >= f->fs_ep_max) {
-				error = EINVAL;
-				break;
-			}
-			if (f->fs_xfer[u.pstall->ep_index] == NULL) {
-				error = EINVAL;
-				break;
-			}
-			if (f->udev->flags.usb2_mode != USB_MODE_HOST) {
-				error = EINVAL;
-				break;
-			}
-			mtx_lock(f->priv_mtx);
-			error = usb2_transfer_pending(f->fs_xfer[u.pstall->ep_index]);
-			mtx_unlock(f->priv_mtx);
+		if (u.pstall->ep_index >= f->fs_ep_max) {
+			error = EINVAL;
+			break;
+		}
+		if (f->fs_xfer[u.pstall->ep_index] == NULL) {
+			error = EINVAL;
+			break;
+		}
+		if (f->udev->flags.usb2_mode != USB_MODE_HOST) {
+			error = EINVAL;
+			break;
+		}
+		mtx_lock(f->priv_mtx);
+		error = usb2_transfer_pending(f->fs_xfer[u.pstall->ep_index]);
+		mtx_unlock(f->priv_mtx);
 
-			if (error) {
-				return (EBUSY);
-			}
-			pipe = f->fs_xfer[u.pstall->ep_index]->pipe;
+		if (error) {
+			return (EBUSY);
+		}
+		pipe = f->fs_xfer[u.pstall->ep_index]->pipe;
 
-			/* setup a clear-stall packet */
-			req.bmRequestType = UT_WRITE_ENDPOINT;
-			req.bRequest = UR_CLEAR_FEATURE;
-			USETW(req.wValue, UF_ENDPOINT_HALT);
-			req.wIndex[0] = pipe->edesc->bEndpointAddress;
-			req.wIndex[1] = 0;
-			USETW(req.wLength, 0);
+		/* setup a clear-stall packet */
+		req.bmRequestType = UT_WRITE_ENDPOINT;
+		req.bRequest = UR_CLEAR_FEATURE;
+		USETW(req.wValue, UF_ENDPOINT_HALT);
+		req.wIndex[0] = pipe->edesc->bEndpointAddress;
+		req.wIndex[1] = 0;
+		USETW(req.wLength, 0);
 
-			error = usb2_do_request(f->udev, NULL, &req, NULL);
-			if (error == 0) {
-				usb2_clear_data_toggle(f->udev, pipe);
-			} else {
-				error = ENXIO;
-			}
-			break;
+		error = usb2_do_request(f->udev, NULL, &req, NULL);
+		if (error == 0) {
+			usb2_clear_data_toggle(f->udev, pipe);
+		} else {
+			error = ENXIO;
+		}
+		break;
 
 	default:
 		error = ENOTTY;
@@ -1657,9 +1657,9 @@
 		struct usb2_interface_descriptor *idesc;
 		struct usb2_endpoint_descriptor *ed;
 		struct usb2_alt_interface *ai;
-		int *pint;
-		void *addr;
-	} u;
+		int    *pint;
+		void   *addr;
+	}     u;
 	struct usb2_interface *iface;
 	struct usb2_pipe *pipe;
 	int error = 0;
@@ -1713,39 +1713,39 @@
 		*(int *)addr = f->bufsize;
 		break;
 
-	case USB_GET_INTERFACE_DESC: 
-			iface = usb2_get_iface(f->udev, f->iface_index);
-			if (iface && iface->idesc) {
-				*u.idesc = *(iface->idesc);
-			} else {
-				error = EIO;
-				break;
-			}
+	case USB_GET_INTERFACE_DESC:
+		iface = usb2_get_iface(f->udev, f->iface_index);
+		if (iface && iface->idesc) {
+			*u.idesc = *(iface->idesc);
+		} else {
+			error = EIO;
 			break;
+		}
+		break;
 
 	case USB_GET_ENDPOINT_DESC:
 
-			pipe = f->priv_sc0;
+		pipe = f->priv_sc0;
 
-			if (pipe && pipe->edesc) {
-				*u.ed = *pipe->edesc;
-			} else {
-				error = EINVAL;
-				break;
-			}
+		if (pipe && pipe->edesc) {
+			*u.ed = *pipe->edesc;
+		} else {
+			error = EINVAL;
 			break;
+		}
+		break;
 
 	case USB_SET_RX_STALL_FLAG:
-			if ((fflags & FREAD) && (*u.pint)) {
-				f->flag_stall = 1;
-			}
-			break;
+		if ((fflags & FREAD) && (*u.pint)) {
+			f->flag_stall = 1;
+		}
+		break;
 
 	case USB_SET_TX_STALL_FLAG:
-			if ((fflags & FWRITE) && (*u.pint)) {
-				f->flag_stall = 1;
-			}
-			break;
+		if ((fflags & FWRITE) && (*u.pint)) {
+			f->flag_stall = 1;
+		}
+		break;
 
 	default:
 		error = ENOTTY;
@@ -1762,10 +1762,10 @@
 		struct usb2_alt_interface *ai;
 		struct usb2_device_descriptor *ddesc;
 		struct usb2_config_descriptor *cdesc;
- 		struct usb2_device_stats *stat;
+		struct usb2_device_stats *stat;
 		uint32_t *ptime;
-		void *addr;
-	} u;
+		void   *addr;
+	}     u;
 	struct usb2_device_descriptor *dtemp;
 	struct usb2_config_descriptor *ctemp;
 	struct usb2_interface *iface;
@@ -1800,41 +1800,41 @@
 		break;
 
 	case USB_GET_ALTINTERFACE:
-			iface = usb2_get_iface(f->udev,
-			    u.ai->uai_interface_index);
-			if (iface && iface->idesc) {
-				u.ai->uai_alt_index = iface->alt_index;
-			} else {
-				error = EINVAL;
-			}
-			break;
+		iface = usb2_get_iface(f->udev,
+		    u.ai->uai_interface_index);
+		if (iface && iface->idesc) {
+			u.ai->uai_alt_index = iface->alt_index;
+		} else {
+			error = EINVAL;
+		}
+		break;
 
 	case USB_SET_ALTINTERFACE:
-			if (!(fflags & FWRITE)) {
-				error = EPERM;
-				break;
-			}
-			error = ugen_set_interface(f,
-			    u.ai->uai_interface_index, u.ai->uai_alt_index);
+		if (!(fflags & FWRITE)) {
+			error = EPERM;
 			break;
+		}
+		error = ugen_set_interface(f,
+		    u.ai->uai_interface_index, u.ai->uai_alt_index);
+		break;
 
 	case USB_GET_DEVICE_DESC:
-			dtemp = usb2_get_device_descriptor(f->udev);
-			if (!dtemp) {
-				error = EIO;
-				break;
-			}
-			*u.ddesc = *dtemp;
+		dtemp = usb2_get_device_descriptor(f->udev);
+		if (!dtemp) {
+			error = EIO;
 			break;
+		}
+		*u.ddesc = *dtemp;
+		break;
 
 	case USB_GET_CONFIG_DESC:
-			ctemp = usb2_get_config_descriptor(f->udev);
-			if (!ctemp) {
-				error = EIO;
-				break;
-			}
-			*u.cdesc = *ctemp;
+		ctemp = usb2_get_config_descriptor(f->udev);
+		if (!ctemp) {
+			error = EIO;
 			break;
+		}
+		*u.cdesc = *ctemp;
+		break;
 
 	case USB_GET_FULL_DESC:
 		error = ugen_get_cdesc(f, addr);
@@ -1863,23 +1863,23 @@
 		break;
 
 	case USB_DEVICESTATS:
-			for (n = 0; n != 4; n++) {
+		for (n = 0; n != 4; n++) {
 
-				u.stat->uds_requests_fail[n] =
-				    f->udev->bus->stats_err.uds_requests[n];
+			u.stat->uds_requests_fail[n] =
+			    f->udev->bus->stats_err.uds_requests[n];
 
-				u.stat->uds_requests_ok[n] =
-				    f->udev->bus->stats_ok.uds_requests[n];
-			}
-			break;
+			u.stat->uds_requests_ok[n] =
+			    f->udev->bus->stats_ok.uds_requests[n];
+		}
+		break;
 
 	case USB_DEVICEENUMERATE:
 		error = ugen_re_enumerate(f);
 		break;
 
 	case USB_GET_PLUGTIME:
-			*u.ptime = f->udev->plugtime;
-			break;
+		*u.ptime = f->udev->plugtime;
+		break;
 
 		/* ... more IOCTL's to come ! ... --hps */
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808111825.m7BIPdcQ056877>