Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jan 2009 16:04:11 +0000 (UTC)
From:      Takanori Watanabe <takawata@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r187299 - head/sys/dev/usb2/serial
Message-ID:  <200901151604.n0FG4Bof081030@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: takawata
Date: Thu Jan 15 16:04:11 2009
New Revision: 187299
URL: http://svn.freebsd.org/changeset/base/187299

Log:
  Name the items of xfer array.

Modified:
  head/sys/dev/usb2/serial/ufoma2.c

Modified: head/sys/dev/usb2/serial/ufoma2.c
==============================================================================
--- head/sys/dev/usb2/serial/ufoma2.c	Thu Jan 15 12:15:46 2009	(r187298)
+++ head/sys/dev/usb2/serial/ufoma2.c	Thu Jan 15 16:04:11 2009	(r187299)
@@ -143,8 +143,21 @@ typedef struct ufoma_mobile_acm_descript
 
 #define	UFOMA_BULK_BUF_SIZE 1024	/* bytes */
 
-#define	UFOMA_CTRL_ENDPT_MAX 4		/* units */
-#define	UFOMA_BULK_ENDPT_MAX 4		/* units */
+enum {
+	UFOMA_CTRL_ENDPT_INTR,
+	UFOMA_CTRL_ENDPT_INTR_CLEAR,	
+	UFOMA_CTRL_ENDPT_READ,
+	UFOMA_CTRL_ENDPT_WRITE,
+	UFOMA_CTRL_ENDPT_MAX = 4,
+};
+
+enum {
+	UFOMA_BULK_ENDPT_WRITE,
+	UFOMA_BULK_ENDPT_READ,	
+	UFOMA_BULK_ENDPT_WRITE_CLEAR,
+	UFOMA_BULK_ENDPT_READ_CLEAR,
+	UFOMA_BULK_ENDPT_MAX = 4,
+};
 
 struct ufoma_softc {
 	struct usb2_com_super_softc sc_super_ucom;
@@ -227,7 +240,7 @@ static int ufoma_sysctl_open(SYSCTL_HAND
 static const struct usb2_config
 	ufoma_ctrl_config[UFOMA_CTRL_ENDPT_MAX] = {
 
-	[0] = {
+	[UFOMA_CTRL_ENDPT_INTR] = {
 		.type = UE_INTERRUPT,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
@@ -236,7 +249,7 @@ static const struct usb2_config
 		.mh.callback = &ufoma_intr_callback,
 	},
 
-	[1] = {
+	[UFOMA_CTRL_ENDPT_INTR_CLEAR] = {
 		.type = UE_CONTROL,
 		.endpoint = 0x00,	/* Control pipe */
 		.direction = UE_DIR_ANY,
@@ -247,7 +260,7 @@ static const struct usb2_config
 		.mh.interval = 50,	/* 50ms */
 	},
 
-	[2] = {
+	[UFOMA_CTRL_ENDPT_READ] = {
 		.type = UE_CONTROL,
 		.endpoint = 0x00,	/* Control pipe */
 		.direction = UE_DIR_ANY,
@@ -257,7 +270,7 @@ static const struct usb2_config
 		.mh.timeout = 1000,	/* 1 second */
 	},
 
-	[3] = {
+	[UFOMA_CTRL_ENDPT_WRITE] = {
 		.type = UE_CONTROL,
 		.endpoint = 0x00,	/* Control pipe */
 		.direction = UE_DIR_ANY,
@@ -271,7 +284,7 @@ static const struct usb2_config
 static const struct usb2_config
 	ufoma_bulk_config[UFOMA_BULK_ENDPT_MAX] = {
 
-	[0] = {
+	[UFOMA_BULK_ENDPT_WRITE] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_OUT,
@@ -280,7 +293,7 @@ static const struct usb2_config
 		.mh.callback = &ufoma_bulk_write_callback,
 	},
 
-	[1] = {
+	[UFOMA_BULK_ENDPT_READ] = {
 		.type = UE_BULK,
 		.endpoint = UE_ADDR_ANY,
 		.direction = UE_DIR_IN,
@@ -289,7 +302,7 @@ static const struct usb2_config
 		.mh.callback = &ufoma_bulk_read_callback,
 	},
 
-	[2] = {
+	[UFOMA_BULK_ENDPT_WRITE_CLEAR] = {
 		.type = UE_CONTROL,
 		.endpoint = 0x00,	/* Control pipe */
 		.direction = UE_DIR_ANY,
@@ -300,7 +313,7 @@ static const struct usb2_config
 		.mh.interval = 50,	/* 50ms */
 	},
 
-	[3] = {
+	[UFOMA_BULK_ENDPT_READ_CLEAR] = {
 		.type = UE_CONTROL,
 		.endpoint = 0x00,	/* Control pipe */
 		.direction = UE_DIR_ANY,
@@ -701,7 +714,7 @@ static void
 ufoma_intr_clear_stall_callback(struct usb2_xfer *xfer)
 {
 	struct ufoma_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_ctrl_xfer[0];
+	struct usb2_xfer *xfer_other = sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_INTR];
 
 	if (usb2_clear_stall_callback(xfer, xfer_other)) {
 		DPRINTF("stall cleared\n");
@@ -758,7 +771,7 @@ ufoma_intr_callback(struct usb2_xfer *xf
 			if (sc->sc_num_msg != 0xFF) {
 				sc->sc_num_msg++;
 			}
-			usb2_transfer_start(sc->sc_ctrl_xfer[2]);
+			usb2_transfer_start(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_READ]);
 			break;
 
 		case UCDC_N_SERIAL_STATE:
@@ -803,7 +816,7 @@ ufoma_intr_callback(struct usb2_xfer *xf
 	case USB_ST_SETUP:
 tr_setup:
 		if (sc->sc_flags & UFOMA_FLAG_INTR_STALL) {
-			usb2_transfer_start(sc->sc_ctrl_xfer[1]);
+			usb2_transfer_start(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_INTR_CLEAR]);
 		} else {
 			xfer->frlengths[0] = xfer->max_data_length;
 			usb2_start_hardware(xfer);
@@ -814,7 +827,7 @@ tr_setup:
 		if (xfer->error != USB_ERR_CANCELLED) {
 			/* start clear stall */
 			sc->sc_flags |= UFOMA_FLAG_INTR_STALL;
-			usb2_transfer_start(sc->sc_ctrl_xfer[1]);
+			usb2_transfer_start(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_INTR_CLEAR]);
 		}
 		return;
 
@@ -831,7 +844,7 @@ ufoma_bulk_write_callback(struct usb2_xf
 	case USB_ST_SETUP:
 	case USB_ST_TRANSFERRED:
 		if (sc->sc_flags & UFOMA_FLAG_BULK_WRITE_STALL) {
-			usb2_transfer_start(sc->sc_bulk_xfer[2]);
+			usb2_transfer_start(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE_CLEAR]);
 			return;
 		}
 		if (usb2_com_get_data(&sc->sc_ucom, xfer->frbuffers, 0,
@@ -844,7 +857,7 @@ ufoma_bulk_write_callback(struct usb2_xf
 	default:			/* Error */
 		if (xfer->error != USB_ERR_CANCELLED) {
 			sc->sc_flags |= UFOMA_FLAG_BULK_WRITE_STALL;
-			usb2_transfer_start(sc->sc_bulk_xfer[2]);
+			usb2_transfer_start(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE_CLEAR]);
 		}
 		return;
 
@@ -855,7 +868,7 @@ static void
 ufoma_bulk_write_clear_stall_callback(struct usb2_xfer *xfer)
 {
 	struct ufoma_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_bulk_xfer[0];
+	struct usb2_xfer *xfer_other = sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE];
 
 	if (usb2_clear_stall_callback(xfer, xfer_other)) {
 		DPRINTF("stall cleared\n");
@@ -876,7 +889,7 @@ ufoma_bulk_read_callback(struct usb2_xfe
 
 	case USB_ST_SETUP:
 		if (sc->sc_flags & UFOMA_FLAG_BULK_READ_STALL) {
-			usb2_transfer_start(sc->sc_bulk_xfer[3]);
+			usb2_transfer_start(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ_CLEAR]);
 		} else {
 			xfer->frlengths[0] = xfer->max_data_length;
 			usb2_start_hardware(xfer);
@@ -886,7 +899,7 @@ ufoma_bulk_read_callback(struct usb2_xfe
 	default:			/* Error */
 		if (xfer->error != USB_ERR_CANCELLED) {
 			sc->sc_flags |= UFOMA_FLAG_BULK_READ_STALL;
-			usb2_transfer_start(sc->sc_bulk_xfer[3]);
+			usb2_transfer_start(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ_CLEAR]);
 		}
 		return;
 
@@ -897,7 +910,7 @@ static void
 ufoma_bulk_read_clear_stall_callback(struct usb2_xfer *xfer)
 {
 	struct ufoma_softc *sc = xfer->priv_sc;
-	struct usb2_xfer *xfer_other = sc->sc_bulk_xfer[1];
+	struct usb2_xfer *xfer_other = sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ];
 
 	if (usb2_clear_stall_callback(xfer, xfer_other)) {
 		DPRINTF("stall cleared\n");
@@ -1159,13 +1172,13 @@ ufoma_start_read(struct usb2_com_softc *
 	struct ufoma_softc *sc = ucom->sc_parent;
 
 	/* start interrupt transfer */
-	usb2_transfer_start(sc->sc_ctrl_xfer[0]);
+	usb2_transfer_start(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_INTR]);
 
 	/* start data transfer */
 	if (sc->sc_is_pseudo) {
-		usb2_transfer_start(sc->sc_ctrl_xfer[2]);
+		usb2_transfer_start(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_READ]);
 	} else {
-		usb2_transfer_start(sc->sc_bulk_xfer[1]);
+		usb2_transfer_start(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ]);
 	}
 }
 
@@ -1175,15 +1188,15 @@ ufoma_stop_read(struct usb2_com_softc *u
 	struct ufoma_softc *sc = ucom->sc_parent;
 
 	/* stop interrupt transfer */
-	usb2_transfer_stop(sc->sc_ctrl_xfer[1]);
-	usb2_transfer_stop(sc->sc_ctrl_xfer[0]);
+	usb2_transfer_stop(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_INTR]);
+	usb2_transfer_stop(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_INTR_CLEAR]);
 
 	/* stop data transfer */
 	if (sc->sc_is_pseudo) {
-		usb2_transfer_stop(sc->sc_ctrl_xfer[2]);
+		usb2_transfer_stop(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_READ]);
 	} else {
-		usb2_transfer_stop(sc->sc_bulk_xfer[3]);
-		usb2_transfer_stop(sc->sc_bulk_xfer[1]);
+		usb2_transfer_stop(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ_CLEAR]);
+		usb2_transfer_stop(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_READ]);
 	}
 }
 
@@ -1193,9 +1206,9 @@ ufoma_start_write(struct usb2_com_softc 
 	struct ufoma_softc *sc = ucom->sc_parent;
 
 	if (sc->sc_is_pseudo) {
-		usb2_transfer_start(sc->sc_ctrl_xfer[3]);
+		usb2_transfer_start(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_WRITE]);
 	} else {
-		usb2_transfer_start(sc->sc_bulk_xfer[0]);
+		usb2_transfer_start(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE]);
 	}
 }
 
@@ -1205,10 +1218,10 @@ ufoma_stop_write(struct usb2_com_softc *
 	struct ufoma_softc *sc = ucom->sc_parent;
 
 	if (sc->sc_is_pseudo) {
-		usb2_transfer_stop(sc->sc_ctrl_xfer[3]);
+		usb2_transfer_stop(sc->sc_ctrl_xfer[UFOMA_CTRL_ENDPT_WRITE]);
 	} else {
-		usb2_transfer_stop(sc->sc_bulk_xfer[2]);
-		usb2_transfer_stop(sc->sc_bulk_xfer[0]);
+		usb2_transfer_stop(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE_CLEAR]);
+		usb2_transfer_stop(sc->sc_bulk_xfer[UFOMA_BULK_ENDPT_WRITE]);
 	}
 }
 



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