=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sndiod/siofile.c,v retrieving revision 1.20 retrieving revision 1.21 diff -c -r1.20 -r1.21 *** src/usr.bin/sndiod/siofile.c 2020/06/12 15:40:18 1.20 --- src/usr.bin/sndiod/siofile.c 2020/06/18 05:11:13 1.21 *************** *** 1,4 **** ! /* $OpenBSD: siofile.c,v 1.20 2020/06/12 15:40:18 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * --- 1,4 ---- ! /* $OpenBSD: siofile.c,v 1.21 2020/06/18 05:11:13 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * *************** *** 93,117 **** static struct sio_hdl * dev_sio_openlist(struct dev *d, unsigned int mode, struct sioctl_hdl **rctlhdl) { ! struct name *n; struct sio_hdl *hdl; struct sioctl_hdl *ctlhdl; - int idx; ! idx = 0; ! n = d->path_list; ! while (1) { ! if (n == NULL) ! break; ! hdl = fdpass_sio_open(d->num, idx, mode); if (hdl != NULL) { if (log_level >= 2) { dev_log(d); log_puts(": using "); ! log_puts(n->str); log_puts("\n"); } ! ctlhdl = fdpass_sioctl_open(d->num, idx, SIOCTL_READ | SIOCTL_WRITE); if (ctlhdl == NULL) { if (log_level >= 1) { --- 93,114 ---- static struct sio_hdl * dev_sio_openlist(struct dev *d, unsigned int mode, struct sioctl_hdl **rctlhdl) { ! struct dev_alt *n; struct sio_hdl *hdl; struct sioctl_hdl *ctlhdl; ! for (n = d->alt_list; n != NULL; n = n->next) { ! if (d->alt_num == n->idx) ! continue; ! hdl = fdpass_sio_open(d->num, n->idx, mode); if (hdl != NULL) { if (log_level >= 2) { dev_log(d); log_puts(": using "); ! log_puts(n->name); log_puts("\n"); } ! ctlhdl = fdpass_sioctl_open(d->num, n->idx, SIOCTL_READ | SIOCTL_WRITE); if (ctlhdl == NULL) { if (log_level >= 1) { *************** *** 119,129 **** log_puts(": no control device\n"); } } *rctlhdl = ctlhdl; return hdl; } - n = n->next; - idx++; } return NULL; } --- 116,125 ---- log_puts(": no control device\n"); } } + d->alt_num = n->idx; *rctlhdl = ctlhdl; return hdl; } } return NULL; } *************** *** 378,383 **** --- 374,380 ---- sioctl_close(d->sioctl.hdl); d->sioctl.hdl = NULL; } + d->alt_num = -1; } void