PERFORCE change 132111 for review

Hans Petter Selasky hselasky at FreeBSD.org
Sun Dec 30 07:58:31 PST 2007


http://perforce.freebsd.org/chv.cgi?CH=132111

Change 132111 by hselasky at hselasky_laptop001 on 2007/12/30 15:58:01

	
	Style changes by "usb_style.sh".

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb/uchcom.c#18 edit

Differences ...

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

@@ -146,8 +146,8 @@
 #define UCHCOM_INTR_STAT2	0x03
 #define UCHCOM_INTR_LEAST	4
 
-#define	UCHCOM_BULK_BUF_SIZE 1024 /* bytes */
-#define	UCHCOM_N_TRANSFER 6 /* units */
+#define	UCHCOM_BULK_BUF_SIZE 1024	/* bytes */
+#define	UCHCOM_N_TRANSFER 6		/* units */
 
 struct uchcom_softc {
 	struct ucom_super_softc sc_super_ucom;
@@ -156,46 +156,46 @@
 	struct usbd_xfer *sc_xfer[UCHCOM_N_TRANSFER];
 	struct usbd_device *sc_udev;
 
-	uint8_t		sc_dtr; /* local copy */
-	uint8_t		sc_rts; /* local copy */
-	uint8_t		sc_version;
-	uint8_t		sc_msr;
-	uint8_t		sc_lsr;			/* local status register */
-	uint8_t		sc_flag;
+	uint8_t	sc_dtr;			/* local copy */
+	uint8_t	sc_rts;			/* local copy */
+	uint8_t	sc_version;
+	uint8_t	sc_msr;
+	uint8_t	sc_lsr;			/* local status register */
+	uint8_t	sc_flag;
 #define	UCHCOM_FLAG_INTR_STALL  0x01
 #define	UCHCOM_FLAG_READ_STALL  0x02
 #define	UCHCOM_FLAG_WRITE_STALL 0x04
 };
 
-struct uchcom_divider
-{
-	uint8_t		dv_prescaler;
-	uint8_t		dv_div;
-	uint8_t		dv_mod;
+struct uchcom_divider {
+	uint8_t	dv_prescaler;
+	uint8_t	dv_div;
+	uint8_t	dv_mod;
 };
 
-struct uchcom_divider_record
-{
-	uint32_t		dvr_high;
-	uint32_t		dvr_low;
-	uint32_t		dvr_base_clock;
-	struct uchcom_divider	dvr_divider;
+struct uchcom_divider_record {
+	uint32_t dvr_high;
+	uint32_t dvr_low;
+	uint32_t dvr_base_clock;
+	struct uchcom_divider dvr_divider;
 };
 
 static const struct uchcom_divider_record dividers[] =
 {
-	{  307200, 307200, UCHCOM_BASE_UNKNOWN, { 7, 0xD9, 0 } },
-	{  921600, 921600, UCHCOM_BASE_UNKNOWN, { 7, 0xF3, 0 } },
-	{ 2999999,  23530,             6000000, { 3,    0, 0 } },
-	{   23529,   2942,              750000, { 2,    0, 0 } },
-	{    2941,    368,               93750, { 1,    0, 0 } },
-	{     367,      1,               11719, { 0,    0, 0 } },
+	{307200, 307200, UCHCOM_BASE_UNKNOWN, {7, 0xD9, 0}},
+	{921600, 921600, UCHCOM_BASE_UNKNOWN, {7, 0xF3, 0}},
+	{2999999, 23530, 6000000, {3, 0, 0}},
+	{23529, 2942, 750000, {2, 0, 0}},
+	{2941, 368, 93750, {1, 0, 0}},
+	{367, 1, 11719, {0, 0, 0}},
 };
+
 #define NUM_DIVIDERS	(sizeof (dividers) / sizeof (dividers[0]))
 
 static const struct usb_devno uchcom_devs[] = {
-	{ USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER },
+	{USB_VENDOR_WCH, USB_PRODUCT_WCH_CH341SER},
 };
+
 #define uchcom_lookup(v, p)	usb_lookup(uchcom_devs, v, p)
 
 /* protypes */
@@ -321,13 +321,11 @@
 	if (uaa->usb_mode != USB_MODE_HOST) {
 		return (UMATCH_NONE);
 	}
-
 	if (uaa->iface) {
 		return (UMATCH_NONE);
 	}
-
 	return (uchcom_lookup(uaa->vendor, uaa->product) != NULL ?
-		UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
+	    UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
 }
 
 static int
@@ -356,7 +354,6 @@
 		    "error=%s\n", usbd_errstr(error));
 		goto detach;
 	}
-
 	switch (uaa->release) {
 	case UCHCOM_REV_CH340:
 		device_printf(dev, "CH340 detected\n");
@@ -376,7 +373,6 @@
 		    "error=%s\n", usbd_errstr(error));
 		goto detach;
 	}
