summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2007-09-09 06:22:06 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2007-09-09 06:22:06 +0000
commit05d9da80b7b9a00fb64d36fa9019fe0fc8bdbb9a (patch)
tree34c23b2844b88d7417d0e41a07e268698e890df1 /sys/dev/usb
parentb379bfba6071fa4b9b45623eedcb70f0e062c254 (diff)
Properly prefix all functions with driver name.
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/uchcom.c204
1 files changed, 107 insertions, 97 deletions
diff --git a/sys/dev/usb/uchcom.c b/sys/dev/usb/uchcom.c
index 89834ec0141..4217aa756ad 100644
--- a/sys/dev/usb/uchcom.c
+++ b/sys/dev/usb/uchcom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uchcom.c,v 1.2 2007/09/08 04:05:36 jsg Exp $ */
+/* $OpenBSD: uchcom.c,v 1.3 2007/09/09 06:22:05 jsg Exp $ */
/* $NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $ */
/*
@@ -177,37 +177,38 @@ void uchcom_close(void *, int);
void uchcom_intr(usbd_xfer_handle, usbd_private_handle,
usbd_status);
-int set_config(struct uchcom_softc *);
-int find_ifaces(struct uchcom_softc *, usbd_interface_handle *);
-int find_endpoints(struct uchcom_softc *,
+int uchcom_set_config(struct uchcom_softc *);
+int uchcom_find_ifaces(struct uchcom_softc *,
+ usbd_interface_handle *);
+int uchcom_find_endpoints(struct uchcom_softc *,
struct uchcom_endpoints *);
-void close_intr_pipe(struct uchcom_softc *);
+void uchcom_close_intr_pipe(struct uchcom_softc *);
-usbd_status generic_control_out(struct uchcom_softc *sc, uint8_t reqno,
- uint16_t value, uint16_t index);
-usbd_status generic_control_in(struct uchcom_softc *, uint8_t,
+usbd_status uchcom_generic_control_out(struct uchcom_softc *sc,
+ uint8_t reqno, uint16_t value, uint16_t index);
+usbd_status uchcom_generic_control_in(struct uchcom_softc *, uint8_t,
uint16_t, uint16_t, void *, int, int *);
-usbd_status write_reg(struct uchcom_softc *, uint8_t, uint8_t, uint8_t,
- uint8_t);
-usbd_status read_reg(struct uchcom_softc *, uint8_t, uint8_t *, uint8_t,
- uint8_t *);
-usbd_status get_version(struct uchcom_softc *, uint8_t *);
-usbd_status get_status(struct uchcom_softc *, uint8_t *);
-usbd_status set_dtrrts_10(struct uchcom_softc *, uint8_t);
-usbd_status set_dtrrts_20(struct uchcom_softc *, uint8_t);
-int update_version(struct uchcom_softc *);
-void convert_status(struct uchcom_softc *, uint8_t);
-int update_status(struct uchcom_softc *);
-int set_dtrrts(struct uchcom_softc *, int, int);
-int set_break(struct uchcom_softc *, int);
-int calc_divider_settings(struct uchcom_divider *, uint32_t);
-int set_dte_rate(struct uchcom_softc *, uint32_t);
-int set_line_control(struct uchcom_softc *, tcflag_t);
-int clear_chip(struct uchcom_softc *);
-int reset_chip(struct uchcom_softc *);
-int setup_comm(struct uchcom_softc *);
-int setup_intr_pipe(struct uchcom_softc *);
+usbd_status uchcom_write_reg(struct uchcom_softc *, uint8_t, uint8_t,
+ uint8_t, uint8_t);
+usbd_status uchcom_read_reg(struct uchcom_softc *, uint8_t, uint8_t *,
+ uint8_t, uint8_t *);
+usbd_status uchcom_get_version(struct uchcom_softc *, uint8_t *);
+usbd_status uchcom_read_status(struct uchcom_softc *, uint8_t *);
+usbd_status uchcom_set_dtrrts_10(struct uchcom_softc *, uint8_t);
+usbd_status uchcom_set_dtrrts_20(struct uchcom_softc *, uint8_t);
+int uchcom_update_version(struct uchcom_softc *);
+void uchcom_convert_status(struct uchcom_softc *, uint8_t);
+int uchcom_update_status(struct uchcom_softc *);
+int uchcom_set_dtrrts(struct uchcom_softc *, int, int);
+int uchcom_set_break(struct uchcom_softc *, int);
+int uchcom_calc_divider_settings(struct uchcom_divider *, uint32_t);
+int uchcom_set_dte_rate(struct uchcom_softc *, uint32_t);
+int uchcom_set_line_control(struct uchcom_softc *, tcflag_t);
+int uchcom_clear_chip(struct uchcom_softc *);
+int uchcom_reset_chip(struct uchcom_softc *);
+int uchcom_setup_comm(struct uchcom_softc *);
+int uchcom_setup_intr_pipe(struct uchcom_softc *);
int uchcom_match(struct device *, void *, void *);
@@ -280,7 +281,7 @@ uchcom_attach(struct device *parent, struct device *self, void *aux)
DPRINTF(("\n\nuchcom attach: sc=%p\n", sc));
- if (set_config(sc))
+ if (uchcom_set_config(sc))
goto failed;
switch (uaa->release) {
@@ -292,10 +293,10 @@ uchcom_attach(struct device *parent, struct device *self, void *aux)
break;
}
- if (find_ifaces(sc, &sc->sc_iface))
+ if (uchcom_find_ifaces(sc, &sc->sc_iface))
goto failed;
- if (find_endpoints(sc, &endpoints))
+ if (uchcom_find_endpoints(sc, &endpoints))
goto failed;
sc->sc_intr_endpoint = endpoints.ep_intr;
@@ -334,7 +335,7 @@ uchcom_detach(struct device *self, int flags)
DPRINTF(("uchcom_detach: sc=%p flags=%d\n", sc, flags));
- close_intr_pipe(sc);
+ uchcom_close_intr_pipe(sc);
sc->sc_dying = 1;
@@ -360,7 +361,7 @@ uchcom_activate(struct device *self, enum devact act)
rv = EOPNOTSUPP;
break;
case DVACT_DEACTIVATE:
- close_intr_pipe(sc);
+ uchcom_close_intr_pipe(sc);
sc->sc_dying = 1;
if (sc->sc_subdev != NULL)
rv = config_deactivate(sc->sc_subdev);
@@ -370,7 +371,7 @@ uchcom_activate(struct device *self, enum devact act)
}
int
-set_config(struct uchcom_softc *sc)
+uchcom_set_config(struct uchcom_softc *sc)
{
usbd_status err;
@@ -385,7 +386,7 @@ set_config(struct uchcom_softc *sc)
}
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;
@@ -401,7 +402,8 @@ find_ifaces(struct uchcom_softc *sc, usbd_interface_handle *riface)
}
int
-find_endpoints(struct uchcom_softc *sc, struct uchcom_endpoints *endpoints)
+uchcom_find_endpoints(struct uchcom_softc *sc,
+ struct uchcom_endpoints *endpoints)
{
int i, bin=-1, bout=-1, intr=-1, isize=0;
usb_interface_descriptor_t *id;
@@ -467,7 +469,7 @@ find_endpoints(struct uchcom_softc *sc, struct uchcom_endpoints *endpoints)
*/
usbd_status
-generic_control_out(struct uchcom_softc *sc, uint8_t reqno,
+uchcom_generic_control_out(struct uchcom_softc *sc, uint8_t reqno,
uint16_t value, uint16_t index)
{
usb_device_request_t req;
@@ -482,7 +484,7 @@ generic_control_out(struct uchcom_softc *sc, uint8_t reqno,
}
usbd_status
-generic_control_in(struct uchcom_softc *sc, uint8_t reqno,
+uchcom_generic_control_in(struct uchcom_softc *sc, uint8_t reqno,
uint16_t value, uint16_t index, void *buf, int buflen, int *actlen)
{
usb_device_request_t req;
@@ -499,26 +501,26 @@ generic_control_in(struct uchcom_softc *sc, uint8_t reqno,
}
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_generic_control_out(
sc, UCHCOM_REQ_WRITE_REG,
reg1|((uint16_t)reg2<<8), val1|((uint16_t)val2<<8));
}
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_generic_control_in(
sc, UCHCOM_REQ_READ_REG,
reg1|((uint16_t)reg2<<8), 0, buf, sizeof buf, &actin);
if (err)
@@ -535,13 +537,13 @@ read_reg(struct uchcom_softc *sc,
}
usbd_status
-get_version(struct uchcom_softc *sc, uint8_t *rver)
+uchcom_get_version(struct uchcom_softc *sc, uint8_t *rver)
{
uint8_t buf[UCHCOM_INPUT_BUF_SIZE];
usbd_status err;
int actin;
- err = generic_control_in(
+ err = uchcom_generic_control_in(
sc, UCHCOM_REQ_GET_VERSION, 0, 0, buf, sizeof buf, &actin);
if (err)
return err;
@@ -552,21 +554,23 @@ get_version(struct uchcom_softc *sc, uint8_t *rver)
}
usbd_status
-get_status(struct uchcom_softc *sc, uint8_t *rval)
+uchcom_read_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);
}
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);
}
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_generic_control_out(sc, UCHCOM_REQ_SET_DTRRTS, val, 0);
}
@@ -575,11 +579,11 @@ set_dtrrts_20(struct uchcom_softc *sc, uint8_t val)
*/
int
-update_version(struct uchcom_softc *sc)
+uchcom_update_version(struct uchcom_softc *sc)
{
usbd_status err;
- err = get_version(sc, &sc->sc_version);
+ err = uchcom_get_version(sc, &sc->sc_version);
if (err) {
printf("%s: cannot get version: %s\n",
sc->sc_dev.dv_xname, usbd_errstr(err));
@@ -590,7 +594,7 @@ update_version(struct uchcom_softc *sc)
}
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);
@@ -600,25 +604,25 @@ convert_status(struct uchcom_softc *sc, uint8_t cur)
}
int
-update_status(struct uchcom_softc *sc)
+uchcom_update_status(struct uchcom_softc *sc)
{
usbd_status err;
uint8_t cur;
- err = get_status(sc, &cur);
+ err = uchcom_read_status(sc, &cur);
if (err) {
printf("%s: cannot update status: %s\n",
sc->sc_dev.dv_xname, usbd_errstr(err));
return EIO;
}
- convert_status(sc, cur);
+ uchcom_convert_status(sc, cur);
return 0;
}
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;
@@ -627,9 +631,9 @@ set_dtrrts(struct uchcom_softc *sc, int dtr, int rts)
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) {
printf("%s: cannot set DTR/RTS: %s\n",
@@ -641,12 +645,13 @@ set_dtrrts(struct uchcom_softc *sc, int dtr, int rts)
}
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) {
@@ -658,7 +663,8 @@ set_break(struct uchcom_softc *sc, int onoff)
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;
@@ -666,7 +672,7 @@ set_break(struct uchcom_softc *sc, int onoff)
}
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;
@@ -705,18 +711,18 @@ found:
}
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))) {
printf("%s: cannot set DTE rate: %s\n",
@@ -728,12 +734,13 @@ set_dte_rate(struct uchcom_softc *sc, uint32_t rate)
}
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) {
printf("%s: cannot get LCR: %s\n",
sc->sc_dev.dv_xname, usbd_errstr(err));
@@ -769,7 +776,8 @@ set_line_control(struct uchcom_softc *sc, tcflag_t cflag)
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) {
printf("%s: cannot set LCR: %s\n",
sc->sc_dev.dv_xname, usbd_errstr(err));
@@ -780,12 +788,12 @@ set_line_control(struct uchcom_softc *sc, tcflag_t cflag)
}
int
-clear_chip(struct uchcom_softc *sc)
+uchcom_clear_chip(struct uchcom_softc *sc)
{
usbd_status err;
DPRINTF(("%s: clear\n", sc->sc_dev.dv_xname));
- err = generic_control_out(sc, UCHCOM_REQ_RESET, 0, 0);
+ err = uchcom_generic_control_out(sc, UCHCOM_REQ_RESET, 0, 0);
if (err) {
printf("%s: cannot clear: %s\n",
sc->sc_dev.dv_xname, usbd_errstr(err));
@@ -796,21 +804,23 @@ clear_chip(struct uchcom_softc *sc)
}
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;
@@ -828,7 +838,7 @@ reset_chip(struct uchcom_softc *sc)
DPRINTF(("%s: reset v=0x%04X, i=0x%04X\n",
sc->sc_dev.dv_xname, val, idx));
- err = generic_control_out(sc, UCHCOM_REQ_RESET, val, idx);
+ err = uchcom_generic_control_out(sc, UCHCOM_REQ_RESET, val, idx);
if (err)
goto failed;
@@ -841,40 +851,40 @@ failed:
}
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;
- ret = update_status(sc);
+ ret = uchcom_update_status(sc);
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;
@@ -882,7 +892,7 @@ setup_comm(struct uchcom_softc *sc)
}
int
-setup_intr_pipe(struct uchcom_softc *sc)
+uchcom_setup_intr_pipe(struct uchcom_softc *sc)
{
usbd_status err;
@@ -906,7 +916,7 @@ setup_intr_pipe(struct uchcom_softc *sc)
}
void
-close_intr_pipe(struct uchcom_softc *sc)
+uchcom_close_intr_pipe(struct uchcom_softc *sc)
{
usbd_status err;
@@ -954,14 +964,14 @@ uchcom_set(void *arg, int portno, int reg, int onoff)
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;
}
}
@@ -975,11 +985,11 @@ uchcom_param(void *arg, int portno, struct termios *t)
if (sc->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;
@@ -995,11 +1005,11 @@ uchcom_open(void *arg, int portno)
if (sc->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;
@@ -1014,7 +1024,7 @@ uchcom_close(void *arg, int portno)
if (sc->sc_dying)
return;
- close_intr_pipe(sc);
+ uchcom_close_intr_pipe(sc);
}
@@ -1048,6 +1058,6 @@ uchcom_intr(usbd_xfer_handle xfer, usbd_private_handle priv,
(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((struct ucom_softc *) sc->sc_subdev);
}