Don't use getebuf() unless you really need a struct buf. Malloc will

do fine in this case.
This commit is contained in:
Poul-Henning Kamp 2000-05-05 07:50:53 +00:00
parent 90c25bd74a
commit 5856c95848
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=60025

View File

@ -68,10 +68,10 @@
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/conf.h>
#include <sys/buf.h>
#include <sys/kernel.h>
#include <sys/uio.h>
#include <sys/syslog.h>
#include <sys/malloc.h>
#include <machine/clock.h>
#include <machine/bus.h>
@ -86,6 +86,8 @@
#include "ppbus_if.h"
#include <dev/ppbus/ppbio.h>
MALLOC_DEFINE(M_LPT, "lpt", "LPT buffers");
#ifndef LPT_DEBUG
#define lprintf(args)
#else
@ -120,8 +122,8 @@ struct lpt_data {
#define LP_PRIMEOPEN 0x20 /* prime on every open */
#define LP_AUTOLF 0x40 /* tell printer to do an automatic lf */
#define LP_BYPASS 0x80 /* bypass printer ready checks */
struct buf *sc_inbuf;
struct buf *sc_statbuf;
void *sc_inbuf;
void *sc_statbuf;
short sc_xfercnt ;
char sc_primed;
char *sc_cp ;
@ -551,8 +553,8 @@ lptopen(dev_t dev, int flags, int fmt, struct proc *p)
ppb_wctr(ppbus, sc->sc_control);
sc->sc_state = OPEN;
sc->sc_inbuf = geteblk(BUFSIZE);
sc->sc_statbuf = geteblk(BUFSTATSIZE);
sc->sc_inbuf = malloc(BUFSIZE, M_LPT, M_WAITOK);
sc->sc_statbuf = malloc(BUFSTATSIZE, M_LPT, M_WAITOK);
sc->sc_xfercnt = 0;
splx(s);
@ -605,8 +607,8 @@ lptclose(dev_t dev, int flags, int fmt, struct proc *p)
break;
ppb_wctr(ppbus, LPC_NINIT);
brelse(sc->sc_inbuf);
brelse(sc->sc_statbuf);
free(sc->sc_inbuf, M_LPT);
free(sc->sc_statbuf, M_LPT);
end_close:
/* release the bus anyway
@ -707,7 +709,7 @@ lptread(dev_t dev, struct uio *uio, int ioflag)
len = 0;
while (uio->uio_resid) {
if ((error = ppb_1284_read(ppbus, PPB_NIBBLE,
sc->sc_statbuf->b_data, min(BUFSTATSIZE,
sc->sc_statbuf, min(BUFSTATSIZE,
uio->uio_resid), &len))) {
goto error;
}
@ -715,7 +717,7 @@ lptread(dev_t dev, struct uio *uio, int ioflag)
if (!len)
goto error; /* no more data */
if ((error = uiomove(sc->sc_statbuf->b_data, len, uio)))
if ((error = uiomove(sc->sc_statbuf, len, uio)))
goto error;
}
@ -765,7 +767,7 @@ lptwrite(dev_t dev, struct uio *uio, int ioflag)
sc->sc_state &= ~INTERRUPTED;
while ((n = min(BUFSIZE, uio->uio_resid)) != 0) {
sc->sc_cp = sc->sc_inbuf->b_data ;
sc->sc_cp = sc->sc_inbuf;
uiomove(sc->sc_cp, n, uio);
sc->sc_xfercnt = n ;