-
 	/*
 	 * Do the initialization during attach so that the system does not
 	 * sleep during open:
@@ -447,7 +443,7 @@
 done:
 	if (length != actlen) {
 		if (req->bmRequestType & UT_READ) {
-			bzero(USBD_ADD_BYTES(data,actlen), length - actlen);
+			bzero(USBD_ADD_BYTES(data, actlen), length - actlen);
 		}
 	}
 	return;
@@ -455,7 +451,7 @@
 
 static void
 uchcom_ctrl_write(struct uchcom_softc *sc, uint8_t reqno,
-		    uint16_t value, uint16_t index)
+    uint16_t value, uint16_t index)
 {
 	usb_device_request_t req;
 
@@ -487,33 +483,35 @@
 
 static void
 uchcom_write_reg(struct uchcom_softc *sc,
-	  uint8_t reg1, uint8_t val1, uint8_t reg2, uint8_t val2)
+    uint8_t reg1, uint8_t val1, uint8_t reg2, uint8_t val2)
 {
 	DPRINTFN(0, "0x%02X<-0x%02X, 0x%02X<-0x%02X\n",
-		 (unsigned)reg1, (unsigned)val1,
-		 (unsigned)reg2, (unsigned)val2);
+	    (unsigned)reg1, (unsigned)val1,
+	    (unsigned)reg2, (unsigned)val2);
 	uchcom_ctrl_write(
-		sc, UCHCOM_REQ_WRITE_REG,
-		reg1|((uint16_t)reg2<<8), val1|((uint16_t)val2<<8));
+	    sc, UCHCOM_REQ_WRITE_REG,
+	    reg1 | ((uint16_t)reg2 << 8), val1 | ((uint16_t)val2 << 8));
 	return;
 }
 
 static void
 uchcom_read_reg(struct uchcom_softc *sc,
-	 uint8_t reg1, uint8_t *rval1, uint8_t reg2, uint8_t *rval2)
+    uint8_t reg1, uint8_t *rval1, uint8_t reg2, uint8_t *rval2)
 {
 	uint8_t buf[UCHCOM_INPUT_BUF_SIZE];
 
 	uchcom_ctrl_read(
-		sc, UCHCOM_REQ_READ_REG,
-		reg1|((uint16_t)reg2<<8), 0, buf, sizeof(buf));
+	    sc, UCHCOM_REQ_READ_REG,
+	    reg1 | ((uint16_t)reg2 << 8), 0, buf, sizeof(buf));
 
 	DPRINTFN(0, "0x%02X->0x%02X, 0x%02X->0x%02X\n",
-		 (unsigned)reg1, (unsigned)buf[0],
-		 (unsigned)reg2, (unsigned)buf[1]);
+	    (unsigned)reg1, (unsigned)buf[0],
+	    (unsigned)reg2, (unsigned)buf[1]);
 
-	if (rval1) *rval1 = buf[0];
-	if (rval2) *rval2 = buf[1];
+	if (rval1)
+		*rval1 = buf[0];
+	if (rval2)
+		*rval2 = buf[1];
 
 	return;
 }
@@ -524,9 +522,10 @@
 	uint8_t buf[UCHCOM_INPUT_BUF_SIZE];
 
 	uchcom_ctrl_read(
-	 sc, UCHCOM_REQ_GET_VERSION, 0, 0, buf, sizeof(buf));
+	    sc, UCHCOM_REQ_GET_VERSION, 0, 0, buf, sizeof(buf));
 
-	if (rver) *rver = buf[0];
+	if (rver)
+		*rver = buf[0];
 
 	return;
 }
@@ -590,8 +589,10 @@
 {
 	uint8_t val = 0;
 
-	if (sc->sc_dtr) val |= UCHCOM_DTR_MASK;
-	if (sc->sc_rts) val |= UCHCOM_RTS_MASK;
+	if (sc->sc_dtr)
+		val |= UCHCOM_DTR_MASK;
+	if (sc->sc_rts)
+		val |= UCHCOM_RTS_MASK;
 
 	if (sc->sc_version < UCHCOM_VER_20)
 		uchcom_set_dtrrts_10(sc, ~val);
@@ -633,7 +634,7 @@
 	uint8_t i;
 
 	/* find record */
