- "whitespace change" that coverts existing driver example code

to be style(9) compliant, matching format of new driver code

Approved: blackend (mentor)
This commit is contained in:
Ken Smith 2003-09-25 12:52:06 +00:00
parent c6674adc3d
commit 0faa41e1ff
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=18239

View file

@ -225,7 +225,7 @@ static struct cdevsw echo_cdevsw = {
-1 -1
}; };
typedef struct s_echo { struct s_echo {
char msg[BUFFERSIZE]; char msg[BUFFERSIZE];
int len; int len;
} t_echo; } t_echo;
@ -240,7 +240,7 @@ MALLOC_DECLARE(M_ECHOBUF);
MALLOC_DEFINE(M_ECHOBUF, "echobuffer", "buffer for echo module"); MALLOC_DEFINE(M_ECHOBUF, "echobuffer", "buffer for echo module");
/* /*
* This function acts is called by the kld[un]load(2) system calls to * This function is called by the kld[un]load(2) system calls to
* determine what actions to take when a module is loaded or unloaded. * determine what actions to take when a module is loaded or unloaded.
*/ */
@ -258,7 +258,6 @@ echo_loader(struct module *m, int what, void *arg)
0600, 0600,
"echo"); "echo");
/* kmalloc memory for use by this driver */ /* kmalloc memory for use by this driver */
/* malloc(256,M_ECHOBUF,M_WAITOK); */
MALLOC(echomsg, t_echo *, sizeof(t_echo), M_ECHOBUF, M_WAITOK); MALLOC(echomsg, t_echo *, sizeof(t_echo), M_ECHOBUF, M_WAITOK);
printf("Echo device loaded.\n"); printf("Echo device loaded.\n");
break; break;
@ -302,14 +301,16 @@ echo_read(dev_t dev, struct uio *uio, int ioflag)
int err = 0; int err = 0;
int amt; int amt;
/* How big is this read operation? Either as big as the user wants, /*
or as big as the remaining data */ * How big is this read operation? Either as big as the user wants,
amt = MIN(uio->uio_resid, (echomsg->len - uio->uio_offset > 0) ? echomsg->len - uio->uio_offset : 0); * or as big as the remaining data
*/
amt = MIN(uio->uio_resid, (echomsg->len - uio->uio_offset > 0) ?
echomsg->len - uio->uio_offset : 0);
if ((err = uiomove(echomsg->msg + uio->uio_offset,amt,uio)) != 0) { if ((err = uiomove(echomsg->msg + uio->uio_offset,amt,uio)) != 0) {
uprintf("uiomove failed!\n"); uprintf("uiomove failed!\n");
} }
return(err);
return err;
} }
/* /*
@ -323,17 +324,16 @@ echo_write(dev_t dev, struct uio *uio, int ioflag)
int err = 0; int err = 0;
/* Copy the string in from user memory to kernel memory */ /* Copy the string in from user memory to kernel memory */
err = copyin(uio->uio_iov->iov_base, echomsg->msg, MIN(uio->uio_iov->iov_len,BUFFERSIZE)); err = copyin(uio->uio_iov->iov_base, echomsg->msg,
MIN(uio->uio_iov->iov_len,BUFFERSIZE));
/* Now we need to null terminate */ /* Now we need to null terminate, then record the length */
*(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE)) = 0; *(echomsg->msg + MIN(uio->uio_iov->iov_len,BUFFERSIZE)) = 0;
/* Record the length */
echomsg->len = MIN(uio->uio_iov->iov_len,BUFFERSIZE); echomsg->len = MIN(uio->uio_iov->iov_len,BUFFERSIZE);
if (err != 0) { if (err != 0) {
uprintf("Write failed: bad address!\n"); uprintf("Write failed: bad address!\n");
} }
count++; count++;
return(err); return(err);
} }