Rename _setctl -> _setval and _onctl -> _onval

This commit is contained in:
Alexandre Ratchov 2020-01-03 15:30:06 +01:00
parent 6e83bb6a4f
commit d2057194b1
13 changed files with 43 additions and 43 deletions

View File

@ -35,7 +35,7 @@ MAN3 = \
sio_nfds.3 sio_pollfd.3 sio_revents.3 sio_eof.3 \ sio_nfds.3 sio_pollfd.3 sio_revents.3 sio_eof.3 \
sio_setvol.3 sio_onvol.3 sio_initpar.3 \ sio_setvol.3 sio_onvol.3 sio_initpar.3 \
sioctl_open.3 \ sioctl_open.3 \
sioctl_close.3 sioctl_setctl.3 sioctl_ondesc.3 sioctl_onctl.3 \ sioctl_close.3 sioctl_setval.3 sioctl_ondesc.3 sioctl_onval.3 \
sioctl_nfds.3 sioctl_pollfd.3 sioctl_revents.3 sioctl_eof.3 \ sioctl_nfds.3 sioctl_pollfd.3 sioctl_revents.3 sioctl_eof.3 \
mio_open.3 \ mio_open.3 \
mio_close.3 mio_read.3 mio_write.3 mio_nfds.3 mio_pollfd.3 \ mio_close.3 mio_read.3 mio_write.3 mio_nfds.3 mio_pollfd.3 \
@ -79,9 +79,9 @@ install:
ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_initpar.3 ln -sf sio_open.3 ${DESTDIR}${MAN3_DIR}/sio_initpar.3
cp sioctl_open.3 ${DESTDIR}${MAN3_DIR} cp sioctl_open.3 ${DESTDIR}${MAN3_DIR}
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_close.3 ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_close.3
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_setctl.3 ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_setval.3
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_ondesc.3 ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_ondesc.3
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_onctl.3 ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_onval.3
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_nfds.3 ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_nfds.3
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_pollfd.3 ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_pollfd.3
ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_revents.3 ln -sf sioctl_open.3 ${DESTDIR}${MAN3_DIR}/sioctl_revents.3

View File