-	for (i=0; i != NUM_DIVIDERS; i++) {
+	for (i = 0; i != NUM_DIVIDERS; i++) {
 		if (dividers[i].dvr_high >= rate &&
 		    dividers[i].dvr_low <= rate) {
 			rp = &dividers[i];
@@ -649,15 +650,15 @@
 	else {
 		div = rp->dvr_base_clock / rate;
 		rem = rp->dvr_base_clock % rate;
-		if (div==0 || div>=0xFF)
-		  return (-1);
-		if ((rem<<1) >= rate)
+		if (div == 0 || div >= 0xFF)
+			return (-1);
+		if ((rem << 1) >= rate)
 			div += 1;
 		dp->dv_div = (uint8_t)-div;
 	}
 
-	mod = UCHCOM_BPS_MOD_BASE/rate + UCHCOM_BPS_MOD_BASE_OFS;
-	mod = mod + mod/2;
+	mod = UCHCOM_BPS_MOD_BASE / rate + UCHCOM_BPS_MOD_BASE_OFS;
+	mod = mod + mod / 2;
 
 	dp->dv_mod = mod / 0x100;
 
@@ -670,14 +671,14 @@
 	struct uchcom_divider dv;
 
 	if (uchcom_calc_divider_settings(&dv, rate))
-	  return;
+		return;
 
 	uchcom_write_reg(sc,
-			     UCHCOM_REG_BPS_PRE, dv.dv_prescaler,
-			 UCHCOM_REG_BPS_DIV, dv.dv_div);
+	    UCHCOM_REG_BPS_PRE, dv.dv_prescaler,
+	    UCHCOM_REG_BPS_DIV, dv.dv_div);
 	uchcom_write_reg(sc,
-			     UCHCOM_REG_BPS_MOD, dv.dv_mod,
-			 UCHCOM_REG_BPS_PAD, 0);
+	    UCHCOM_REG_BPS_MOD, dv.dv_mod,
+	    UCHCOM_REG_BPS_PAD, 0);
 	return;
 }
 
@@ -708,7 +709,6 @@
 		else
 			lcr2 |= UCHCOM_LCR2_PAREVEN;
 	}
-
 	uchcom_write_reg(sc, UCHCOM_REG_LCR1, lcr1, UCHCOM_REG_LCR2, lcr2);
 
 	return;
@@ -739,9 +739,9 @@
 
 	val = 0;
 	idx = 0;
-	val |= (uint16_t)(lcr1&0xF0) << 8;
+	val |= (uint16_t)(lcr1 & 0xF0) << 8;
 	val |= 0x01;
-	val |= (uint16_t)(lcr2&0x0F) << 8;
+	val |= (uint16_t)(lcr2 & 0x0F) << 8;
 	val |= 0x02;
 	idx |= pre & 0x07;
 	val |= 0x04;
@@ -820,13 +820,14 @@
 	if (uchcom_calc_divider_settings(&dv, t->c_ospeed)) {
 		return (EIO);
 	}
-	return (0); /* success */
+	return (0);			/* success */
 }
 
 static void
 uchcom_cfg_param(struct ucom_softc *ucom, struct termios *t)
 {
 	struct uchcom_softc *sc = ucom->sc_parent;
+
 	uchcom_set_line_control(sc, t->c_cflag);
 	uchcom_set_dte_rate(sc, t->c_ospeed);
 	return;
@@ -893,17 +894,16 @@
 		DPRINTFN(0, "actlen = %u\n", xfer->actlen);
 
 		if (xfer->actlen >= UCHCOM_INTR_LEAST) {
-			usbd_copy_out(xfer->frbuffers + 0, 0, buf, 
+			usbd_copy_out(xfer->frbuffers + 0, 0, buf,
 			    UCHCOM_INTR_LEAST);
 
-		DPRINTFN(0, "data = 0x%02X 0x%02X 0x%02X 0x%02X\n",
-		 (unsigned)buf[0], (unsigned)buf[1],
-		 (unsigned)buf[2], (unsigned)buf[3]);
+			DPRINTFN(0, "data = 0x%02X 0x%02X 0x%02X 0x%02X\n",
+			    (unsigned)buf[0], (unsigned)buf[1],
+			    (unsigned)buf[2], (unsigned)buf[3]);
 
-	uchcom_convert_status(sc, buf[UCHCOM_INTR_STAT1]);
-	ucom_status_change(&sc->sc_ucom);
+			uchcom_convert_status(sc, buf[UCHCOM_INTR_STAT1]);
+			ucom_status_change(&sc->sc_ucom);
 		}
-
 	case USBD_ST_SETUP:
 		if (sc->sc_flag & UCHCOM_FLAG_INTR_STALL) {
 			usbd_transfer_start(sc->sc_xfer[5]);
@@ -1032,13 +1032,13 @@
 	DEVMETHOD(device_attach, uchcom_attach),
 	DEVMETHOD(device_detach, uchcom_detach),
 
-	{ 0, 0 }
+	{0, 0}
 };
 
 static driver_t uchcom_driver = {
 	"ucom",
 	uchcom_methods,
-	sizeof (struct uchcom_softc)
+	sizeof(struct uchcom_softc)
 };
 
 static devclass_t uchcom_devclass;


More information about the p4-projects mailing list