summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorticso <ticso@FreeBSD.org>2003-10-01 13:53:51 +0000
committerticso <ticso@FreeBSD.org>2003-10-01 13:53:51 +0000
commit12047aec4c024a24308af5f0a8581a52c7d1a29a (patch)
treee8217ae6cdc8d1c9baaa85d9c4b87a305d96f949
parent7f355f9a0e640d321cff6ed38ddceabbeeb73514 (diff)
downloadFreeBSD-src-12047aec4c024a24308af5f0a8581a52c7d1a29a.zip
FreeBSD-src-12047aec4c024a24308af5f0a8581a52c7d1a29a.tar.gz
Don't call makedev().
Cache result of make_dev() and use it when calling destroy_dev().
-rw-r--r--sys/dev/usb/ugen.c27
-rw-r--r--sys/dev/usb/uscanner.c10
2 files changed, 23 insertions, 14 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index 6232918..8b4fdad 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -99,6 +99,9 @@ SYSCTL_INT(_hw_usb_ugen, OID_AUTO, debug, CTLFLAG_RW,
struct ugen_endpoint {
struct ugen_softc *sc;
+#if defined(__FreeBSD__)
+ dev_t dev;
+#endif
usb_endpoint_descriptor_t *edesc;
usbd_interface_handle iface;
int state;
@@ -123,6 +126,9 @@ struct ugen_endpoint {
struct ugen_softc {
USBBASEDEVICE sc_dev; /* base device */
usbd_device_handle sc_udev;
+#if defined(__FreeBSD__)
+ dev_t dev;
+#endif
char sc_is_open[USB_MAX_ENDPOINTS];
struct ugen_endpoint sc_endpoints[USB_MAX_ENDPOINTS][2];
@@ -235,7 +241,7 @@ USB_ATTACH(ugen)
#if defined(__FreeBSD__)
/* the main device, ctrl endpoint */
- make_dev(&ugen_cdevsw, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0),
+ sc->dev = make_dev(&ugen_cdevsw, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0),
UID_ROOT, GID_OPERATOR, 0644, "%s", USBDEVNAME(sc->sc_dev));
#endif
@@ -247,6 +253,7 @@ Static void
ugen_make_devnodes(struct ugen_softc *sc)
{
int endptno;
+ dev_t dev;
for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++) {
if (sc->sc_endpoints[endptno][IN].sc != NULL ||
@@ -259,11 +266,15 @@ ugen_make_devnodes(struct ugen_softc *sc)
* In the if clause above we check whether one
* of the structs is populated.
*/
- make_dev(&ugen_cdevsw,
+ dev = make_dev(&ugen_cdevsw,
UGENMINOR(USBDEVUNIT(sc->sc_dev), endptno),
UID_ROOT, GID_OPERATOR, 0644,
"%s.%d",
USBDEVNAME(sc->sc_dev), endptno);
+ if (sc->sc_endpoints[endptno][IN].sc != NULL)
+ sc->sc_endpoints[endptno][IN].sc->dev = dev;
+ if (sc->sc_endpoints[endptno][OUT].sc != NULL)
+ sc->sc_endpoints[endptno][OUT].sc->dev = dev;
}
}
}
@@ -286,9 +297,10 @@ ugen_destroy_devnodes(struct ugen_softc *sc)
* In the if clause above we check whether one
* of the structs is populated.
*/
- dev = makedev(UGEN_CDEV_MAJOR,
- UGENMINOR(USBDEVUNIT(sc->sc_dev), endptno));
-
+ if (sc->sc_endpoints[endptno][IN].sc != NULL)
+ dev = sc->sc_endpoints[endptno][IN].sc->dev;
+ else
+ dev = sc->sc_endpoints[endptno][OUT].sc->dev;
destroy_dev(dev);
}
}
@@ -854,8 +866,6 @@ USB_DETACH(ugen)
int s;
#if defined(__NetBSD__) || defined(__OpenBSD__)
int maj, mn;
-#elif defined(__FreeBSD__)
- dev_t dev;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -895,8 +905,7 @@ USB_DETACH(ugen)
vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR);
#elif defined(__FreeBSD__)
/* destroy the device for the control endpoint */
- dev = makedev(UGEN_CDEV_MAJOR, UGENMINOR(USBDEVUNIT(sc->sc_dev), 0));
- destroy_dev(dev);
+ destroy_dev(sc->dev);
ugen_destroy_devnodes(sc);
#endif
diff --git a/sys/dev/usb/uscanner.c b/sys/dev/usb/uscanner.c
index 5d82960..ff0cbbd 100644
--- a/sys/dev/usb/uscanner.c
+++ b/sys/dev/usb/uscanner.c
@@ -223,6 +223,9 @@ struct uscanner_softc {
USBBASEDEVICE sc_dev; /* base device */
usbd_device_handle sc_udev;
usbd_interface_handle sc_iface;
+#if defined(__FreeBSD__)
+ dev_t dev;
+#endif
u_int sc_dev_flags;
@@ -358,7 +361,7 @@ USB_ATTACH(uscanner)
#ifdef __FreeBSD__
/* the main device, ctrl endpoint */
- make_dev(&uscanner_cdevsw, USBDEVUNIT(sc->sc_dev),
+ sc->dev = make_dev(&uscanner_cdevsw, USBDEVUNIT(sc->sc_dev),
UID_ROOT, GID_OPERATOR, 0644, "%s", USBDEVNAME(sc->sc_dev));
#endif
@@ -618,8 +621,6 @@ USB_DETACH(uscanner)
int s;
#if defined(__NetBSD__) || defined(__OpenBSD__)
int maj, mn;
-#elif defined(__FreeBSD__)
- dev_t dev;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
@@ -655,8 +656,7 @@ USB_DETACH(uscanner)
vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR);
#elif defined(__FreeBSD__)
/* destroy the device for the control endpoint */
- dev = makedev(USCANNER_CDEV_MAJOR, USBDEVUNIT(sc->sc_dev));
- destroy_dev(dev);
+ destroy_dev(sc->dev);
#endif
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
OpenPOWER on IntegriCloud