PERFORCE change 132092 for review

Hans Petter Selasky hselasky at FreeBSD.org
Sun Dec 30 05:25:49 PST 2007


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

Change 132092 by hselasky at hselasky_laptop001 on 2007/12/30 13:25:10

	
	First step converting "uchcom" to the new USB API.
	
	o Prefix all function names by "uchcom_".

Affected files ...

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

Differences ...

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

@@ -216,11 +216,11 @@
 static void	uchcom_intr(usbd_xfer_handle, usbd_private_handle,
 			    usbd_status);
 
-static int	set_config(device_t );
-static int	find_ifaces(struct uchcom_softc *, usbd_interface_handle *);
-static int	find_endpoints(struct uchcom_softc *,
+static int	uchcom_set_config(device_t );
+static int	uchcom_find_ifaces(struct uchcom_softc *, usbd_interface_handle *);
+static int	uchcom_find_endpoints(struct uchcom_softc *,
 			       struct uchcom_endpoints *);
-static void	close_intr_pipe(struct uchcom_softc *);
+static void	uchcom_close_intr_pipe(struct uchcom_softc *);
 
 static int uchcom_match(device_t );
 static int uchcom_attach(device_t );
@@ -270,7 +270,7 @@
 
 	DPRINTF(("\n\nuchcom attach: sc=%p\n", sc));
 
-	if (set_config(self))
+	if (uchcom_set_config(self))
 		goto failed;
 
 	switch (uaa->release) {
@@ -282,10 +282,10 @@
 		break;
 	}
 
-	if (find_ifaces(sc, &ucom->sc_iface))
+	if (uchcom_find_ifaces(sc, &ucom->sc_iface))
 		goto failed;
 
-	if (find_endpoints(sc, &endpoints))
+	if (uchcom_find_endpoints(sc, &endpoints))
 		goto failed;
 
 	sc->sc_intr_endpoint = endpoints.ep_intr;
@@ -320,7 +320,7 @@
 
 	DPRINTF(("uchcom_detach: sc=%p flags=%d\n", sc, flags));
 
-	close_intr_pipe(sc);
+	uchcom_close_intr_pipe(sc);
 
 	ucom->sc_dying = 1;
 
@@ -329,7 +329,7 @@
 	return rv;
 }
 static int
-set_config(device_t dev)
+uchcom_set_config(device_t dev)
 {
 	struct uchcom_softc *sc = device_get_softc(dev);
 	struct ucom_softc *ucom = &sc->sc_ucom;
@@ -346,7 +346,7 @@
 }
 
 static int
-find_ifaces(struct uchcom_softc *sc, usbd_interface_handle *riface)
+uchcom_find_ifaces(struct uchcom_softc *sc, usbd_interface_handle *riface)
 {
 	usbd_status err;
 	struct ucom_softc *ucom = &sc->sc_ucom;
@@ -363,7 +363,7 @@
 }
 
 static int
