Remove lots of extra junk:

o other bsd defines, there's no way this would work there
o devinfo junk
This commit is contained in:
Warner Losh 2007-06-09 06:40:17 +00:00
parent 80170fd0c4
commit 07f51bab6d

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2001 M. Warner Losh
* Copyright (c) 2001-2007 M. Warner Losh
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,14 +36,9 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#if defined(__NetBSD__)
#include <sys/device.h>
#include <sys/ioctl.h>
#elif defined(__FreeBSD__)
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/ioccom.h>
#endif
#include <sys/fcntl.h>
#include <sys/filio.h>
#include <sys/conf.h>
@ -73,13 +68,6 @@ SYSCTL_INT(_hw_usb_ufm, OID_AUTO, debug, CTLFLAG_RW,
#define DPRINTFN(n,x)
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__)
int ufmopen(dev_t, int, int, usb_proc_ptr);
int ufmclose(dev_t, int, int, usb_proc_ptr);
int ufmioctl(dev_t, u_long, caddr_t, int, usb_proc_ptr);
cdev_decl(ufm);
#elif defined(__FreeBSD__)
d_open_t ufmopen;
d_close_t ufmclose;
d_ioctl_t ufmioctl;
@ -92,7 +80,6 @@ static struct cdevsw ufm_cdevsw = {
.d_ioctl = ufmioctl,
.d_name = "ufm",
};
#endif /*defined(__FreeBSD__)*/
#define FM_CMD0 0x00
#define FM_CMD_SET_FREQ 0x01
@ -108,9 +95,6 @@ struct ufm_softc {
int sc_freq;
int sc_refcnt;
#if defined(__NetBSD__) || defined(__OpenBSD__)
u_char sc_dying;
#endif
};
#define UFMUNIT(n) (minor(n))
@ -139,46 +123,22 @@ USB_MATCH(ufm)
USB_ATTACH(ufm)
{
USB_ATTACH_START(ufm, sc, uaa);
char devinfo[1024];
usb_endpoint_descriptor_t *edesc;
usbd_device_handle udev;
usbd_interface_handle iface;
u_int8_t epcount;
#if defined(__NetBSD__) || defined(__OpenBSD__)
u_int8_t niface;
#endif
usbd_status r;
char * ermsg = "<none>";
DPRINTFN(10,("ufm_attach: sc=%p\n", sc));
usbd_devinfo(uaa->device, 0, devinfo);
USB_ATTACH_SETUP;
sc->sc_dev = self;
sc->sc_udev = udev = uaa->device;
#if defined(__FreeBSD__)
if ((!uaa->device) || (!uaa->iface)) {
ermsg = "device or iface";
goto nobulk;
}
sc->sc_iface = iface = uaa->iface;
#elif defined(__NetBSD__) || defined(__OpenBSD__)
if (!udev) {
ermsg = "device";
goto nobulk;
}
r = usbd_interface_count(udev, &niface);
if (r) {
ermsg = "iface";
goto nobulk;
}
r = usbd_device2interface_handle(udev, 0, &iface);
if (r) {
ermsg = "iface";
goto nobulk;
}
sc->sc_iface = iface;
#endif
sc->sc_opened = 0;
sc->sc_refcnt = 0;
@ -195,18 +155,11 @@ USB_ATTACH(ufm)
}
sc->sc_epaddr = edesc->bEndpointAddress;
#if defined(__FreeBSD__)
/* XXX no error trapping, no storing of struct cdev **/
(void) make_dev(&ufm_cdevsw, device_get_unit(self),
UID_ROOT, GID_OPERATOR,
0644, "ufm%d", device_get_unit(self));
#elif defined(__NetBSD__) || defined(__OpenBSD__)
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
USBDEV(sc->sc_dev));
#endif
DPRINTFN(10, ("ufm_attach: %p\n", sc->sc_udev));
USB_ATTACH_SUCCESS_RETURN;
nobulk:
@ -392,75 +345,10 @@ ufmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, usb_proc_ptr td)
return error;
}
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
ufm_activate(device_t self, enum devact act)
{
struct ufm_softc *sc = (struct ufm_softc *)self;
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
sc->sc_dying = 1;
break;
}
return (0);
}
USB_DETACH(ufm)
{
USB_DETACH_START(ufm, sc);
struct ufm_endpoint *sce;
int i, dir;
int s;
#if defined(__NetBSD__) || defined(__OpenBSD__)
int maj, mn;
DPRINTF(("ufm_detach: sc=%p flags=%d\n", sc, flags));
#elif defined(__FreeBSD__)
DPRINTF(("ufm_detach: sc=%p\n", sc));
#endif
sc->sc_dying = 1;
s = splusb();
if (--sc->sc_refcnt >= 0) {
/* Wait for processes to go away. */
usb_detach_wait(USBDEV(sc->sc_dev));
}
splx(s);
#if defined(__NetBSD__) || defined(__OpenBSD__)
/* locate the major number */
for (maj = 0; maj < nchrdev; maj++)
if (cdevsw[maj].d_open == ufmopen)
break;
/* Nuke the vnodes for any open instances (calls close). */
mn = self->dv_unit * USB_MAX_ENDPOINTS;
vdevgone(maj, mn, mn + USB_MAX_ENDPOINTS - 1, VCHR);
#elif defined(__FreeBSD__)
/* XXX not implemented yet */
#endif
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
USBDEV(sc->sc_dev));
return (0);
}
#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */
#if defined(__FreeBSD__)
static int
ufm_detach(device_t self)
{
DPRINTF(("%s: disconnected\n", device_get_nameunit(self)));
return 0;
}
DRIVER_MODULE(ufm, uhub, ufm_driver, ufm_devclass, usbd_driver_load, 0);
#endif