diff options
author | ed <ed@FreeBSD.org> | 2008-09-27 08:51:18 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-09-27 08:51:18 +0000 |
commit | 4efdef565f9a0ca3468534f97c6ac4aaaf747c9a (patch) | |
tree | dd0035910760a440d495b23940f57a42ed24ca85 /sys/dev/bktr | |
parent | d720932e5974ce75bf983cc61010a6eb70f94b86 (diff) | |
download | FreeBSD-src-4efdef565f9a0ca3468534f97c6ac4aaaf747c9a.zip FreeBSD-src-4efdef565f9a0ca3468534f97c6ac4aaaf747c9a.tar.gz |
Replace all calls to minor() with dev2unit().
After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.
This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.
Reviewed by: kib
Diffstat (limited to 'sys/dev/bktr')
-rw-r--r-- | sys/dev/bktr/bktr_os.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sys/dev/bktr/bktr_os.c b/sys/dev/bktr/bktr_os.c index 9ce258c..1e0010f 100644 --- a/sys/dev/bktr/bktr_os.c +++ b/sys/dev/bktr/bktr_os.c @@ -584,7 +584,7 @@ bktr_open( struct cdev *dev, int flags, int fmt, struct thread *td ) int unit; int result; - unit = UNIT( minor(dev) ); + unit = UNIT( dev2unit(dev) ); /* Get the device data */ bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit); @@ -652,7 +652,7 @@ bktr_open( struct cdev *dev, int flags, int fmt, struct thread *td ) } #endif - switch ( FUNCTION( minor(dev) ) ) { + switch ( FUNCTION( dev2unit(dev) ) ) { case VIDEO_DEV: result = video_open( bktr ); break; @@ -684,7 +684,7 @@ bktr_close( struct cdev *dev, int flags, int fmt, struct thread *td ) int unit; int result; - unit = UNIT( minor(dev) ); + unit = UNIT( dev2unit(dev) ); /* Get the device data */ bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit); @@ -693,7 +693,7 @@ bktr_close( struct cdev *dev, int flags, int fmt, struct thread *td ) return (ENXIO); } - switch ( FUNCTION( minor(dev) ) ) { + switch ( FUNCTION( dev2unit(dev) ) ) { case VIDEO_DEV: result = video_close( bktr ); break; @@ -722,7 +722,7 @@ bktr_read( struct cdev *dev, struct uio *uio, int ioflag ) bktr_ptr_t bktr; int unit; - unit = UNIT(minor(dev)); + unit = UNIT(dev2unit(dev)); /* Get the device data */ bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit); @@ -731,7 +731,7 @@ bktr_read( struct cdev *dev, struct uio *uio, int ioflag ) return (ENXIO); } - switch ( FUNCTION( minor(dev) ) ) { + switch ( FUNCTION( dev2unit(dev) ) ) { case VIDEO_DEV: return( video_read( bktr, unit, dev, uio ) ); case VBI_DEV: @@ -760,7 +760,7 @@ bktr_ioctl( struct cdev *dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct thr bktr_ptr_t bktr; int unit; - unit = UNIT(minor(dev)); + unit = UNIT(dev2unit(dev)); /* Get the device data */ bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit); @@ -779,7 +779,7 @@ bktr_ioctl( struct cdev *dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct thr return( ENOMEM ); #endif - switch ( FUNCTION( minor(dev) ) ) { + switch ( FUNCTION( dev2unit(dev) ) ) { case VIDEO_DEV: return( video_ioctl( bktr, unit, cmd, arg, td ) ); case TUNER_DEV: @@ -799,9 +799,9 @@ bktr_mmap( struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot ) int unit; bktr_ptr_t bktr; - unit = UNIT(minor(dev)); + unit = UNIT(dev2unit(dev)); - if (FUNCTION(minor(dev)) > 0) /* only allow mmap on /dev/bktr[n] */ + if (FUNCTION(dev2unit(dev)) > 0) /* only allow mmap on /dev/bktr[n] */ return( -1 ); /* Get the device data */ @@ -832,7 +832,7 @@ bktr_poll( struct cdev *dev, int events, struct thread *td) int revents = 0; DECLARE_INTR_MASK(s); - unit = UNIT(minor(dev)); + unit = UNIT(dev2unit(dev)); /* Get the device data */ bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit); @@ -846,7 +846,7 @@ bktr_poll( struct cdev *dev, int events, struct thread *td) if (events & (POLLIN | POLLRDNORM)) { - switch ( FUNCTION( minor(dev) ) ) { + switch ( FUNCTION( dev2unit(dev) ) ) { case VBI_DEV: if(bktr->vbisize == 0) selrecord(td, &bktr->vbi_select); @@ -1182,8 +1182,8 @@ free_bktr_mem(bktr, dmap, kva) #define TUNER_DEV 0x01 #define VBI_DEV 0x02 -#define UNIT(x) (minor((x) & 0x0f)) -#define FUNCTION(x) (minor((x >> 4) & 0x0f)) +#define UNIT(x) (dev2unit((x) & 0x0f)) +#define FUNCTION(x) (dev2unit((x >> 4) & 0x0f)) /* * |