diff options
author | Eitan Adler <eadler@FreeBSD.org> | 2018-01-26 04:24:39 +0000 |
---|---|---|
committer | Eitan Adler <eadler@FreeBSD.org> | 2018-01-26 04:24:39 +0000 |
commit | 6058f7207a82c51149bf8728ca37d2fe2ce7a97a (patch) | |
tree | 87e1434ecf054156d08a27dd1a4905c7b3d80c71 /share | |
parent | 44e0a832f29732b1bfbc2b657ada4ae7c9fe5e43 (diff) | |
download | src-6058f7207a82c51149bf8728ca37d2fe2ce7a97a.tar.gz src-6058f7207a82c51149bf8728ca37d2fe2ce7a97a.zip |
example cdev: use make_dev_s
Make use of make_dev_s in the example cdev. While here, fix warnings.
Reviewed by: rpokala
Notes
Notes:
svn path=/head/; revision=328428
Diffstat (limited to 'share')
-rw-r--r-- | share/examples/kld/cdev/module/cdev.c | 10 | ||||
-rw-r--r-- | share/examples/kld/cdev/module/cdevmod.c | 11 |
2 files changed, 14 insertions, 7 deletions
diff --git a/share/examples/kld/cdev/module/cdev.c b/share/examples/kld/cdev/module/cdev.c index 3ab9ae4d4223..f86b9a41563b 100644 --- a/share/examples/kld/cdev/module/cdev.c +++ b/share/examples/kld/cdev/module/cdev.c @@ -104,7 +104,7 @@ mydev_open(struct cdev *dev, int flag, int otyp, struct thread *td) { struct proc *procp = td->td_proc; - printf("mydev_open: dev_t=%d, flag=%x, otyp=%x, procp=%p\n", + printf("mydev_open: dev_t=%lu, flag=%x, otyp=%x, procp=%p\n", dev2udev(dev), flag, otyp, procp); memset(&buf, '\0', 513); len = 0; @@ -116,7 +116,7 @@ mydev_close(struct cdev *dev, int flag, int otyp, struct thread *td) { struct proc *procp = td->td_proc; - printf("mydev_close: dev_t=%d, flag=%x, otyp=%x, procp=%p\n", + printf("mydev_close: dev_t=%lu, flag=%x, otyp=%x, procp=%p\n", dev2udev(dev), flag, otyp, procp); return (0); } @@ -128,7 +128,7 @@ mydev_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int mode, int error = 0; struct proc *procp = td->td_proc; - printf("mydev_ioctl: dev_t=%d, cmd=%lx, arg=%p, mode=%x procp=%p\n", + printf("mydev_ioctl: dev_t=%lu, cmd=%lx, arg=%p, mode=%x procp=%p\n", dev2udev(dev), cmd, arg, mode, procp); switch(cmd) { @@ -152,7 +152,7 @@ mydev_write(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; - printf("mydev_write: dev_t=%d, uio=%p, ioflag=%d\n", + printf("mydev_write: dev_t=%lu, uio=%p, ioflag=%d\n", dev2udev(dev), uio, ioflag); err = copyinstr(uio->uio_iov->iov_base, &buf, 512, &len); @@ -172,7 +172,7 @@ mydev_read(struct cdev *dev, struct uio *uio, int ioflag) { int err = 0; - printf("mydev_read: dev_t=%d, uio=%p, ioflag=%d\n", + printf("mydev_read: dev_t=%lu, uio=%p, ioflag=%d\n", dev2udev(dev), uio, ioflag); if (len <= 0) { diff --git a/share/examples/kld/cdev/module/cdevmod.c b/share/examples/kld/cdev/module/cdevmod.c index 3a9db3fbc92a..7030cb15a95f 100644 --- a/share/examples/kld/cdev/module/cdevmod.c +++ b/share/examples/kld/cdev/module/cdevmod.c @@ -109,6 +109,7 @@ static int cdev_load(module_t mod, int cmd, void *arg) { int err = 0; + struct make_dev_args mda; switch (cmd) { case MOD_LOAD: @@ -120,8 +121,14 @@ cdev_load(module_t mod, int cmd, void *arg) printf("Copyright (c) 1998\n"); printf("Rajesh Vaidheeswarran\n"); printf("All rights reserved\n"); - sdev = make_dev(&my_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "cdev"); - break; /* Success*/ + + make_dev_args_init(&mda); + mda.mda_devsw = &my_devsw; + mda.mda_uid = UID_ROOT; + mda.mda_gid = GID_WHEEL; + mda.mda_mode = 0600; + err = make_dev_s(&mda, &sdev, "cdev"); + break; case MOD_UNLOAD: printf("Unloaded kld character device driver\n"); |