diff options
Diffstat (limited to 'en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml')
-rw-r--r-- | en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml b/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml index b017856fae..95ccb7b43d 100644 --- a/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml +++ b/en_US.ISO8859-1/books/arch-handbook/driverbasics/chapter.sgml @@ -364,7 +364,6 @@ DEV_MODULE(echo,echo_loader,NULL);</programlisting> #include <sys/malloc.h> #define BUFFERSIZE 256 -#define CDEV_MAJOR 33 /* Function prototypes */ @@ -375,12 +374,12 @@ static d_write_t echo_write; /* Character device entry points */ static struct cdevsw echo_cdevsw = { + .d_version = D_VERSION, .d_open = echo_open, .d_close = echo_close, - .d_maj = CDEV_MAJOR, - .d_name = "echo", .d_read = echo_read, - .d_write = echo_write + .d_write = echo_write, + .d_name = "echo", }; typedef struct s_echo { @@ -389,7 +388,7 @@ typedef struct s_echo { } t_echo; /* vars */ -static dev_t echo_dev; +static struct cdev *echo_dev; static int count; static t_echo *echomsg; @@ -415,12 +414,12 @@ echo_loader(struct module *m, int what, void *arg) 0600, "echo"); /* kmalloc memory for use by this driver */ - MALLOC(echomsg, t_echo *, sizeof(t_echo), M_ECHOBUF, M_WAITOK); + echomsg = malloc(sizeof(t_echo), M_ECHOBUF, M_WAITOK); printf("Echo device loaded.\n"); break; case MOD_UNLOAD: destroy_dev(echo_dev); - FREE(echomsg,M_ECHOBUF); + free(echomsg, M_ECHOBUF); printf("Echo device unloaded.\n"); break; default: @@ -431,7 +430,7 @@ echo_loader(struct module *m, int what, void *arg) } static int -echo_open(dev_t dev, int oflags, int devtype, struct thread *p) +echo_open(struct cdev *dev, int oflags, int devtype, struct thread *p) { int err = 0; @@ -440,7 +439,7 @@ echo_open(dev_t dev, int oflags, int devtype, struct thread *p) } static int -echo_close(dev_t dev, int fflag, int devtype, struct thread *p) +echo_close(struct cdev *dev, int fflag, int devtype, struct thread *p) { uprintf("Closing device \"echo.\"\n"); return(0); @@ -453,7 +452,7 @@ echo_close(dev_t dev, int fflag, int devtype, struct thread *p) */ static int -echo_read(dev_t dev, struct uio *uio, int ioflag) +echo_read(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; int amt; @@ -476,7 +475,7 @@ echo_read(dev_t dev, struct uio *uio, int ioflag) */ static int -echo_write(dev_t dev, struct uio *uio, int ioflag) +echo_write(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; |