1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-18 15:30:21 +00:00

Fixed the type of timeout functions and removed casts that hid the

type mismatches.  mcd and scd were/are particularly bogus.  They
used a general purpose function taking 2 args for the timeout
function and fudged varargs stuff to supply the second arg for the
timeout case.  This broke `cc -mrtd'.  Bounce through a timeout
function instead.  The timeout arg still gets bogusly cast from
int to `void *' and back.
This commit is contained in:
Bruce Evans 1997-04-20 17:26:55 +00:00
parent 7cac787bee
commit 20925249e7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25056
4 changed files with 76 additions and 48 deletions

View File

@ -40,7 +40,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: mcd.c,v 1.86 1997/03/23 03:34:51 bde Exp $
* $Id: mcd.c,v 1.87 1997/03/24 11:23:55 bde Exp $
*/
static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
@ -185,6 +185,7 @@ static void hsg2msf(int hsg, bcd_t *msf);
static int msf2hsg(bcd_t *msf, int relative);
static int mcd_volinfo(int unit);
static int mcd_waitrdy(int port,int dly);
static timeout_t mcd_timeout;
static void mcd_doread(int state, struct mcd_mbx *mbxin);
static void mcd_soft_reset(int unit);
static int mcd_hard_reset(int unit);
@ -982,6 +983,12 @@ mcdintr(unit)
*/
static struct mcd_mbx *mbxsave;
static void
mcd_timeout(void *arg)
{
mcd_doread((int)arg, mbxsave);
}
static void
mcd_doread(int state, struct mcd_mbx *mbxin)
{
@ -1008,14 +1015,14 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
/* get status */
outb(com_port, MCD_CMDGETSTAT);
mbx->count = RDELAY_WAITSTAT;
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
return;
case MCD_S_WAITSTAT:
untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT);
untimeout(mcd_timeout,(caddr_t)MCD_S_WAITSTAT);
if (mbx->count-- >= 0) {
if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
return;
}
@ -1052,7 +1059,7 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
mcd_put(com_port, MCD_CMDSETMODE);
mcd_put(com_port, rm);
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITMODE,hz/100); /* XXX */
return;
} else {
@ -1061,13 +1068,13 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
}
case MCD_S_WAITMODE:
untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE);
untimeout(mcd_timeout,(caddr_t)MCD_S_WAITMODE);
if (mbx->count-- < 0) {
printf("mcd%d: timeout set mode\n",unit);
goto readerr;
}
if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100);
timeout(mcd_timeout,(caddr_t)MCD_S_WAITMODE,hz/100);
return;
}
cd->status = inb(port+mcd_status) & 0xFF;
@ -1115,11 +1122,11 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
}
mbx->count = RDELAY_WAITREAD;
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
return;
case MCD_S_WAITREAD:
untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITREAD);
untimeout(mcd_timeout,(caddr_t)MCD_S_WAITREAD);
if (mbx->count-- > 0) {
k = inb(port+MCD_FLAGS);
if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */
@ -1163,7 +1170,7 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
if (mcd_setflags(unit,cd) < 0)
goto changed;
}
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
return;
} else {

View File

@ -41,7 +41,7 @@
*/
/* $Id: scd.c,v 1.27 1997/02/22 09:37:03 peter Exp $ */
/* $Id: scd.c,v 1.28 1997/03/24 11:24:01 bde Exp $ */
/* Please send any comments to micke@dynas.se */
@ -164,6 +164,7 @@ static int get_result(u_int unit, int result_len, u_char *result);
static void print_error(int unit, int errcode);
static void scd_start(int unit);
static timeout_t scd_timeout;
static void scd_doread(int state, struct scd_mbx *mbxin);
static int scd_eject(int unit);
@ -776,6 +777,12 @@ read_subcode(int unit, struct sony_subchannel_position_data *sc)
static struct scd_mbx *mbxsave;
static void
scd_timeout(void *arg)
{
scd_doread((int)arg, mbxsave);
}
static void
scd_doread(int state, struct scd_mbx *mbxin)
{
@ -802,7 +809,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto trystat;
case SCD_S_WAITSTAT:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSTAT);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITSTAT);
if (mbx->count-- <= 0) {
printf("scd%d: timeout. drive busy.\n",unit);
goto harderr;
@ -810,7 +817,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
trystat:
if (IS_BUSY(port)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITSTAT,hz/100); /* XXX */
return;
}
@ -849,18 +856,18 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto writeparam;
mbx->count = 100;
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */
return;
case SCD_S_WAITSPIN:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSPIN);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITSPIN);
if (mbx->count-- <= 0) {
printf("scd%d: timeout waiting for drive to spin up.\n", unit);
goto harderr;
}
if (!STATUS_BIT(port, SBIT_RESULT_READY)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */
return;
}
@ -881,13 +888,13 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto loop;
case SCD_S_WAITFIFO:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITFIFO);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITFIFO);
if (mbx->count-- <= 0) {
printf("scd%d: timeout. write param not ready.\n",unit);
goto harderr;
}
if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */
return;
}
@ -900,7 +907,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
XDEBUG(1, ("scd%d: spinning up drive ...\n", unit));
outb(port+OREG_COMMAND, CMD_SPIN_UP);
mbx->count = 300;
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */
return;
}
@ -924,12 +931,12 @@ scd_doread(int state, struct scd_mbx *mbxin)
DELAY(100);
}
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */
return;
case SCD_S_WAITREAD:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITREAD);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITREAD);
if (mbx->count-- <= 0) {
if (STATUS_BIT(port, SBIT_RESULT_READY))
goto got_param;
@ -940,7 +947,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
process_attention(unit);
if (!(cd->flags & SCDVALID))
goto changed;
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */
return;
}
@ -961,7 +968,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto waitfor_param;
case SCD_S_WAITPARAM:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITPARAM);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITPARAM);
if (mbx->count-- <= 0) {
printf("scd%d: timeout waiting for params\n",unit);
goto readerr;
@ -969,7 +976,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
waitfor_param:
if (!STATUS_BIT(port, SBIT_RESULT_READY)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITPARAM,hz/100); /* XXX */
return;
}