-find_endpoints(struct uchcom_softc *sc, struct uchcom_endpoints *endpoints)
+uchcom_find_endpoints(struct uchcom_softc *sc, struct uchcom_endpoints *endpoints)
 {
 	struct ucom_softc *ucom= &sc->sc_ucom;
 	int i, bin=-1, bout=-1, intr=-1, isize=0;
@@ -427,7 +427,7 @@
  */
 
 static __inline usbd_status
-generic_control_out(struct uchcom_softc *sc, uint8_t reqno,
+uchcom_ctrl_write(struct uchcom_softc *sc, uint8_t reqno,
 		    uint16_t value, uint16_t index)
 {
 	usb_device_request_t req;
@@ -442,7 +442,7 @@
 }
 
 static __inline usbd_status
-generic_control_in(struct uchcom_softc *sc, uint8_t reqno,
+uchcom_ctrl_read(struct uchcom_softc *sc, uint8_t reqno,
 		   uint16_t value, uint16_t index, void *buf, int buflen,
 		   int *actlen)
 {
@@ -460,26 +460,26 @@
 }
 
 static __inline usbd_status
-write_reg(struct uchcom_softc *sc,
+uchcom_write_reg(struct uchcom_softc *sc,
 	  uint8_t reg1, uint8_t val1, uint8_t reg2, uint8_t val2)
 {
 	DPRINTF(("uchcom: write reg 0x%02X<-0x%02X, 0x%02X<-0x%02X\n",
 		 (unsigned)reg1, (unsigned)val1,
 		 (unsigned)reg2, (unsigned)val2));
-	return generic_control_out(
+	return uchcom_ctrl_write(
 		sc, UCHCOM_REQ_WRITE_REG,
 		reg1|((uint16_t)reg2<<8), val1|((uint16_t)val2<<8));
 }
 
 static __inline usbd_status
-read_reg(struct uchcom_softc *sc,
+uchcom_read_reg(struct uchcom_softc *sc,
 	 uint8_t reg1, uint8_t *rval1, uint8_t reg2, uint8_t *rval2)
 {
 	uint8_t buf[UCHCOM_INPUT_BUF_SIZE];
 	usbd_status err;
 	int actin;
 
-	err = generic_control_in(
+	err = uchcom_ctrl_read(
 		sc, UCHCOM_REQ_READ_REG,
 		reg1|((uint16_t)reg2<<8), 0, buf, sizeof buf, &actin);
 	if (err)
@@ -502,7 +502,7 @@
 	usbd_status err;
 	int actin;
 
-	err = generic_control_in(
+	err = uchcom_ctrl_read(
 		sc, UCHCOM_REQ_GET_VERSION, 0, 0, buf, sizeof buf, &actin);
 	if (err)
 		return err;
@@ -513,21 +513,21 @@
 }
 
 static __inline usbd_status
-get_status(struct uchcom_softc *sc, uint8_t *rval)
+uchcom_get_status(struct uchcom_softc *sc, uint8_t *rval)
 {
-	return read_reg(sc, UCHCOM_REG_STAT1, rval, UCHCOM_REG_STAT2, NULL);
+	return uchcom_read_reg(sc, UCHCOM_REG_STAT1, rval, UCHCOM_REG_STAT2, NULL);
 }
 
 static __inline usbd_status
-set_dtrrts_10(struct uchcom_softc *sc, uint8_t val)
+uchcom_set_dtrrts_10(struct uchcom_softc *sc, uint8_t val)
 {
-	return write_reg(sc, UCHCOM_REG_STAT1, val, UCHCOM_REG_STAT1, val);
+	return uchcom_write_reg(sc, UCHCOM_REG_STAT1, val, UCHCOM_REG_STAT1, val);
 }
 
 static __inline usbd_status
-set_dtrrts_20(struct uchcom_softc *sc, uint8_t val)
+uchcom_set_dtrrts_20(struct uchcom_softc *sc, uint8_t val)
 {
-	return generic_control_out(sc, UCHCOM_REQ_SET_DTRRTS, val, 0);
+	return uchcom_ctrl_write(sc, UCHCOM_REQ_SET_DTRRTS, val, 0);
 }
 
 
@@ -536,7 +536,7 @@
  */
 
 static int
-update_version(struct uchcom_softc *sc)
+uchcom_update_version(struct uchcom_softc *sc)
 {
 	usbd_status err;
 
@@ -551,7 +551,7 @@
 }
 
 static void
-convert_status(struct uchcom_softc *sc, uint8_t cur)
+uchcom_convert_status(struct uchcom_softc *sc, uint8_t cur)
 {
 	sc->sc_dtr = !(cur & UCHCOM_DTR_MASK);
 	sc->sc_rts = !(cur & UCHCOM_RTS_MASK);
@@ -566,21 +566,21 @@
 	usbd_status err;
 	uint8_t cur;
 
-	err = get_status(sc, &cur);
+	err = uchcom_get_status(sc, &cur);
 	if (err) {
 		device_printf(sc->sc_ucom.sc_dev, 
 			      "cannot update status: %s\n",
 			      usbd_errstr(err));
 		return EIO;
 	}
-	convert_status(sc, cur);
+	uchcom_convert_status(sc, cur);
 
 	return 0;
 }
 
 
 static int
-set_dtrrts(struct uchcom_softc *sc, int dtr, int rts)
+uchcom_set_dtrrts(struct uchcom_softc *sc, int dtr, int rts)
 {
 	usbd_status err;
 	uint8_t val = 0;
@@ -589,9 +589,9 @@
 	if (rts) val |= UCHCOM_RTS_MASK;
 
 	if (sc->sc_version < UCHCOM_VER_20)
-		err = set_dtrrts_10(sc, ~val);
+		err = uchcom_set_dtrrts_10(sc, ~val);
 	else
-		err = set_dtrrts_20(sc, ~val);
+		err = uchcom_set_dtrrts_20(sc, ~val);
 
 	if (err) {
 		device_printf(sc->sc_ucom.sc_dev, "cannot set DTR/RTS: %s\n",
@@ -603,12 +603,12 @@
 }
 
 static int
-set_break(struct uchcom_softc *sc, int onoff)
+uchcom_set_break(struct uchcom_softc *sc, int onoff)
 {
 	usbd_status err;
 	uint8_t brk1, brk2;
 
-	err = read_reg(sc, UCHCOM_REG_BREAK1, &brk1, UCHCOM_REG_BREAK2, &brk2);
+	err = uchcom_read_reg(sc, UCHCOM_REG_BREAK1, &brk1, UCHCOM_REG_BREAK2, &brk2);
 	if (err)
 		return EIO;
 	if (onoff) {
@@ -620,7 +620,7 @@
 		brk1 |= UCHCOM_BRK1_MASK;
 		brk2 |= UCHCOM_BRK2_MASK;
 	}
-	err = write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_BREAK2, brk2);
+	err = uchcom_write_reg(sc, UCHCOM_REG_BREAK1, brk1, UCHCOM_REG_BREAK2, brk2);
 	if (err)
 		return EIO;
 
@@ -628,7 +628,7 @@
 }
 
 static int
-calc_divider_settings(struct uchcom_divider *dp, uint32_t rate)
+uchcom_calc_divider_settings(struct uchcom_divider *dp, uint32_t rate)
 {
 	int i;
 	const struct uchcom_divider_record *rp;
@@ -667,18 +667,18 @@
 }
 
 static int
-set_dte_rate(struct uchcom_softc *sc, uint32_t rate)
+uchcom_set_dte_rate(struct uchcom_softc *sc, uint32_t rate)
 {
 	usbd_status err;
 	struct uchcom_divider dv;
 
-	if (calc_divider_settings(&dv, rate))
+	if (uchcom_calc_divider_settings(&dv, rate))
 		return EINVAL;
 
-	if ((err = write_reg(sc,
+	if ((err = uchcom_write_reg(sc,
 			     UCHCOM_REG_BPS_PRE, dv.dv_prescaler,
 			     UCHCOM_REG_BPS_DIV, dv.dv_div)) ||
-	    (err = write_reg(sc,
+	    (err = uchcom_write_reg(sc,
 			     UCHCOM_REG_BPS_MOD, dv.dv_mod,
 			     UCHCOM_REG_BPS_PAD, 0))) {
 		device_printf(sc->sc_ucom.sc_dev, " cannot set DTE rate: %s\n",
@@ -690,12 +690,12 @@
 }
 
 static int
-set_line_control(struct uchcom_softc *sc, tcflag_t cflag)
+uchcom_set_line_control(struct uchcom_softc *sc, tcflag_t cflag)
 {
 	usbd_status err;
 	uint8_t lcr1 = 0, lcr2 = 0;
 
-	err = read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2, &lcr2);
+	err = uchcom_read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2, &lcr2);
 	if (err) {
 		device_printf(sc->sc_ucom.sc_dev, " cannot get LCR: %s\n",
 		        usbd_errstr(err));
@@ -731,7 +731,7 @@
 			lcr2 |= UCHCOM_LCR2_PAREVEN;
 	}
 
-	err = write_reg(sc, UCHCOM_REG_LCR1, lcr1, UCHCOM_REG_LCR2, lcr2);
+	err = uchcom_write_reg(sc, UCHCOM_REG_LCR1, lcr1, UCHCOM_REG_LCR2, lcr2);
 	if (err) {
 		device_printf(sc->sc_ucom.sc_dev, "cannot set LCR: %s\n",
 			      usbd_errstr(err));
@@ -742,12 +742,12 @@
 }
 
 static int
-clear_chip(struct uchcom_softc *sc)
+uchcom_clear_chip(struct uchcom_softc *sc)
 {
 	usbd_status err;
 
 	DPRINTF(("%s: clear\n", USBDEVNAME(sc->sc_dev)));
-	err = generic_control_out(sc, UCHCOM_REQ_RESET, 0, 0);
+	err = uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, 0, 0);
 	if (err) {
 		device_printf(sc->sc_ucom.sc_dev, "cannot clear: %s\n",
 			      usbd_errstr(err));
@@ -758,21 +758,21 @@
 }
 
 static int
-reset_chip(struct uchcom_softc *sc)
+uchcom_reset_chip(struct uchcom_softc *sc)
 {
 	usbd_status err;
 	uint8_t lcr1, lcr2, pre, div, mod;
 	uint16_t val=0, idx=0;
 
-	err = read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2, &lcr2);
+	err = uchcom_read_reg(sc, UCHCOM_REG_LCR1, &lcr1, UCHCOM_REG_LCR2, &lcr2);
 	if (err)
 		goto failed;
 
-	err = read_reg(sc, UCHCOM_REG_BPS_PRE, &pre, UCHCOM_REG_BPS_DIV, &div);
+	err = uchcom_read_reg(sc, UCHCOM_REG_BPS_PRE, &pre, UCHCOM_REG_BPS_DIV, &div);
 	if (err)
 		goto failed;
 
-	err = read_reg(sc, UCHCOM_REG_BPS_MOD, &mod, UCHCOM_REG_BPS_PAD, NULL);
+	err = uchcom_read_reg(sc, UCHCOM_REG_BPS_MOD, &mod, UCHCOM_REG_BPS_PAD, NULL);
 	if (err)
 		goto failed;
 
@@ -790,7 +790,7 @@
 	DPRINTF(("%s: reset v=0x%04X, i=0x%04X\n",
 		 USBDEVNAME(sc->sc_dev), val, idx));
 
-	err = generic_control_out(sc, UCHCOM_REQ_RESET, val, idx);
+	err = uchcom_ctrl_write(sc, UCHCOM_REQ_RESET, val, idx);
 	if (err)
 		goto failed;
 
@@ -803,23 +803,23 @@
 }
 
 static int
-setup_comm(struct uchcom_softc *sc)
+uchcom_setup_comm(struct uchcom_softc *sc)
 {
 	int ret;
 
-	ret = update_version(sc);
+	ret = uchcom_update_version(sc);
 	if (ret)
 		return ret;
 
-	ret = clear_chip(sc);
+	ret = uchcom_clear_chip(sc);
 	if (ret)
 		return ret;
 
-	ret = set_dte_rate(sc, TTYDEF_SPEED);
+	ret = uchcom_set_dte_rate(sc, TTYDEF_SPEED);
 	if (ret)
 		return ret;
 
-	ret = set_line_control(sc, CS8);
+	ret = uchcom_set_line_control(sc, CS8);
 	if (ret)
 		return ret;
 
@@ -827,16 +827,16 @@
 	if (ret)
 		return ret;
 
-	ret = reset_chip(sc);
+	ret = uchcom_reset_chip(sc);
 	if (ret)
 		return ret;
 
-	ret = set_dte_rate(sc, TTYDEF_SPEED); /* XXX */
+	ret = uchcom_set_dte_rate(sc, TTYDEF_SPEED); /* XXX */
 	if (ret)
 		return ret;
 
 	sc->sc_dtr = sc->sc_rts = 1;
-	ret = set_dtrrts(sc, sc->sc_dtr, sc->sc_rts);
+	ret = uchcom_set_dtrrts(sc, sc->sc_dtr, sc->sc_rts);
 	if (ret)
 		return ret;
 
@@ -844,7 +844,7 @@
 }
 
 static int
-setup_intr_pipe(struct uchcom_softc *sc)
+uchcom_setup_intr_pipe(struct uchcom_softc *sc)
 {
 	usbd_status err;
 	struct ucom_softc *ucom = &sc->sc_ucom;
@@ -868,7 +868,7 @@
 }
 
 static void
-close_intr_pipe(struct uchcom_softc *sc)
+uchcom_close_intr_pipe(struct uchcom_softc *sc)
 {
 	usbd_status err;
 	struct ucom_softc *ucom = &sc->sc_ucom;
@@ -896,7 +896,7 @@
  * methods for ucom
  */
 void
-uchcom_get_status(void *arg, int portno, u_char *rlsr, u_char *rmsr)
+uchcom_uchcom_get_status(void *arg, int portno, u_char *rlsr, u_char *rmsr)
 {
 	struct uchcom_softc *sc = arg;
 
@@ -918,14 +918,14 @@
 	switch (reg) {
 	case UCOM_SET_DTR:
 		sc->sc_dtr = !!onoff;
-		set_dtrrts(sc, sc->sc_dtr, sc->sc_rts);
+		uchcom_set_dtrrts(sc, sc->sc_dtr, sc->sc_rts);
 		break;
 	case UCOM_SET_RTS:
 		sc->sc_rts = !!onoff;
-		set_dtrrts(sc, sc->sc_dtr, sc->sc_rts);
+		uchcom_set_dtrrts(sc, sc->sc_dtr, sc->sc_rts);
 		break;
 	case UCOM_SET_BREAK:
-		set_break(sc, onoff);
+		uchcom_set_break(sc, onoff);
 		break;
 	}
 }
@@ -939,11 +939,11 @@
 	if (sc->sc_ucom.sc_dying)
 		return 0;
 
-	ret = set_line_control(sc, t->c_cflag);
+	ret = uchcom_set_line_control(sc, t->c_cflag);
 	if (ret)
 		return ret;
 
-	ret = set_dte_rate(sc, t->c_ospeed);
+	ret = uchcom_set_dte_rate(sc, t->c_ospeed);
 	if (ret)
 		return ret;
 
@@ -959,11 +959,11 @@
 	if (sc->sc_ucom.sc_dying)
 		return EIO;
 
-	ret = setup_intr_pipe(sc);
+	ret = uchcom_setup_intr_pipe(sc);
 	if (ret)
 		return ret;
 
-	ret = setup_comm(sc);
+	ret = uchcom_setup_comm(sc);
 	if (ret)
 		return ret;
 
@@ -978,7 +978,7 @@
 	if (sc->sc_ucom.sc_dying)
 		return;
 
-	close_intr_pipe(sc);
+	uchcom_close_intr_pipe(sc);
 }
 
 
@@ -1012,7 +1012,7 @@
 		 (unsigned)buf[4], (unsigned)buf[5],
 		 (unsigned)buf[6], (unsigned)buf[7]));
 
-	convert_status(sc, buf[UCHCOM_INTR_STAT1]);
+	uchcom_convert_status(sc, buf[UCHCOM_INTR_STAT1]);
 	ucom_status_change(&sc->sc_ucom);
 }
 


More information about the p4-projects mailing list