summaryrefslogtreecommitdiffstats
path: root/share/examples/kld/cdev
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1999-06-27 12:44:44 +0000
committerdfr <dfr@FreeBSD.org>1999-06-27 12:44:44 +0000
commit633d8b5f5a152bf3fdda8daf986ec47105ae879b (patch)
treeecbd2f08cc1b76af7b0b0b9ba217f4d4fcab1030 /share/examples/kld/cdev
parent6d9ab211ebee6249e6a59d14305833c9ec03048c (diff)
downloadFreeBSD-src-633d8b5f5a152bf3fdda8daf986ec47105ae879b.zip
FreeBSD-src-633d8b5f5a152bf3fdda8daf986ec47105ae879b.tar.gz
* Tidy up a few things and fix some more warnings.
* Change the devsw declaration to standard form and add missing fields * Change the filename from cdev_mod.ko to cdev.ko
Diffstat (limited to 'share/examples/kld/cdev')
-rw-r--r--share/examples/kld/cdev/module/Makefile4
-rw-r--r--share/examples/kld/cdev/module/cdev.c5
-rw-r--r--share/examples/kld/cdev/module/cdev.h21
-rw-r--r--share/examples/kld/cdev/module/cdevmod.c32
-rw-r--r--share/examples/kld/cdev/test/testcdev.c3
5 files changed, 34 insertions, 31 deletions
diff --git a/share/examples/kld/cdev/module/Makefile b/share/examples/kld/cdev/module/Makefile
index aa07686..9e95e85 100644
--- a/share/examples/kld/cdev/module/Makefile
+++ b/share/examples/kld/cdev/module/Makefile
@@ -34,7 +34,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $Id: Makefile,v 1.5 1998/11/08 22:31:00 rv Exp $
+# $Id: Makefile,v 1.1 1998/12/11 10:44:30 dfr Exp $
#
# Copyright (c) 1993 Terrence R. Lambert.
# All rights reserved.
@@ -69,7 +69,7 @@
BINDIR = /tmp
SRCS = cdev.c cdevmod.c
-KMOD = cdev_mod
+KMOD = cdev
NOMAN = t
KLDMOD = t
diff --git a/share/examples/kld/cdev/module/cdev.c b/share/examples/kld/cdev/module/cdev.c
index 8739a52..4cbbc07 100644
--- a/share/examples/kld/cdev/module/cdev.c
+++ b/share/examples/kld/cdev/module/cdev.c
@@ -68,6 +68,9 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/ioccom.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+
#include "cdev.h"
/*
@@ -109,7 +112,7 @@ mydev_ioctl(dev_t dev, u_long cmd, caddr_t arg, int mode, struct proc *procp)
int error = 0;
printf("mydev_ioctl: dev_t=%d, cmd=%lx, arg=%p, mode=%x procp=%p\n",
- dev, cmd, arg, mode, procp);
+ dev2udev(dev), cmd, arg, mode, procp);
switch(cmd) {
case CDEV_IOCTL1:
diff --git a/share/examples/kld/cdev/module/cdev.h b/share/examples/kld/cdev/module/cdev.h
index 34c8235..88b3cb9 100644
--- a/share/examples/kld/cdev/module/cdev.h
+++ b/share/examples/kld/cdev/module/cdev.h
@@ -70,29 +70,8 @@
#ifndef __CDEV_H_
#define __CDEV_H_
-#include <sys/conf.h>
-
d_open_t mydev_open;
d_close_t mydev_close;
d_ioctl_t mydev_ioctl;
-#define CDEV_MAJOR 32
-
-static struct cdevsw my_devsw = {
- mydev_open,
- mydev_close,
- noread,
- nowrite,
- mydev_ioctl,
- nostop,
- noreset,
- nodevtotty,
- NULL,
- nommap,
- NULL,
- "cdev",
- NULL,
- CDEV_MAJOR
-};
-
#endif
diff --git a/share/examples/kld/cdev/module/cdevmod.c b/share/examples/kld/cdev/module/cdevmod.c
index e2ee2e8..5c9ef47 100644
--- a/share/examples/kld/cdev/module/cdevmod.c
+++ b/share/examples/kld/cdev/module/cdevmod.c
@@ -69,10 +69,33 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/conf.h>
#include "cdev.h"
-static int cdev_load(module_t, modeventtype_t, void *);
+#define CDEV_MAJOR 32
+
+static struct cdevsw my_devsw = {
+ /* open */ mydev_open,
+ /* close */ mydev_close,
+ /* read */ noread,
+ /* write */ nowrite,
+ /* ioctl */ mydev_ioctl,
+ /* stop */ nostop,
+ /* reset */ noreset,
+ /* devtotty */ nodevtotty,
+ /* poll */ nopoll,
+ /* mmap */ nommap,
+ /* strategy */ nostrategy,
+ /* name */ "cdev",
+ /* parms */ noparms,
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ D_TTY,
+ /* maxio */ 0,
+ /* bmaj */ -1
+};
/*
* This function is called each time the module is loaded or unloaded.
@@ -86,10 +109,7 @@ static int cdev_load(module_t, modeventtype_t, void *);
*/
static int
-cdev_load(mod, cmd, arg)
- module_t mod;
- modeventtype_t cmd;
- void * arg;
+cdev_load(module_t mod, int cmd, void *arg)
{
int err = 0;
@@ -119,4 +139,4 @@ cdev_load(mod, cmd, arg)
/* Now declare the module to the system */
-DEV_MODULE(cdev_mod, CDEV_MAJOR, -1, my_devsw, cdev_load, 0);
+DEV_MODULE(cdev, CDEV_MAJOR, -1, my_devsw, cdev_load, 0);
diff --git a/share/examples/kld/cdev/test/testcdev.c b/share/examples/kld/cdev/test/testcdev.c
index c1aeeba..e43df97 100644
--- a/share/examples/kld/cdev/test/testcdev.c
+++ b/share/examples/kld/cdev/test/testcdev.c
@@ -74,8 +74,9 @@
#define CDEV_IOCTL1 _IOR('C', 1, u_int)
#define CDEV_DEVICE "cdev"
+
int
-main()
+main(int argc, char *argv[])
{
int kernel_fd;
int one;
OpenPOWER on IntegriCloud