View File

@ -40,7 +40,7 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: mcd.c,v 1.86 1997/03/23 03:34:51 bde Exp $
* $Id: mcd.c,v 1.87 1997/03/24 11:23:55 bde Exp $
*/
static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
@ -185,6 +185,7 @@ static void hsg2msf(int hsg, bcd_t *msf);
static int msf2hsg(bcd_t *msf, int relative);
static int mcd_volinfo(int unit);
static int mcd_waitrdy(int port,int dly);
static timeout_t mcd_timeout;
static void mcd_doread(int state, struct mcd_mbx *mbxin);
static void mcd_soft_reset(int unit);
static int mcd_hard_reset(int unit);
@ -982,6 +983,12 @@ mcdintr(unit)
*/
static struct mcd_mbx *mbxsave;
static void
mcd_timeout(void *arg)
{
mcd_doread((int)arg, mbxsave);
}
static void
mcd_doread(int state, struct mcd_mbx *mbxin)
{
@ -1008,14 +1015,14 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
/* get status */
outb(com_port, MCD_CMDGETSTAT);
mbx->count = RDELAY_WAITSTAT;
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
return;
case MCD_S_WAITSTAT:
untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITSTAT);
untimeout(mcd_timeout,(caddr_t)MCD_S_WAITSTAT);
if (mbx->count-- >= 0) {
if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITSTAT,hz/100); /* XXX */
return;
}
@ -1052,7 +1059,7 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
mcd_put(com_port, MCD_CMDSETMODE);
mcd_put(com_port, rm);
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITMODE,hz/100); /* XXX */
return;
} else {
@ -1061,13 +1068,13 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
}
case MCD_S_WAITMODE:
untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE);
untimeout(mcd_timeout,(caddr_t)MCD_S_WAITMODE);
if (mbx->count-- < 0) {
printf("mcd%d: timeout set mode\n",unit);
goto readerr;
}
if (inb(port+MCD_FLAGS) & MFL_STATUS_NOT_AVAIL) {
timeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITMODE,hz/100);
timeout(mcd_timeout,(caddr_t)MCD_S_WAITMODE,hz/100);
return;
}
cd->status = inb(port+mcd_status) & 0xFF;
@ -1115,11 +1122,11 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
}
mbx->count = RDELAY_WAITREAD;
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
return;
case MCD_S_WAITREAD:
untimeout((timeout_func_t)mcd_doread,(caddr_t)MCD_S_WAITREAD);
untimeout(mcd_timeout,(caddr_t)MCD_S_WAITREAD);
if (mbx->count-- > 0) {
k = inb(port+MCD_FLAGS);
if (!(k & MFL_DATA_NOT_AVAIL)) { /* XXX */
@ -1163,7 +1170,7 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
if (mcd_setflags(unit,cd) < 0)
goto changed;
}
timeout((timeout_func_t)mcd_doread,
timeout(mcd_timeout,
(caddr_t)MCD_S_WAITREAD,hz/100); /* XXX */
return;
} else {

View File

@ -41,7 +41,7 @@
*/
/* $Id: scd.c,v 1.27 1997/02/22 09:37:03 peter Exp $ */
/* $Id: scd.c,v 1.28 1997/03/24 11:24:01 bde Exp $ */
/* Please send any comments to micke@dynas.se */
@ -164,6 +164,7 @@ static int get_result(u_int unit, int result_len, u_char *result);
static void print_error(int unit, int errcode);
static void scd_start(int unit);
static timeout_t scd_timeout;
static void scd_doread(int state, struct scd_mbx *mbxin);
static int scd_eject(int unit);
@ -776,6 +777,12 @@ read_subcode(int unit, struct sony_subchannel_position_data *sc)
static struct scd_mbx *mbxsave;
static void
scd_timeout(void *arg)
{
scd_doread((int)arg, mbxsave);
}
static void
scd_doread(int state, struct scd_mbx *mbxin)
{
@ -802,7 +809,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto trystat;
case SCD_S_WAITSTAT:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSTAT);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITSTAT);
if (mbx->count-- <= 0) {
printf("scd%d: timeout. drive busy.\n",unit);
goto harderr;
@ -810,7 +817,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
trystat:
if (IS_BUSY(port)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITSTAT,hz/100); /* XXX */
return;
}
@ -849,18 +856,18 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto writeparam;
mbx->count = 100;
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */
return;
case SCD_S_WAITSPIN:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITSPIN);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITSPIN);
if (mbx->count-- <= 0) {
printf("scd%d: timeout waiting for drive to spin up.\n", unit);
goto harderr;
}
if (!STATUS_BIT(port, SBIT_RESULT_READY)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */
return;
}
@ -881,13 +888,13 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto loop;
case SCD_S_WAITFIFO:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITFIFO);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITFIFO);
if (mbx->count-- <= 0) {
printf("scd%d: timeout. write param not ready.\n",unit);
goto harderr;
}
if (!FSTATUS_BIT(port, FBIT_WPARAM_READY)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITFIFO,hz/100); /* XXX */
return;
}
@ -900,7 +907,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
XDEBUG(1, ("scd%d: spinning up drive ...\n", unit));
outb(port+OREG_COMMAND, CMD_SPIN_UP);
mbx->count = 300;
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITSPIN,hz/100); /* XXX */
return;
}
@ -924,12 +931,12 @@ scd_doread(int state, struct scd_mbx *mbxin)
DELAY(100);
}
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */
return;
case SCD_S_WAITREAD:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITREAD);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITREAD);
if (mbx->count-- <= 0) {
if (STATUS_BIT(port, SBIT_RESULT_READY))
goto got_param;
@ -940,7 +947,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
process_attention(unit);
if (!(cd->flags & SCDVALID))
goto changed;
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITREAD,hz/100); /* XXX */
return;
}
@ -961,7 +968,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
goto waitfor_param;
case SCD_S_WAITPARAM:
untimeout((timeout_func_t)scd_doread,(caddr_t)SCD_S_WAITPARAM);
untimeout(scd_timeout,(caddr_t)SCD_S_WAITPARAM);
if (mbx->count-- <= 0) {
printf("scd%d: timeout waiting for params\n",unit);
goto readerr;
@ -969,7 +976,7 @@ scd_doread(int state, struct scd_mbx *mbxin)
waitfor_param:
if (!STATUS_BIT(port, SBIT_RESULT_READY)) {
timeout((timeout_func_t)scd_doread,
timeout(scd_timeout,
(caddr_t)SCD_S_WAITPARAM,hz/100); /* XXX */
return;
}