@ -149,7 +149,7 @@ sioctl_ondesc(struct sioctl_hdl *hdl,
} }
int int
sioctl_onctl(struct sioctl_hdl *hdl, sioctl_onval(struct sioctl_hdl *hdl,
void (*cb)(void *, unsigned int, unsigned int), void *arg) void (*cb)(void *, unsigned int, unsigned int), void *arg)
{ {
hdl->ctl_cb = cb; hdl->ctl_cb = cb;
@ -174,15 +174,15 @@ _sioctl_ondesc_cb(struct sioctl_hdl *hdl,
} }
void void
_sioctl_onctl_cb(struct sioctl_hdl *hdl, unsigned int addr, unsigned int val) _sioctl_onval_cb(struct sioctl_hdl *hdl, unsigned int addr, unsigned int val)
{ {
DPRINTF("_sioctl_onctl_cb: %u -> %u\n", addr, val); DPRINTF("_sioctl_onval_cb: %u -> %u\n", addr, val);
if (hdl->ctl_cb) if (hdl->ctl_cb)
hdl->ctl_cb(hdl->ctl_arg, addr, val); hdl->ctl_cb(hdl->ctl_arg, addr, val);
} }
int int
sioctl_setctl(struct sioctl_hdl *hdl, unsigned int addr, unsigned int val) sioctl_setval(struct sioctl_hdl *hdl, unsigned int addr, unsigned int val)
{ {
if (!(hdl->mode & SIOCTL_WRITE)) if (!(hdl->mode & SIOCTL_WRITE))
return 0; return 0;

View File

@ -40,7 +40,7 @@ static int sioctl_aucat_nfds(struct sioctl_hdl *);
static int sioctl_aucat_pollfd(struct sioctl_hdl *, struct pollfd *, int); static int sioctl_aucat_pollfd(struct sioctl_hdl *, struct pollfd *, int);
static int sioctl_aucat_revents(struct sioctl_hdl *, struct pollfd *); static int sioctl_aucat_revents(struct sioctl_hdl *, struct pollfd *);
static int sioctl_aucat_setctl(struct sioctl_hdl *, unsigned int, unsigned int); static int sioctl_aucat_setctl(struct sioctl_hdl *, unsigned int, unsigned int);
static int sioctl_aucat_onctl(struct sioctl_hdl *); static int sioctl_aucat_onval(struct sioctl_hdl *);
static int sioctl_aucat_ondesc(struct sioctl_hdl *); static int sioctl_aucat_ondesc(struct sioctl_hdl *);
/* /*
@ -52,7 +52,7 @@ struct sioctl_ops sioctl_aucat_ops = {
sioctl_aucat_pollfd, sioctl_aucat_pollfd,
sioctl_aucat_revents, sioctl_aucat_revents,
sioctl_aucat_setctl, sioctl_aucat_setctl,
sioctl_aucat_onctl, sioctl_aucat_onval,
sioctl_aucat_ondesc sioctl_aucat_ondesc
}; };
@ -117,7 +117,7 @@ sioctl_aucat_runmsg(struct sioctl_aucat_hdl *hdl)
break; break;
case AMSG_CTLSET: case AMSG_CTLSET:
DPRINTF("sioctl_aucat_runmsg: got CTLSET\n"); DPRINTF("sioctl_aucat_runmsg: got CTLSET\n");
_sioctl_onctl_cb(&hdl->sioctl, _sioctl_onval_cb(&hdl->sioctl,
ntohs(hdl->aucat.rmsg.u.ctlset.addr), ntohs(hdl->aucat.rmsg.u.ctlset.addr),
ntohs(hdl->aucat.rmsg.u.ctlset.val)); ntohs(hdl->aucat.rmsg.u.ctlset.val));
break; break;
@ -191,7 +191,7 @@ sioctl_aucat_ondesc(struct sioctl_hdl *addr)
} }
static int static int
sioctl_aucat_onctl(struct sioctl_hdl *addr) sioctl_aucat_onval(struct sioctl_hdl *addr)
{ {
struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr; struct sioctl_aucat_hdl *hdl = (struct sioctl_aucat_hdl *)addr;

View File

@ -21,8 +21,8 @@
.Nm sioctl_open , .Nm sioctl_open ,
.Nm sioctl_close , .Nm sioctl_close ,
.Nm sioctl_ondesc , .Nm sioctl_ondesc ,
.Nm sioctl_onctl , .Nm sioctl_onval ,
.Nm sioctl_setctl , .Nm sioctl_setval ,
.Nm sioctl_nfds , .Nm sioctl_nfds ,
.Nm sioctl_pollfd , .Nm sioctl_pollfd ,
.Nm sioctl_eof .Nm sioctl_eof
@ -36,9 +36,9 @@
.Ft "int" .Ft "int"
.Fn "sioctl_ondesc" "struct sioctl_hdl *hdl" "void (*cb)(void *arg, struct sioctl_desc *desc, int val)" "void *arg" .Fn "sioctl_ondesc" "struct sioctl_hdl *hdl" "void (*cb)(void *arg, struct sioctl_desc *desc, int val)" "void *arg"
.Ft "void" .Ft "void"
.Fn "sioctl_onctl" "struct sioctl_hdl *hdl" "void (*cb)(void *arg, unsigned int addr, unsigned int val)" "void *arg" .Fn "sioctl_onval" "struct sioctl_hdl *hdl" "void (*cb)(void *arg, unsigned int addr, unsigned int val)" "void *arg"
.Ft "int" .Ft "int"
.Fn "sioctl_setctl" "struct sioctl_hdl *hdl" "unsigned int addr" "unsigned int val" .Fn "sioctl_setval" "struct sioctl_hdl *hdl" "unsigned int addr" "unsigned int val"
.Ft "int" .Ft "int"
.Fn "sioctl_nfds" "struct sioctl_hdl *hdl" .Fn "sioctl_nfds" "struct sioctl_hdl *hdl"
.Ft "int" .Ft "int"
@ -86,7 +86,7 @@ modified respectively.
If the If the
.Ar nbio_flag .Ar nbio_flag
argument is 1, then the argument is 1, then the
.Fn sioctl_setctl .Fn sioctl_setval
function (see below) may fail instead of blocking and function (see below) may fail instead of blocking and
the the
.Fn sioctl_ondesc .Fn sioctl_ondesc
@ -192,10 +192,10 @@ are strings usable as unique identifiers within the the given
.Va namespace . .Va namespace .
.Sh Changing and reading control values .Sh Changing and reading control values
Controls are changed with the Controls are changed with the
.Fn sioctl_setctl .Fn sioctl_setval
function, by giving the index of the control and the new value. function, by giving the index of the control and the new value.
The The
.Fn sioctl_onctl .Fn sioctl_onval
function can be used to register a call-back which will be invoked whenever function can be used to register a call-back which will be invoked whenever
a control changes. a control changes.
Continuous values are in the 0..127 range. Continuous values are in the 0..127 range.
@ -231,7 +231,7 @@ structures.
If If
.Va POLLOUT .Va POLLOUT
is set, is set,
.Fn sioctl_setctl .Fn sioctl_setval
can be called without blocking. can be called without blocking.
POLLHUP may be set if an error occurs, even if POLLHUP may be set if an error occurs, even if
it is not selected with it is not selected with

View File

@ -61,7 +61,7 @@ void _sioctl_create(struct sioctl_hdl *,
struct sioctl_ops *, unsigned int, int); struct sioctl_ops *, unsigned int, int);
void _sioctl_ondesc_cb(struct sioctl_hdl *, void _sioctl_ondesc_cb(struct sioctl_hdl *,
struct sioctl_desc *, unsigned int); struct sioctl_desc *, unsigned int);
void _sioctl_onctl_cb(struct sioctl_hdl *, unsigned int, unsigned int); void _sioctl_onval_cb(struct sioctl_hdl *, unsigned int, unsigned int);
int _sioctl_psleep(struct sioctl_hdl *, int); int _sioctl_psleep(struct sioctl_hdl *, int);
#endif /* !defined(SIOCTL_PRIV_H) */ #endif /* !defined(SIOCTL_PRIV_H) */

View File

@ -67,7 +67,7 @@ static int sioctl_sun_nfds(struct sioctl_hdl *);
static int sioctl_sun_pollfd(struct sioctl_hdl *, struct pollfd *, int); static int sioctl_sun_pollfd(struct sioctl_hdl *, struct pollfd *, int);
static int sioctl_sun_revents(struct sioctl_hdl *, struct pollfd *); static int sioctl_sun_revents(struct sioctl_hdl *, struct pollfd *);
static int sioctl_sun_setctl(struct sioctl_hdl *, unsigned int, unsigned int); static int sioctl_sun_setctl(struct sioctl_hdl *, unsigned int, unsigned int);
static int sioctl_sun_onctl(struct sioctl_hdl *); static int sioctl_sun_onval(struct sioctl_hdl *);
static int sioctl_sun_ondesc(struct sioctl_hdl *); static int sioctl_sun_ondesc(struct sioctl_hdl *);
/* /*
@ -79,7 +79,7 @@ struct sioctl_ops sioctl_sun_ops = {
sioctl_sun_pollfd, sioctl_sun_pollfd,
sioctl_sun_revents, sioctl_sun_revents,
sioctl_sun_setctl, sioctl_sun_setctl,
sioctl_sun_onctl, sioctl_sun_onval,
sioctl_sun_ondesc sioctl_sun_ondesc
}; };
@ -187,7 +187,7 @@ setvol(struct sioctl_sun_hdl *hdl, struct wskbd_vol *vol, int addr, int val)
DPRINTF("level write failed\n"); DPRINTF("level write failed\n");
return 0; return 0;
} }
_sioctl_onctl_cb(&hdl->sioctl, vol->base_addr + addr, val); _sioctl_onval_cb(&hdl->sioctl, vol->base_addr + addr, val);
return 1; return 1;
} }
@ -208,7 +208,7 @@ setvol(struct sioctl_sun_hdl *hdl, struct wskbd_vol *vol, int addr, int val)
return 0; return 0;
} }
for (i = 0; i < vol->nch; i++) { for (i = 0; i < vol->nch; i++) {
_sioctl_onctl_cb(&hdl->sioctl, _sioctl_onval_cb(&hdl->sioctl,
vol->base_addr + 32 + i, val); vol->base_addr + 32 + i, val);
} }
return 1; return 1;
@ -371,7 +371,7 @@ sioctl_sun_ondesc(struct sioctl_hdl *addr)
} }
static int static int
sioctl_sun_onctl(struct sioctl_hdl *addr) sioctl_sun_onval(struct sioctl_hdl *addr)
{ {
return 1; return 1;
} }

View File

@ -184,9 +184,9 @@ struct sioctl_hdl *sioctl_open(const char *, unsigned int, int);
void sioctl_close(struct sioctl_hdl *); void sioctl_close(struct sioctl_hdl *);
int sioctl_ondesc(struct sioctl_hdl *, int sioctl_ondesc(struct sioctl_hdl *,
void (*)(void *, struct sioctl_desc *, int), void *); void (*)(void *, struct sioctl_desc *, int), void *);
int sioctl_onctl(struct sioctl_hdl *, int sioctl_onval(struct sioctl_hdl *,
void (*)(void *, unsigned int, unsigned int), void *); void (*)(void *, unsigned int, unsigned int), void *);
int sioctl_setctl(struct sioctl_hdl *, unsigned int, unsigned int); int sioctl_setval(struct sioctl_hdl *, unsigned int, unsigned int);
int sioctl_nfds(struct sioctl_hdl *); int sioctl_nfds(struct sioctl_hdl *);
int sioctl_pollfd(struct sioctl_hdl *, struct pollfd *, int); int sioctl_pollfd(struct sioctl_hdl *, struct pollfd *, int);
int sioctl_revents(struct sioctl_hdl *, struct pollfd *); int sioctl_revents(struct sioctl_hdl *, struct pollfd *);

View File

@ -710,11 +710,11 @@ commit(void)
switch (i->desc.type) { switch (i->desc.type) {
case SIOCTL_NUM: case SIOCTL_NUM:
case SIOCTL_SW: case SIOCTL_SW:
sioctl_setctl(hdl, i->ctladdr, val); sioctl_setval(hdl, i->ctladdr, val);
break; break;
case SIOCTL_VEC: case SIOCTL_VEC:
case SIOCTL_LIST: case SIOCTL_LIST:
sioctl_setctl(hdl, i->ctladdr, val); sioctl_setval(hdl, i->ctladdr, val);
} }
i->curval = val; i->curval = val;
} }
@ -866,7 +866,7 @@ main(int argc, char **argv)
fprintf(stderr, "%s: can't get device description\n", devname); fprintf(stderr, "%s: can't get device description\n", devname);
exit(1); exit(1);
} }
sioctl_onctl(hdl, onctl, NULL); sioctl_onval(hdl, onctl, NULL);
if (d_flag) { if (d_flag) {
if (argc > 0) { if (argc > 0) {

View File

@ -423,7 +423,7 @@ dev_midi_omsg(void *arg, unsigned char *msg, int len)
if (chan >= DEV_NSLOT) if (chan >= DEV_NSLOT)
return; return;
slot_setvol(d->slot + chan, msg[2]); slot_setvol(d->slot + chan, msg[2]);
dev_onctl(d, CTLADDR_SLOT_LEVEL(chan), msg[2]); dev_onval(d, CTLADDR_SLOT_LEVEL(chan), msg[2]);
return; return;
} }
x = (struct sysex *)msg; x = (struct sysex *)msg;
@ -436,7 +436,7 @@ dev_midi_omsg(void *arg, unsigned char *msg, int len)
if (x->id0 == SYSEX_CONTROL && x->id1 == SYSEX_MASTER) { if (x->id0 == SYSEX_CONTROL && x->id1 == SYSEX_MASTER) {
if (len == SYSEX_SIZE(master)) { if (len == SYSEX_SIZE(master)) {
dev_master(d, x->u.master.coarse); dev_master(d, x->u.master.coarse);
dev_onctl(d, CTLADDR_MASTER, dev_onval(d, CTLADDR_MASTER,
x->u.master.coarse); x->u.master.coarse);
} }
return; return;
@ -2386,7 +2386,7 @@ dev_setctl(struct dev *d, int addr, int val)
} }
int int
dev_onctl(struct dev *d, int addr, int val) dev_onval(struct dev *d, int addr, int val)
{ {
struct ctl *c; struct ctl *c;

View File

@ -302,7 +302,7 @@ void ctl_log(struct ctl *);
struct ctlslot *ctlslot_new(struct dev *, struct ctlops *, void *); struct ctlslot *ctlslot_new(struct dev *, struct ctlops *, void *);
void ctlslot_del(struct ctlslot *); void ctlslot_del(struct ctlslot *);
int dev_setctl(struct dev *, int, int); int dev_setctl(struct dev *, int, int);
int dev_onctl(struct dev *, int, int); int dev_onval(struct dev *, int, int);
int dev_nctl(struct dev *); int dev_nctl(struct dev *);
void dev_label(struct dev *, int); void dev_label(struct dev *, int);
struct ctl *dev_addctl(struct dev *, char *, int, int, int, struct ctl *dev_addctl(struct dev *, char *, int, int, int,

View File

@ -32,7 +32,7 @@
#include "bsd-compat.h" #include "bsd-compat.h"
void dev_sioctl_ondesc(void *, struct sioctl_desc *, int); void dev_sioctl_ondesc(void *, struct sioctl_desc *, int);
void dev_sioctl_onctl(void *, unsigned int, unsigned int); void dev_sioctl_onval(void *, unsigned int, unsigned int);
int dev_sioctl_pollfd(void *, struct pollfd *); int dev_sioctl_pollfd(void *, struct pollfd *);
int dev_sioctl_revents(void *, struct pollfd *); int dev_sioctl_revents(void *, struct pollfd *);
void dev_sioctl_in(void *); void dev_sioctl_in(void *);
@ -65,7 +65,7 @@ dev_sioctl_ondesc(void *arg, struct sioctl_desc *desc, int val)
} }
void void
dev_sioctl_onctl(void *arg, unsigned int addr, unsigned int val) dev_sioctl_onval(void *arg, unsigned int addr, unsigned int val)
{ {
struct dev *d = arg; struct dev *d = arg;
struct ctl *c; struct ctl *c;
@ -100,7 +100,7 @@ dev_sioctl_open(struct dev *d)
if (d->sioctl.hdl == NULL) if (d->sioctl.hdl == NULL)
return; return;
sioctl_ondesc(d->sioctl.hdl, dev_sioctl_ondesc, d); sioctl_ondesc(d->sioctl.hdl, dev_sioctl_ondesc, d);
sioctl_onctl(d->sioctl.hdl, dev_sioctl_onctl, d); sioctl_onval(d->sioctl.hdl, dev_sioctl_onval, d);
d->sioctl.file = file_new(&dev_sioctl_ops, d, "mix", d->sioctl.file = file_new(&dev_sioctl_ops, d, "mix",
sioctl_nfds(d->sioctl.hdl)); sioctl_nfds(d->sioctl.hdl));
} }
@ -151,7 +151,7 @@ dev_sioctl_out(void *arg)
int cnt; int cnt;
/* /*
* for each dirty ctl, call sioctl_setctl() and dev_unref(). As * for each dirty ctl, call sioctl_setval() and dev_unref(). As
* dev_unref() may destroy the ctl_list, we must call it after * dev_unref() may destroy the ctl_list, we must call it after
* we've finished iterating on it. * we've finished iterating on it.
*/ */
@ -159,7 +159,7 @@ dev_sioctl_out(void *arg)
for (c = d->ctl_list; c != NULL; c = c->next) { for (c = d->ctl_list; c != NULL; c = c->next) {
if (!c->dirty) if (!c->dirty)
continue; continue;
if (!sioctl_setctl(d->sioctl.hdl, if (!sioctl_setval(d->sioctl.hdl,
c->addr - CTLADDR_END, c->curval)) { c->addr - CTLADDR_END, c->curval)) {
ctl_log(c); ctl_log(c);
log_puts(": set failed\n"); log_puts(": set failed\n");

View File

@ -1205,7 +1205,7 @@ sock_execmsg(struct sock *f)
f->lastvol = ctl; /* dont trigger feedback message */ f->lastvol = ctl; /* dont trigger feedback message */
slot_setvol(s, ctl); slot_setvol(s, ctl);
dev_midi_vol(s->dev, s); dev_midi_vol(s->dev, s);
dev_onctl(s->dev, dev_onval(s->dev,
CTLADDR_SLOT_LEVEL(f->slot - s->dev->slot), ctl); CTLADDR_SLOT_LEVEL(f->slot - s->dev->slot), ctl);
break; break;
case AMSG_CTLSUB: case AMSG_CTLSUB:

View File

@ -80,7 +80,7 @@ dev_ondesc(void *unused, struct sioctl_desc *desc, int val)
* control value changed * control value changed
*/ */
static void static void
dev_onctl(void *unused, unsigned int addr, unsigned int val) dev_onval(void *unused, unsigned int addr, unsigned int val)
{ {
if (addr == master_addr) { if (addr == master_addr) {
if (verbose) if (verbose)
@ -120,7 +120,7 @@ dev_connect(void)
} }
master_found = 0; master_found = 0;
sioctl_ondesc(hdl, dev_ondesc, NULL); sioctl_ondesc(hdl, dev_ondesc, NULL);
sioctl_onctl(hdl, dev_onctl, NULL); sioctl_onval(hdl, dev_onval, NULL);
if (!master_found) if (!master_found)
fprintf(stderr, "%s: warning, couldn't find master control\n", fprintf(stderr, "%s: warning, couldn't find master control\n",
dev_name); dev_name);
@ -149,7 +149,7 @@ dev_incrvol(int incr)
fprintf(stderr, "%s: setting volume to %d\n", fprintf(stderr, "%s: setting volume to %d\n",
dev_name, vol); dev_name, vol);
} }
sioctl_setctl(hdl, master_addr, master_val); sioctl_setval(hdl, master_addr, master_val);
dev_disconnect(); dev_disconnect();
} }
} }