summaryrefslogtreecommitdiffstats
path: root/sys/dev/cy
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2001-08-13 10:52:15 +0000
committerbde <bde@FreeBSD.org>2001-08-13 10:52:15 +0000
commit87c263c2a197c7dbdf536a888c08e18f9fb640bb (patch)
treece389c14ae7e5df0071e1c438e0ca68372df301a /sys/dev/cy
parentd94655dace7abaec2d57925e578ebdf89d778ec8 (diff)
downloadFreeBSD-src-87c263c2a197c7dbdf536a888c08e18f9fb640bb.zip
FreeBSD-src-87c263c2a197c7dbdf536a888c08e18f9fb640bb.tar.gz
Fixed minor numbers when there is more than one cy card.
PR: 19256 Submitted by: initial version by yokota MFC after: 1 week
Diffstat (limited to 'sys/dev/cy')
-rw-r--r--sys/dev/cy/cy.c21
-rw-r--r--sys/dev/cy/cy_isa.c21
2 files changed, 30 insertions, 12 deletions
diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c
index 52d9fc4..9d6f2bb 100644
--- a/sys/dev/cy/cy.c
+++ b/sys/dev/cy/cy.c
@@ -183,8 +183,15 @@ extern struct mtx com_mtx;
#define CONTROL_LOCK_STATE 0x40
#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
+/*
+ * Not all of the magic is parametrized in the following macros. 16 and
+ * 0xff are related to the bitfields in a udev_t. CY_MAX_PORTS must be
+ * ((0xff & ~MINOR_MAGIC_MASK) + 1) for things to work.
+ */
#define MINOR_TO_UNIT(mynor) (((mynor) >> 16) * CY_MAX_PORTS \
| (((mynor) & 0xff) & ~MINOR_MAGIC_MASK))
+#define UNIT_TO_MINOR(unit) (((unit) / CY_MAX_PORTS) << 16 \
+ | (((unit) & 0xff) & ~MINOR_MAGIC_MASK))
/*
* com state bits.
@@ -535,6 +542,7 @@ cyattach_common(cy_iobase, cy_align)
int cyu;
u_char firmware_version;
cy_addr iobase;
+ int minorbase;
int ncyu;
int unit;
@@ -625,22 +633,23 @@ cyattach_common(cy_iobase, cy_align)
swi_add(&tty_ithd, "tty:cy", siopoll, NULL, SWI_TTY, 0,
&sio_ih);
}
- make_dev(&sio_cdevsw, unit,
+ minorbase = UNIT_TO_MINOR(unit);
+ make_dev(&sio_cdevsw, minorbase,
UID_ROOT, GID_WHEEL, 0600, "ttyc%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE,
+ make_dev(&sio_cdevsw, minorbase | CONTROL_INIT_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyic%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE,
+ make_dev(&sio_cdevsw, minorbase | CONTROL_LOCK_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttylc%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK,
+ make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK,
UID_UUCP, GID_DIALER, 0660, "cuac%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE,
+ make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK | CONTROL_INIT_STATE,
UID_UUCP, GID_DIALER, 0660, "cuaic%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE,
+ make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK | CONTROL_LOCK_STATE,
UID_UUCP, GID_DIALER, 0660, "cualc%r%r", adapter,
unit % CY_MAX_PORTS);
}
diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c
index 52d9fc4..9d6f2bb 100644
--- a/sys/dev/cy/cy_isa.c
+++ b/sys/dev/cy/cy_isa.c
@@ -183,8 +183,15 @@ extern struct mtx com_mtx;
#define CONTROL_LOCK_STATE 0x40
#define DEV_TO_UNIT(dev) (MINOR_TO_UNIT(minor(dev)))
#define MINOR_MAGIC_MASK (CALLOUT_MASK | CONTROL_MASK)
+/*
+ * Not all of the magic is parametrized in the following macros. 16 and
+ * 0xff are related to the bitfields in a udev_t. CY_MAX_PORTS must be
+ * ((0xff & ~MINOR_MAGIC_MASK) + 1) for things to work.
+ */
#define MINOR_TO_UNIT(mynor) (((mynor) >> 16) * CY_MAX_PORTS \
| (((mynor) & 0xff) & ~MINOR_MAGIC_MASK))
+#define UNIT_TO_MINOR(unit) (((unit) / CY_MAX_PORTS) << 16 \
+ | (((unit) & 0xff) & ~MINOR_MAGIC_MASK))
/*
* com state bits.
@@ -535,6 +542,7 @@ cyattach_common(cy_iobase, cy_align)
int cyu;
u_char firmware_version;
cy_addr iobase;
+ int minorbase;
int ncyu;
int unit;
@@ -625,22 +633,23 @@ cyattach_common(cy_iobase, cy_align)
swi_add(&tty_ithd, "tty:cy", siopoll, NULL, SWI_TTY, 0,
&sio_ih);
}
- make_dev(&sio_cdevsw, unit,
+ minorbase = UNIT_TO_MINOR(unit);
+ make_dev(&sio_cdevsw, minorbase,
UID_ROOT, GID_WHEEL, 0600, "ttyc%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE,
+ make_dev(&sio_cdevsw, minorbase | CONTROL_INIT_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttyic%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE,
+ make_dev(&sio_cdevsw, minorbase | CONTROL_LOCK_STATE,
UID_ROOT, GID_WHEEL, 0600, "ttylc%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK,
+ make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK,
UID_UUCP, GID_DIALER, 0660, "cuac%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE,
+ make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK | CONTROL_INIT_STATE,
UID_UUCP, GID_DIALER, 0660, "cuaic%r%r", adapter,
unit % CY_MAX_PORTS);
- make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE,
+ make_dev(&sio_cdevsw, minorbase | CALLOUT_MASK | CONTROL_LOCK_STATE,
UID_UUCP, GID_DIALER, 0660, "cualc%r%r", adapter,
unit % CY_MAX_PORTS);
}
OpenPOWER on IntegriCloud