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 | |
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')
49 files changed, 119 insertions, 119 deletions
diff --git a/sys/dev/agp/agp.c b/sys/dev/agp/agp.c index 1dd8b3a..c18fa19 100644 --- a/sys/dev/agp/agp.c +++ b/sys/dev/agp/agp.c @@ -80,7 +80,7 @@ static struct cdevsw agp_cdevsw = { }; static devclass_t agp_devclass; -#define KDEV2DEV(kdev) devclass_get_device(agp_devclass, minor(kdev)) +#define KDEV2DEV(kdev) devclass_get_device(agp_devclass, dev2unit(kdev)) /* Helper functions for implementing chipset mini drivers. */ diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c index d586a36..192f128 100644 --- a/sys/dev/amr/amr.c +++ b/sys/dev/amr/amr.c @@ -438,7 +438,7 @@ amr_submit_bio(struct amr_softc *sc, struct bio *bio) static int amr_open(struct cdev *dev, int flags, int fmt, d_thread_t *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit); debug_called(1); @@ -494,7 +494,7 @@ amr_prepare_ld_delete(struct amr_softc *sc) static int amr_close(struct cdev *dev, int flags, int fmt, d_thread_t *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit); debug_called(1); diff --git a/sys/dev/arcmsr/arcmsr.c b/sys/dev/arcmsr/arcmsr.c index 1c23181..74c807f 100644 --- a/sys/dev/arcmsr/arcmsr.c +++ b/sys/dev/arcmsr/arcmsr.c @@ -256,7 +256,7 @@ MODULE_DEPEND(arcmsr, cam, 1, 1, 1); #if __FreeBSD_version < 503000 struct AdapterControlBlock *acb=dev->si_drv1; #else - int unit = minor(dev); + int unit = dev2unit(dev); struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, unit); #endif if(acb==NULL) { @@ -281,7 +281,7 @@ MODULE_DEPEND(arcmsr, cam, 1, 1, 1); #if __FreeBSD_version < 503000 struct AdapterControlBlock *acb=dev->si_drv1; #else - int unit = minor(dev); + int unit = dev2unit(dev); struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, unit); #endif if(acb==NULL) { @@ -306,7 +306,7 @@ MODULE_DEPEND(arcmsr, cam, 1, 1, 1); #if __FreeBSD_version < 503000 struct AdapterControlBlock *acb=dev->si_drv1; #else - int unit = minor(dev); + int unit = dev2unit(dev); struct AdapterControlBlock *acb = devclass_get_softc(arcmsr_devclass, unit); #endif diff --git a/sys/dev/asr/asr.c b/sys/dev/asr/asr.c index 2e3aae2..8cda0a9 100644 --- a/sys/dev/asr/asr.c +++ b/sys/dev/asr/asr.c @@ -3113,7 +3113,7 @@ typedef U32 DPT_RTN_T; #undef SCSI_RESET /* Conflicts with "scsi/scsiconf.h" defintion */ #include "dev/asr/osd_unix.h" -#define asr_unit(dev) minor(dev) +#define asr_unit(dev) dev2unit(dev) static u_int8_t ASR_ctlr_held; diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 8986069..947bacf 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -238,7 +238,7 @@ ast_close(struct cdev *cdev, int flags, int fmt, struct thread *td) ast_write_filemark(dev, ATAPI_WF_WRITE); /* if minor is even rewind on close */ - if (!(minor(cdev) & 0x01)) + if (!(dev2unit(cdev) & 0x01)) ast_rewind(dev); if (stp->cap.lock && count_dev(cdev) == 1) diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c index bed0c37..c173496 100644 --- a/sys/dev/atkbdc/psm.c +++ b/sys/dev/atkbdc/psm.c @@ -141,8 +141,8 @@ __FBSDID("$FreeBSD$"); (((b[0] & 0x30) >> 2) | ((b[1] & 0x30) >> 4)) /* some macros */ -#define PSM_UNIT(dev) (minor(dev) >> 1) -#define PSM_NBLOCKIO(dev) (minor(dev) & 1) +#define PSM_UNIT(dev) (dev2unit(dev) >> 1) +#define PSM_NBLOCKIO(dev) (dev2unit(dev) & 1) #define PSM_MKMINOR(unit,block) (((unit) << 1) | ((block) ? 0:1)) /* ring buffer */ 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)) /* * diff --git a/sys/dev/ce/if_ce.c b/sys/dev/ce/if_ce.c index a08a7a0..9b0d69c 100644 --- a/sys/dev/ce/if_ce.c +++ b/sys/dev/ce/if_ce.c @@ -1254,7 +1254,7 @@ static int ce_open (dev_t dev, int oflags, int devtype, struct proc *p) static int ce_open (struct cdev *dev, int oflags, int devtype, struct thread *td) #endif { - int unit = minor (dev); + int unit = dev2unit (dev); drv_t *d; if (unit >= NBRD*NCHAN || ! (d = channel[unit])) @@ -1272,7 +1272,7 @@ static int ce_close (dev_t dev, int fflag, int devtype, struct proc *p) static int ce_close (struct cdev *dev, int fflag, int devtype, struct thread *td) #endif { - drv_t *d = channel [minor (dev)]; + drv_t *d = channel [dev2unit (dev)]; CE_DEBUG2 (d, ("ce_close\n")); return 0; @@ -1303,7 +1303,7 @@ static int ce_ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc static int ce_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) #endif { - drv_t *d = channel [minor (dev)]; + drv_t *d = channel [dev2unit (dev)]; bdrv_t *bd = d->board->sys; ce_chan_t *c = d->chan; struct serial_statistics *st; diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c index 36b12ab..0b300ce 100644 --- a/sys/dev/cp/if_cp.c +++ b/sys/dev/cp/if_cp.c @@ -999,7 +999,7 @@ static void cp_error (cp_chan_t *c, int data) */ static int cp_open (struct cdev *dev, int oflags, int devtype, struct thread *td) { - int unit = minor (dev); + int unit = dev2unit (dev); drv_t *d; if (unit >= NBRD*NCHAN || ! (d = channel[unit])) @@ -1013,7 +1013,7 @@ static int cp_open (struct cdev *dev, int oflags, int devtype, struct thread *td */ static int cp_close (struct cdev *dev, int fflag, int devtype, struct thread *td) { - drv_t *d = channel [minor (dev)]; + drv_t *d = channel [dev2unit (dev)]; CP_DEBUG2 (d, ("cp_close\n")); return 0; @@ -1040,7 +1040,7 @@ static int cp_modem_status (cp_chan_t *c) static int cp_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) { - drv_t *d = channel [minor (dev)]; + drv_t *d = channel [dev2unit (dev)]; bdrv_t *bd = d->board->sys; cp_chan_t *c = d->chan; struct serial_statistics *st; diff --git a/sys/dev/cpuctl/cpuctl.c b/sys/dev/cpuctl/cpuctl.c index b560fde..157991c 100644 --- a/sys/dev/cpuctl/cpuctl.c +++ b/sys/dev/cpuctl/cpuctl.c @@ -144,7 +144,7 @@ cpuctl_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int ret; - int cpu = minor(dev); + int cpu = dev2unit(dev); if (cpu >= mp_ncpus || !cpu_enabled(cpu)) { DPRINTF("[cpuctl,%d]: bad cpu number %d\n", __LINE__, cpu); @@ -389,7 +389,7 @@ cpuctl_open(struct cdev *dev, int flags, int fmt __unused, struct thread *td) int ret = 0; int cpu; - cpu = minor(dev); + cpu = dev2unit(dev); if (cpu >= mp_ncpus || !cpu_enabled(cpu)) { DPRINTF("[cpuctl,%d]: incorrect cpu number %d\n", __LINE__, cpu); diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c index f2d876d..b8bccf4 100644 --- a/sys/dev/ctau/if_ct.c +++ b/sys/dev/ctau/if_ct.c @@ -1218,7 +1218,7 @@ static int ct_open (struct cdev *dev, int oflags, int devtype, struct thread *td { drv_t *d; - if (minor(dev) >= NCTAU*NCHAN || ! (d = channel[minor(dev)])) + if (dev2unit(dev) >= NCTAU*NCHAN || ! (d = channel[dev2unit(dev)])) return ENXIO; CT_DEBUG2 (d, ("ct_open\n")); @@ -1227,7 +1227,7 @@ static int ct_open (struct cdev *dev, int oflags, int devtype, struct thread *td static int ct_close (struct cdev *dev, int fflag, int devtype, struct thread *td) { - drv_t *d = channel [minor(dev)]; + drv_t *d = channel [dev2unit(dev)]; if (!d) return 0; @@ -1265,7 +1265,7 @@ static int ct_modem_status (ct_chan_t *c) */ static int ct_ioctl (struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td) { - drv_t *d = channel [minor (dev)]; + drv_t *d = channel [dev2unit (dev)]; bdrv_t *bd; ct_chan_t *c; struct serial_statistics *st; diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 7ed2393..b41b53d 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -713,7 +713,7 @@ int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p) struct drm_device *dev = NULL; int retcode = 0; - dev = DRIVER_SOFTC(minor(kdev)); + dev = DRIVER_SOFTC(dev2unit(kdev)); DRM_DEBUG( "open_count = %d\n", dev->open_count ); diff --git a/sys/dev/drm/drm_fops.c b/sys/dev/drm/drm_fops.c index 23cc1c0..f6eacd2 100644 --- a/sys/dev/drm/drm_fops.c +++ b/sys/dev/drm/drm_fops.c @@ -62,7 +62,7 @@ drm_file_t *drm_find_file_by_proc(struct drm_device *dev, DRM_STRUCTPROC *p) int drm_open_helper(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p, struct drm_device *dev) { - int m = minor(kdev); + int m = dev2unit(kdev); drm_file_t *priv; int retcode; diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c index dbb9f36..21871f6 100644 --- a/sys/dev/fb/fb.c +++ b/sys/dev/fb/fb.c @@ -350,7 +350,7 @@ fbattach(device_t dev) #endif -#define FB_UNIT(dev) minor(dev) +#define FB_UNIT(dev) dev2unit(dev) #define FB_MKMINOR(unit) (u) #if 0 /* experimental */ diff --git a/sys/dev/fb/vgareg.h b/sys/dev/fb/vgareg.h index 4ccef40..0a73fbd 100644 --- a/sys/dev/fb/vgareg.h +++ b/sys/dev/fb/vgareg.h @@ -61,7 +61,7 @@ #define GDCREG (IO_VGA + 0x0F) /* graph data controller data */ #define VGA_DRIVER_NAME "vga" -#define VGA_UNIT(dev) minor(dev) +#define VGA_UNIT(dev) dev2unit(dev) #define VGA_MKMINOR(unit) (unit) #ifdef _KERNEL diff --git a/sys/dev/firewire/firewire.h b/sys/dev/firewire/firewire.h index ee510e6..39d8fd1 100644 --- a/sys/dev/firewire/firewire.h +++ b/sys/dev/firewire/firewire.h @@ -417,7 +417,7 @@ struct fw_crom_buf { #endif #define MAKEMINOR(f, u, s) \ - unit2minor((f) | (((u) & 0xff) << 8) | (s & 0xff)) + ((f) | (((u) & 0xff) << 8) | (s & 0xff)) #define DEV2UNIT(x) ((dev2unit(x) & 0xff00) >> 8) #define DEV2SUB(x) (dev2unit(x) & 0xff) diff --git a/sys/dev/firewire/fwdev.c b/sys/dev/firewire/fwdev.c index 9e6602d..9cbb5e4 100644 --- a/sys/dev/firewire/fwdev.c +++ b/sys/dev/firewire/fwdev.c @@ -213,7 +213,7 @@ fw_open (struct cdev *dev, int flags, int fmt, fw_proc *td) int unit = DEV2UNIT(dev); int sub = DEV2SUB(dev); - make_dev(&firewire_cdevsw, minor(dev), + make_dev(&firewire_cdevsw, dev2unit(dev), UID_ROOT, GID_OPERATOR, 0660, "fw%d.%d", unit, sub); } diff --git a/sys/dev/hptiop/hptiop.c b/sys/dev/hptiop/hptiop.c index 88aa843..7218bc5 100644 --- a/sys/dev/hptiop/hptiop.c +++ b/sys/dev/hptiop/hptiop.c @@ -178,7 +178,7 @@ static struct cdevsw hptiop_cdevsw = { #define hba_from_dev(dev) ((struct hpt_iop_hba *)(dev)->si_drv1) #else #define hba_from_dev(dev) \ - ((struct hpt_iop_hba *)devclass_get_softc(hptiop_devclass, minor(dev))) + ((struct hpt_iop_hba *)devclass_get_softc(hptiop_devclass, dev2unit(dev))) #endif #define BUS_SPACE_WRT4_ITL(offset, value) bus_space_write_4(hba->bar0t,\ diff --git a/sys/dev/iir/iir_ctrl.c b/sys/dev/iir/iir_ctrl.c index 206b6ff..e5fbac94 100644 --- a/sys/dev/iir/iir_ctrl.c +++ b/sys/dev/iir/iir_ctrl.c @@ -152,7 +152,7 @@ iir_open(struct cdev *dev, int flags, int fmt, d_thread_t * p) int minor_no; struct gdt_softc *gdt; - minor_no = minor(dev); + minor_no = dev2unit(dev); gdt = gdt_minor2softc(minor_no); if (gdt == NULL) return (ENXIO); @@ -170,7 +170,7 @@ iir_close(struct cdev *dev, int flags, int fmt, d_thread_t * p) int minor_no; struct gdt_softc *gdt; - minor_no = minor(dev); + minor_no = dev2unit(dev); gdt = gdt_minor2softc(minor_no); if (gdt == NULL) return (ENXIO); @@ -188,7 +188,7 @@ iir_write(struct cdev *dev, struct uio * uio, int ioflag) int minor_no; struct gdt_softc *gdt; - minor_no = minor(dev); + minor_no = dev2unit(dev); gdt = gdt_minor2softc(minor_no); if (gdt == NULL) return (ENXIO); @@ -206,7 +206,7 @@ iir_read(struct cdev *dev, struct uio * uio, int ioflag) int minor_no; struct gdt_softc *gdt; - minor_no = minor(dev); + minor_no = dev2unit(dev); gdt = gdt_minor2softc(minor_no); if (gdt == NULL) return (ENXIO); @@ -230,7 +230,7 @@ iir_ioctl(struct cdev *dev, u_long cmd, caddr_t cmdarg, int flags, d_thread_t * int minor_no; struct gdt_softc *gdt; - minor_no = minor(dev); + minor_no = dev2unit(dev); gdt = gdt_minor2softc(minor_no); if (gdt == NULL) return (ENXIO); diff --git a/sys/dev/iscsi/initiator/isc_cam.c b/sys/dev/iscsi/initiator/isc_cam.c index ed0b74a..d978db3 100644 --- a/sys/dev/iscsi/initiator/isc_cam.c +++ b/sys/dev/iscsi/initiator/isc_cam.c @@ -142,7 +142,7 @@ ic_fullfeature(struct cdev *dev) isc_session_t *sp = (isc_session_t *)dev->si_drv2; debug_called(8); - sdebug(3, "dev=%d sc=%p", minor(dev), isp); + sdebug(3, "dev=%d sc=%p", dev2unit(dev), isp); sp->flags &= ~ISC_FFPHASE; sp->flags |= ISC_FFPWAIT; diff --git a/sys/dev/iscsi/initiator/iscsi.c b/sys/dev/iscsi/initiator/iscsi.c index a572ba9..1b0b00c 100644 --- a/sys/dev/iscsi/initiator/iscsi.c +++ b/sys/dev/iscsi/initiator/iscsi.c @@ -115,13 +115,13 @@ iscsi_open(struct cdev *dev, int flags, int otype, struct thread *td) { debug_called(8); - debug(7, "dev=%d", minor(dev)); + debug(7, "dev=%d", dev2unit(dev)); - if(minor(dev) > MAX_SESSIONS) { + if(dev2unit(dev) > MAX_SESSIONS) { // should not happen return ENODEV; } - if(minor(dev) == MAX_SESSIONS) { + if(dev2unit(dev) == MAX_SESSIONS) { #if 1 struct isc_softc *sc = (struct isc_softc *)dev->si_drv1; @@ -144,12 +144,12 @@ iscsi_close(struct cdev *dev, int flag, int otyp, struct thread *td) debug(3, "flag=%x", flag); sc = (struct isc *)dev->si_drv1; - if(minor(dev) == MAX_SESSIONS) { + if(dev2unit(dev) == MAX_SESSIONS) { return 0; } sp = (isc_session_t *)dev->si_drv2; if(sp != NULL) { - sdebug(2, "session=%d flags=%x", minor(dev), sp->flags ); + sdebug(2, "session=%d flags=%x", dev2unit(dev), sp->flags ); /* | if still in full phase, this probably means | that something went realy bad. @@ -179,7 +179,7 @@ iscsi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int mode, struct thread * debug_called(8); error = 0; - if(minor(dev) == MAX_SESSIONS) { + if(dev2unit(dev) == MAX_SESSIONS) { /* | non Session commands */ @@ -205,7 +205,7 @@ iscsi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int mode, struct thread * if(sp == NULL) return ENXIO; - sdebug(6, "dev=%d cmd=%d", minor(dev), (int)(cmd & 0xff)); + sdebug(6, "dev=%d cmd=%d", dev2unit(dev), (int)(cmd & 0xff)); switch(cmd) { case ISCSISETSOC: @@ -285,7 +285,7 @@ iscsi_read(struct cdev *dev, struct uio *uio, int ioflag) sc = (struct isc_softc *)dev->si_drv1; sp = (isc_session_t *)dev->si_drv2; - if(minor(dev) == MAX_SESSIONS) { + if(dev2unit(dev) == MAX_SESSIONS) { sprintf(buf, "/----- Session ------/\n"); uiomove(buf, strlen(buf), uio); int i = 0; diff --git a/sys/dev/isp/isp_freebsd.c b/sys/dev/isp/isp_freebsd.c index cc7017a..2e7981f 100644 --- a/sys/dev/isp/isp_freebsd.c +++ b/sys/dev/isp/isp_freebsd.c @@ -311,7 +311,7 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td) isp = isplist; while (isp) { - if (minor(dev) == device_get_unit(isp->isp_dev)) { + if (dev2unit(dev) == device_get_unit(isp->isp_dev)) { break; } isp = isp->isp_osinfo.next; diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c index 472985b..762cfd7 100644 --- a/sys/dev/joy/joy.c +++ b/sys/dev/joy/joy.c @@ -54,8 +54,8 @@ __FBSDID("$FreeBSD$"); * wait until the corresponding bit returns to 0. */ -#define joypart(d) (minor(d)&1) -#define UNIT(d) ((minor(d)>>1)&3) +#define joypart(d) (dev2unit(d)&1) +#define UNIT(d) ((dev2unit(d)>>1)&3) #ifndef JOY_TIMEOUT #define JOY_TIMEOUT 2000 /* 2 milliseconds */ #endif diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index 53b118d..753269a 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #include <dev/kbd/kbdreg.h> -#define KBD_INDEX(dev) minor(dev) +#define KBD_INDEX(dev) dev2unit(dev) typedef struct genkbd_softc { int gkb_flags; /* flag/status bits */ @@ -460,7 +460,7 @@ kbd_configure(int flags) * appropriate subdrivers. */ -#define KBD_UNIT(dev) minor(dev) +#define KBD_UNIT(dev) dev2unit(dev) static d_open_t genkbdopen; static d_close_t genkbdclose; diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c index c7c7be7f..368530d 100644 --- a/sys/dev/mlx/mlx.c +++ b/sys/dev/mlx/mlx.c @@ -711,7 +711,7 @@ mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp) int mlx_open(struct cdev *dev, int flags, int fmt, struct thread *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct mlx_softc *sc = devclass_get_softc(mlx_devclass, unit); sc->mlx_state |= MLX_STATE_OPEN; @@ -724,7 +724,7 @@ mlx_open(struct cdev *dev, int flags, int fmt, struct thread *td) int mlx_close(struct cdev *dev, int flags, int fmt, struct thread *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct mlx_softc *sc = devclass_get_softc(mlx_devclass, unit); sc->mlx_state &= ~MLX_STATE_OPEN; @@ -737,7 +737,7 @@ mlx_close(struct cdev *dev, int flags, int fmt, struct thread *td) int mlx_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct mlx_softc *sc = devclass_get_softc(mlx_devclass, unit); struct mlx_rebuild_request *rb = (struct mlx_rebuild_request *)addr; struct mlx_rebuild_status *rs = (struct mlx_rebuild_status *)addr; diff --git a/sys/dev/mly/mly.c b/sys/dev/mly/mly.c index d9e78bd..2fcaadc 100644 --- a/sys/dev/mly/mly.c +++ b/sys/dev/mly/mly.c @@ -2834,7 +2834,7 @@ mly_print_controller(int controller) static int mly_user_open(struct cdev *dev, int flags, int fmt, struct thread *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct mly_softc *sc = devclass_get_softc(devclass_find("mly"), unit); sc->mly_state |= MLY_STATE_OPEN; @@ -2847,7 +2847,7 @@ mly_user_open(struct cdev *dev, int flags, int fmt, struct thread *td) static int mly_user_close(struct cdev *dev, int flags, int fmt, struct thread *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct mly_softc *sc = devclass_get_softc(devclass_find("mly"), unit); sc->mly_state &= ~MLY_STATE_OPEN; diff --git a/sys/dev/mse/mse.c b/sys/dev/mse/mse.c index 405be42..4f3258b 100644 --- a/sys/dev/mse/mse.c +++ b/sys/dev/mse/mse.c @@ -111,8 +111,8 @@ static struct cdevsw mse_cdevsw = { static void mseintr(void *); static timeout_t msetimeout; -#define MSE_UNIT(dev) (minor(dev) >> 1) -#define MSE_NBLOCKIO(dev) (minor(dev) & 0x1) +#define MSE_UNIT(dev) (dev2unit(dev) >> 1) +#define MSE_NBLOCKIO(dev) (dev2unit(dev) & 0x1) #define MSEPRI (PZERO + 3) diff --git a/sys/dev/pbio/pbio.c b/sys/dev/pbio/pbio.c index 3ba3c12..536e6fb 100644 --- a/sys/dev/pbio/pbio.c +++ b/sys/dev/pbio/pbio.c @@ -79,8 +79,8 @@ static char *port_names[] = {"a", "b", "ch", "cl"}; #define PBIO_PNAME(n) (port_names[(n)]) -#define UNIT(dev) (minor(dev) >> 2) -#define PORT(dev) (minor(dev) & 0x3) +#define UNIT(dev) (dev2unit(dev) >> 2) +#define PORT(dev) (dev2unit(dev) & 0x3) #define PBIOPRI ((PZERO + 5) | PCATCH) diff --git a/sys/dev/powermac_nvram/powermac_nvram.c b/sys/dev/powermac_nvram/powermac_nvram.c index bcc1db1..a22c7ab 100644 --- a/sys/dev/powermac_nvram/powermac_nvram.c +++ b/sys/dev/powermac_nvram/powermac_nvram.c @@ -91,7 +91,7 @@ DRIVER_MODULE(powermac_nvram, nexus, powermac_nvram_driver, powermac_nvram_devcl * Cdev methods. */ -#define NVRAM_UNIT(dev) minor(dev) +#define NVRAM_UNIT(dev) dev2unit(dev) #define NVRAM_SOFTC(unit) ((struct powermac_nvram_softc *) \ devclass_get_softc(powermac_nvram_devclass, unit)) diff --git a/sys/dev/ppbus/lpt.c b/sys/dev/ppbus/lpt.c index d507f14..c3253a2 100644 --- a/sys/dev/ppbus/lpt.c +++ b/sys/dev/ppbus/lpt.c @@ -461,7 +461,7 @@ lptopen(struct cdev *dev, int flags, int fmt, struct thread *td) { int s; int trys, err; - u_int unit = LPTUNIT(minor(dev)); + u_int unit = LPTUNIT(dev2unit(dev)); struct lpt_data *sc = UNITOSOFTC(unit); device_t lptdev = UNITODEVICE(unit); device_t ppbus = device_get_parent(lptdev); @@ -475,7 +475,7 @@ lptopen(struct cdev *dev, int flags, int fmt, struct thread *td) } else sc->sc_state |= LPTINIT; - sc->sc_flags = LPTFLAGS(minor(dev)); + sc->sc_flags = LPTFLAGS(dev2unit(dev)); /* Check for open with BYPASS flag set. */ if (sc->sc_flags & LP_BYPASS) { @@ -579,7 +579,7 @@ lptopen(struct cdev *dev, int flags, int fmt, struct thread *td) static int lptclose(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = LPTUNIT(minor(dev)); + u_int unit = LPTUNIT(dev2unit(dev)); struct lpt_data *sc = UNITOSOFTC(unit); device_t lptdev = UNITODEVICE(unit); device_t ppbus = device_get_parent(lptdev); @@ -688,7 +688,7 @@ lpt_pushbytes(device_t dev) static int lptread(struct cdev *dev, struct uio *uio, int ioflag) { - u_int unit = LPTUNIT(minor(dev)); + u_int unit = LPTUNIT(dev2unit(dev)); struct lpt_data *sc = UNITOSOFTC(unit); device_t lptdev = UNITODEVICE(unit); device_t ppbus = device_get_parent(lptdev); @@ -735,7 +735,7 @@ lptwrite(struct cdev *dev, struct uio *uio, int ioflag) { register unsigned n; int err; - u_int unit = LPTUNIT(minor(dev)); + u_int unit = LPTUNIT(dev2unit(dev)); struct lpt_data *sc = UNITOSOFTC(unit); device_t lptdev = UNITODEVICE(unit); device_t ppbus = device_get_parent(lptdev); @@ -902,7 +902,7 @@ static int lptioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { int error = 0; - u_int unit = LPTUNIT(minor(dev)); + u_int unit = LPTUNIT(dev2unit(dev)); struct lpt_data *sc = UNITOSOFTC(unit); u_char old_sc_irq; /* old printer IRQ status */ diff --git a/sys/dev/ppbus/pcfclock.c b/sys/dev/ppbus/pcfclock.c index 0a65055..c7562fc 100644 --- a/sys/dev/ppbus/pcfclock.c +++ b/sys/dev/ppbus/pcfclock.c @@ -153,7 +153,7 @@ pcfclock_attach(device_t dev) static int pcfclock_open(struct cdev *dev, int flag, int fms, struct thread *td) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); struct pcfclock_data *sc = UNITOSOFTC(unit); device_t pcfclockdev = UNITODEVICE(unit); device_t ppbus = device_get_parent(pcfclockdev); @@ -174,7 +174,7 @@ pcfclock_open(struct cdev *dev, int flag, int fms, struct thread *td) static int pcfclock_close(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); struct pcfclock_data *sc = UNITOSOFTC(unit); device_t pcfclockdev = UNITODEVICE(unit); device_t ppbus = device_get_parent(pcfclockdev); @@ -189,7 +189,7 @@ pcfclock_close(struct cdev *dev, int flags, int fmt, struct thread *td) static void pcfclock_write_cmd(struct cdev *dev, unsigned char command) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); unsigned char ctr = 14; @@ -209,7 +209,7 @@ pcfclock_write_cmd(struct cdev *dev, unsigned char command) static void pcfclock_display_data(struct cdev *dev, char buf[18]) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); #ifdef PCFCLOCK_VERBOSE int year; @@ -233,7 +233,7 @@ pcfclock_display_data(struct cdev *dev, char buf[18]) static int pcfclock_read_data(struct cdev *dev, char *buf, ssize_t bits) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); int i; @@ -272,7 +272,7 @@ pcfclock_read_data(struct cdev *dev, char *buf, ssize_t bits) static int pcfclock_read_dev(struct cdev *dev, char *buf, int maxretries) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); int error = 0; @@ -302,7 +302,7 @@ pcfclock_read_dev(struct cdev *dev, char *buf, int maxretries) static int pcfclock_read(struct cdev *dev, struct uio *uio, int ioflag) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); char buf[18]; int error = 0; diff --git a/sys/dev/ppbus/ppi.c b/sys/dev/ppbus/ppi.c index ca8aa04..e3e329f 100644 --- a/sys/dev/ppbus/ppi.c +++ b/sys/dev/ppbus/ppi.c @@ -252,7 +252,7 @@ ppiintr(void *arg) static int ppiopen(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); struct ppi_data *ppi = UNITOSOFTC(unit); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); @@ -286,7 +286,7 @@ ppiopen(struct cdev *dev, int flags, int fmt, struct thread *td) static int ppiclose(struct cdev *dev, int flags, int fmt, struct thread *td) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); struct ppi_data *ppi = UNITOSOFTC(unit); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); @@ -329,7 +329,7 @@ static int ppiread(struct cdev *dev, struct uio *uio, int ioflag) { #ifdef PERIPH_1284 - u_int unit = minor(dev); + u_int unit = dev2unit(dev); struct ppi_data *ppi = UNITOSOFTC(unit); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); @@ -413,7 +413,7 @@ static int ppiwrite(struct cdev *dev, struct uio *uio, int ioflag) { #ifdef PERIPH_1284 - u_int unit = minor(dev); + u_int unit = dev2unit(dev); struct ppi_data *ppi = UNITOSOFTC(unit); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); @@ -499,7 +499,7 @@ error: static int ppiioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { - u_int unit = minor(dev); + u_int unit = dev2unit(dev); device_t ppidev = UNITODEVICE(unit); device_t ppbus = device_get_parent(ppidev); int error = 0; diff --git a/sys/dev/rp/rpvar.h b/sys/dev/rp/rpvar.h index 7aff0d6..f7f28aa 100644 --- a/sys/dev/rp/rpvar.h +++ b/sys/dev/rp/rpvar.h @@ -37,7 +37,7 @@ */ #define RP_UNIT(x) dv_unit(x) -#define RP_PORT(x) (minor(x) & 0x3f) +#define RP_PORT(x) (dev2unit(x) & 0x3f) #define MAX_RP_PORTS 128 diff --git a/sys/dev/sound/midi/sequencer.c b/sys/dev/sound/midi/sequencer.c index aaf53ef..9cdc2d5 100644 --- a/sys/dev/sound/midi/sequencer.c +++ b/sys/dev/sound/midi/sequencer.c @@ -91,8 +91,8 @@ __FBSDID("$FreeBSD$"); #define PCMMKMINOR(u, d, c) \ ((((c) & 0xff) << 16) | (((u) & 0x0f) << 4) | ((d) & 0x0f)) #define MIDIMKMINOR(u, d, c) PCMMKMINOR(u, d, c) -#define MIDIUNIT(y) ((minor(y) >> 4) & 0x0f) -#define MIDIDEV(y) (minor(y) & 0x0f) +#define MIDIUNIT(y) ((dev2unit(y) >> 4) & 0x0f) +#define MIDIDEV(y) (dev2unit(y) & 0x0f) /* These are the entries to the sequencer driver. */ static d_open_t seq_open; diff --git a/sys/dev/speaker/spkr.c b/sys/dev/speaker/spkr.c index 44b825f..8d2ceed 100644 --- a/sys/dev/speaker/spkr.c +++ b/sys/dev/speaker/spkr.c @@ -419,7 +419,7 @@ spkropen(dev, flags, fmt, td) (void) printf("spkropen: entering with dev = %s\n", devtoname(dev)); #endif /* DEBUG */ - if (minor(dev) != 0) + if (dev2unit(dev) != 0) return(ENXIO); else if (spkr_active) return(EBUSY); @@ -444,7 +444,7 @@ spkrwrite(dev, uio, ioflag) printf("spkrwrite: entering with dev = %s, count = %d\n", devtoname(dev), uio->uio_resid); #endif /* DEBUG */ - if (minor(dev) != 0) + if (dev2unit(dev) != 0) return(ENXIO); else if (uio->uio_resid > (DEV_BSIZE - 1)) /* prevent system crashes */ return(E2BIG); @@ -475,7 +475,7 @@ spkrclose(dev, flags, fmt, td) (void) printf("spkrclose: entering with dev = %s\n", devtoname(dev)); #endif /* DEBUG */ - if (minor(dev) != 0) + if (dev2unit(dev) != 0) return(ENXIO); else { wakeup(&endtone); @@ -499,7 +499,7 @@ spkrioctl(dev, cmd, cmdarg, flags, td) devtoname(dev), cmd); #endif /* DEBUG */ - if (minor(dev) != 0) + if (dev2unit(dev) != 0) return(ENXIO); else if (cmd == SPKRTONE) { tone_t *tp = (tone_t *)cmdarg; diff --git a/sys/dev/streams/streams.c b/sys/dev/streams/streams.c index 5b97f85..e7327f8 100644 --- a/sys/dev/streams/streams.c +++ b/sys/dev/streams/streams.c @@ -108,7 +108,7 @@ struct streams_softc { struct isa_device *dev; } ; -#define UNIT(dev) minor(dev) /* assume one minor number per unit */ +#define UNIT(dev) dev2unit(dev) /* assume one minor number per unit */ typedef struct streams_softc *sc_p; @@ -194,7 +194,7 @@ streamsopen(struct cdev *dev, int oflags, int devtype, struct thread *td) if (td->td_dupfd >= 0) return ENODEV; - switch (minor(dev)) { + switch (dev2unit(dev)) { case dev_udp: family = AF_INET; type = SOCK_DGRAM; diff --git a/sys/dev/tdfx/tdfx_pci.c b/sys/dev/tdfx/tdfx_pci.c index ff4efc6..4d12a65 100644 --- a/sys/dev/tdfx/tdfx_pci.c +++ b/sys/dev/tdfx/tdfx_pci.c @@ -394,7 +394,7 @@ tdfx_open(struct cdev *dev, int flags, int fmt, struct thread *td) * We can pretty much allow any opening of the device. */ struct tdfx_softc *tdfx_info = devclass_get_softc(tdfx_devclass, - UNIT(minor(dev))); + UNIT(dev2unit(dev))); if(tdfx_info->busy != 0) return EBUSY; #ifdef DEBUG printf("3dfx: Opened by #%d\n", td->td_proc->p_pid); @@ -412,7 +412,7 @@ tdfx_close(struct cdev *dev, int fflag, int devtype, struct thread *td) * We'll always want to close the device when it's called. */ struct tdfx_softc *tdfx_info = devclass_get_softc(tdfx_devclass, - UNIT(minor(dev))); + UNIT(dev2unit(dev))); if(tdfx_info->busy == 0) return EBADF; tdfx_info->busy = 0; #ifdef DEBUG @@ -435,7 +435,7 @@ tdfx_mmap(struct cdev *dev, vm_offset_t offset, vm_paddr_t *paddr, int nprot) /* Get the configuration for our card XXX*/ /*tdfx_info = (struct tdfx_softc*)devclass_get_softc(tdfx_devclass, - UNIT(minor(dev)));*/ + UNIT(dev2unit(dev)));*/ /************************/ struct tdfx_softc* tdfx_info[2]; diff --git a/sys/dev/twa/tw_osl_freebsd.c b/sys/dev/twa/tw_osl_freebsd.c index 4b098ae..b1fd287 100644 --- a/sys/dev/twa/tw_osl_freebsd.c +++ b/sys/dev/twa/tw_osl_freebsd.c @@ -88,7 +88,7 @@ static devclass_t twa_devclass; static TW_INT32 twa_open(struct cdev *dev, TW_INT32 flags, TW_INT32 fmt, d_thread_t *proc) { - TW_INT32 unit = minor(dev); + TW_INT32 unit = dev2unit(dev); struct twa_softc *sc = devclass_get_softc(twa_devclass, unit); tw_osli_dbg_dprintf(5, sc, "entered"); @@ -114,7 +114,7 @@ twa_open(struct cdev *dev, TW_INT32 flags, TW_INT32 fmt, d_thread_t *proc) static TW_INT32 twa_close(struct cdev *dev, TW_INT32 flags, TW_INT32 fmt, d_thread_t *proc) { - TW_INT32 unit = minor(dev); + TW_INT32 unit = dev2unit(dev); struct twa_softc *sc = devclass_get_softc(twa_devclass, unit); tw_osli_dbg_dprintf(5, sc, "entered"); diff --git a/sys/dev/twe/twe_freebsd.c b/sys/dev/twe/twe_freebsd.c index 7e03883..d5e794a 100644 --- a/sys/dev/twe/twe_freebsd.c +++ b/sys/dev/twe/twe_freebsd.c @@ -81,7 +81,7 @@ static struct cdevsw twe_cdevsw = { static int twe_open(struct cdev *dev, int flags, int fmt, d_thread_t *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct twe_softc *sc = devclass_get_softc(twe_devclass, unit); sc->twe_state |= TWE_STATE_OPEN; @@ -94,7 +94,7 @@ twe_open(struct cdev *dev, int flags, int fmt, d_thread_t *td) static int twe_close(struct cdev *dev, int flags, int fmt, d_thread_t *td) { - int unit = minor(dev); + int unit = dev2unit(dev); struct twe_softc *sc = devclass_get_softc(twe_devclass, unit); sc->twe_state &= ~TWE_STATE_OPEN; diff --git a/sys/dev/usb/ucomvar.h b/sys/dev/usb/ucomvar.h index 32d7c04..0fcd7f3 100644 --- a/sys/dev/usb/ucomvar.h +++ b/sys/dev/usb/ucomvar.h @@ -82,9 +82,9 @@ #define UCOMDIALOUT_MASK 0x80000 #define UCOMCALLUNIT_MASK 0x40000 -#define UCOMUNIT(x) (minor(x) & UCOMUNIT_MASK) -#define UCOMDIALOUT(x) (minor(x) & UCOMDIALOUT_MASK) -#define UCOMCALLUNIT(x) (minor(x) & UCOMCALLUNIT_MASK) +#define UCOMUNIT(x) (dev2unit(x) & UCOMUNIT_MASK) +#define UCOMDIALOUT(x) (dev2unit(x) & UCOMDIALOUT_MASK) +#define UCOMCALLUNIT(x) (dev2unit(x) & UCOMCALLUNIT_MASK) #define UCOM_UNK_PORTNO -1 /* XXX */ diff --git a/sys/dev/usb/ufm.c b/sys/dev/usb/ufm.c index 9eaf49720..2635827 100644 --- a/sys/dev/usb/ufm.c +++ b/sys/dev/usb/ufm.c @@ -96,7 +96,7 @@ struct ufm_softc { int sc_refcnt; }; -#define UFMUNIT(n) (minor(n)) +#define UFMUNIT(n) (dev2unit(n)) static device_probe_t ufm_match; static device_attach_t ufm_attach; diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 4856919..77ea2ef 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -182,8 +182,8 @@ static usb_config_descriptor_t *ugen_get_cdesc(struct ugen_softc *sc, static usbd_status ugen_set_interface(struct ugen_softc *, int, int); static int ugen_get_alt_index(struct ugen_softc *sc, int ifaceidx); -#define UGENUNIT(n) ((minor(n) >> 4) & 0xf) -#define UGENENDPOINT(n) (minor(n) & 0xf) +#define UGENUNIT(n) ((dev2unit(n) >> 4) & 0xf) +#define UGENENDPOINT(n) (dev2unit(n) & 0xf) #define UGENMINOR(u, e) (((u) << 4) | (e)) static device_probe_t ugen_match; diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index 44e8349..d821c01 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -137,7 +137,7 @@ struct uhid_softc { struct cdev *dev; }; -#define UHIDUNIT(dev) (minor(dev)) +#define UHIDUNIT(dev) (dev2unit(dev)) #define UHID_CHUNK 128 /* chunk size for read */ #define UHID_BSIZE 1020 /* buffer size */ diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c index 909aa28..99a1433 100644 --- a/sys/dev/usb/ulpt.c +++ b/sys/dev/usb/ulpt.c @@ -163,8 +163,8 @@ void ulpt_tick(void *xsc); void ieee1284_print_id(char *); #endif -#define ULPTUNIT(s) (minor(s) & 0x1f) -#define ULPTFLAGS(s) (minor(s) & 0xe0) +#define ULPTUNIT(s) (dev2unit(s) & 0x1f) +#define ULPTFLAGS(s) (dev2unit(s) & 0xe0) static device_probe_t ulpt_match; static device_attach_t ulpt_attach; diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index a869f75..6484303 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -81,7 +81,7 @@ SYSCTL_INT(_hw_usb_ums, OID_AUTO, debug, CTLFLAG_RW, #define DPRINTFN(n,x) #endif -#define UMSUNIT(s) (minor(s)&0x1f) +#define UMSUNIT(s) (dev2unit(s)&0x1f) #define MS_TO_TICKS(ms) ((ms) * hz / 1000) diff --git a/sys/dev/usb/urio.c b/sys/dev/usb/urio.c index 01e276a..5f69918 100644 --- a/sys/dev/usb/urio.c +++ b/sys/dev/usb/urio.c @@ -126,7 +126,7 @@ struct urio_softc { u_char sc_dying; }; -#define URIOUNIT(n) (minor(n)) +#define URIOUNIT(n) (dev2unit(n)) #define RIO_RW_TIMEOUT 4000 /* ms */ diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index 0cbf6bd..b1b7d44 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$"); #include <dev/usb/usbdi.h> #include <dev/usb/usbdi_util.h> -#define USBUNIT(d) (minor(d)) /* usb_discover device nodes, kthread */ +#define USBUNIT(d) (dev2unit(d)) /* usb_discover device nodes, kthread */ #define USB_DEV_MINOR 255 /* event queue device */ MALLOC_DEFINE(M_USB, "USB", "USB"); diff --git a/sys/dev/usb/uscanner.c b/sys/dev/usb/uscanner.c index 4c42f46..0f3293a 100644 --- a/sys/dev/usb/uscanner.c +++ b/sys/dev/usb/uscanner.c @@ -293,7 +293,7 @@ static int uscanner_do_read(struct uscanner_softc *, struct uio *, int); static int uscanner_do_write(struct uscanner_softc *, struct uio *, int); static void uscanner_do_close(struct uscanner_softc *); -#define USCANNERUNIT(n) (minor(n)) +#define USCANNERUNIT(n) (dev2unit(n)) static device_probe_t uscanner_match; static device_attach_t uscanner_attach; diff --git a/sys/dev/xen/console/console.c b/sys/dev/xen/console/console.c index ac6dc70..da778d6 100644 --- a/sys/dev/xen/console/console.c +++ b/sys/dev/xen/console/console.c @@ -72,7 +72,7 @@ static unsigned int cnsl_evt_reg; static unsigned int wc, wp; /* write_cons, write_prod */ #define CDEV_MAJOR 12 -#define XCUNIT(x) (minor(x)) +#define XCUNIT(x) (dev2unit(x)) #define ISTTYOPEN(tp) ((tp) && ((tp)->t_state & TS_ISOPEN)) #define CN_LOCK_INIT(x, _name) \ mtx_init(&x, _name, NULL, MTX_SPIN|MTX_RECURSE) |