diff options
author | julian <julian@FreeBSD.org> | 1995-12-08 11:19:42 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1995-12-08 11:19:42 +0000 |
commit | 1900eea896e2aaeae8a9fa8affa5fded2068c9b4 (patch) | |
tree | 5150d199464d64c1021f91b2c2f112d48546a8bf /sys/dev/joy | |
parent | aaf9d7f10ecc63adae1dc4f55cfd31a2926c605a (diff) | |
download | FreeBSD-src-1900eea896e2aaeae8a9fa8affa5fded2068c9b4.zip FreeBSD-src-1900eea896e2aaeae8a9fa8affa5fded2068c9b4.tar.gz |
Pass 3 of the great devsw changes
most devsw referenced functions are now static, as they are
in the same file as their devsw structure. I've also added DEVFS
support for nearly every device in the system, however
many of the devices have 'incorrect' names under DEVFS
because I couldn't quickly work out the correct naming conventions.
(but devfs won't be coming on line for a month or so anyhow so that doesn't
matter)
If you "OWN" a device which would normally have an entry in /dev
then search for the devfs_add_devsw() entries and munge to make them right..
check out similar devices to see what I might have done in them in you
can't see what's going on..
for a laugh compare conf.c conf.h defore and after... :)
I have not doen DEVFS entries for any DISKSLICE devices yet as that will be
a much more complicated job.. (pass 5 :)
pass 4 will be to make the devsw tables of type (cdevsw * )
rather than (cdevsw)
seems to work here..
complaints to the usual places.. :)
Diffstat (limited to 'sys/dev/joy')
-rw-r--r-- | sys/dev/joy/joy.c | 72 |
1 files changed, 38 insertions, 34 deletions
diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c index 25d2311..2955d1c 100644 --- a/sys/dev/joy/joy.c +++ b/sys/dev/joy/joy.c @@ -34,6 +34,11 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/conf.h> +#include <sys/kernel.h> +#ifdef DEVFS +#include <sys/devfsext.h> +#endif /*DEVFS*/ #include <machine/joystick.h> @@ -41,15 +46,6 @@ #include <i386/isa/isa_device.h> #include <i386/isa/timerreg.h> -#ifdef JREMOD -#include <sys/conf.h> -#include <sys/kernel.h> -#ifdef DEVFS -#include <sys/devfsext.h> -#endif /*DEVFS*/ -#define CDEV_MAJOR 51 -#endif /*JREMOD*/ - /* The game port can manage 4 buttons and 4 variable resistors (usually 2 * joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201. * Getting the state of the buttons is done by reading the game port: @@ -77,6 +73,9 @@ static struct { int port; int x_off[2], y_off[2]; int timeout[2]; +#ifdef DEVFS + void *devfs_token; +#endif } joy[NJOY]; @@ -86,6 +85,17 @@ int joyprobe (struct isa_device *), joyattach (struct isa_device *); struct isa_driver joydriver = {joyprobe, joyattach, "joy"}; +#define CDEV_MAJOR 51 +static d_open_t joyopen; +static d_close_t joyclose; +static d_read_t joyread; +static d_ioctl_t joyioctl; + +struct cdevsw joy_cdevsw = + { joyopen, joyclose, joyread, nowrite, /*51*/ + joyioctl, nostop, nullreset, nodevtotty,/*joystick */ + seltrue, nommap, NULL, "joy", NULL, -1 }; + static int get_tick (); @@ -104,14 +114,22 @@ joyprobe (struct isa_device *dev) int joyattach (struct isa_device *dev) { - joy[dev->id_unit].port = dev->id_iobase; - joy[dev->id_unit].timeout[0] = joy[dev->id_unit].timeout[1] = 0; - printf("joy%d: joystick\n", dev->id_unit); - + int unit = dev->id_unit; + char name[32]; + + joy[unit].port = dev->id_iobase; + joy[unit].timeout[0] = joy[unit].timeout[1] = 0; + printf("joy%d: joystick\n", unit); +#ifdef DEVFS + sprintf(name, "joy%d", unit); + joy[dev->id_unit].devfs_token = devfs_add_devsw( "/", "joy", + &joy_cdevsw, 0, + DV_CHR, 0, 0, 0600); +#endif return 1; } -int +static int joyopen (dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT (dev); @@ -123,7 +141,7 @@ joyopen (dev_t dev, int flags, int fmt, struct proc *p) joy[unit].timeout[i] = JOY_TIMEOUT; return 0; } -int +static int joyclose (dev_t dev, int flags, int fmt, struct proc *p) { int unit = UNIT (dev); @@ -133,7 +151,7 @@ joyclose (dev_t dev, int flags, int fmt, struct proc *p) return 0; } -int +static int joyread (dev_t dev, struct uio *uio, int flag) { int unit = UNIT(dev); @@ -169,7 +187,9 @@ joyread (dev_t dev, struct uio *uio, int flag) c.b2 = ~(state >> 1) & 1; return uiomove ((caddr_t)&c, sizeof(struct joystick), uio); } -int joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) + +static int +joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) { int unit = UNIT (dev); int i = joypart (dev); @@ -202,6 +222,7 @@ int joyioctl (dev_t dev, int cmd, caddr_t data, int flag, struct proc *p) } return 0; } + static int get_tick () { @@ -215,12 +236,6 @@ get_tick () } -#ifdef JREMOD -struct cdevsw joy_cdevsw = - { joyopen, joyclose, joyread, nowrite, /*51*/ - joyioctl, nostop, nullreset, nodevtotty,/*joystick */ - seltrue, nommap, NULL}; - static joy_devsw_installed = 0; static void joy_drvinit(void *unused) @@ -231,20 +246,9 @@ static void joy_drvinit(void *unused) dev = makedev(CDEV_MAJOR,0); cdevsw_add(&dev,&joy_cdevsw,NULL); joy_devsw_installed = 1; -#ifdef DEVFS - { - int x; -/* default for a simple device with no probe routine (usually delete this) */ - x=devfs_add_devsw( -/* path name devsw minor type uid gid perm*/ - "/", "joy", major(dev), 0, DV_CHR, 0, 0, 0600); - } -#endif } } SYSINIT(joydev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,joy_drvinit,NULL) -#endif /* JREMOD */ - #endif /* NJOY > 0 */ |