Index: ehci_pci.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ehci_pci.c,v retrieving revision 1.26 diff -u -r1.26 ehci_pci.c --- ehci_pci.c 20 Jun 2007 05:10:52 -0000 1.26 +++ ehci_pci.c 20 Jun 2007 07:20:47 -0000 @@ -153,11 +153,11 @@ #define DPRINTF(x) #endif -static int ehci_pci_attach(device_t self); -static int ehci_pci_detach(device_t self); -static int ehci_pci_shutdown(device_t self); -static int ehci_pci_suspend(device_t self); -static int ehci_pci_resume(device_t self); +static device_attach_t ehci_pci_attach; +static device_detach_t ehci_pci_detach; +static device_shutdown_t ehci_pci_shutdown; +static device_suspend_t ehci_pci_suspend; +static device_resume_t ehci_pci_resume; static void ehci_pci_givecontroller(device_t self); static void ehci_pci_takecontroller(device_t self); Index: if_rum.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/if_rum.c,v retrieving revision 1.10 diff -u -r1.10 if_rum.c --- if_rum.c 20 Jun 2007 05:10:52 -0000 1.10 +++ if_rum.c 21 Jun 2007 04:23:44 -0000 @@ -123,6 +123,7 @@ MODULE_DEPEND(rum, wlan, 1, 1, 1); MODULE_DEPEND(rum, wlan_amrr, 1, 1, 1); +MODULE_DEPEND(ural, usb, 1, 1, 1); static int rum_alloc_tx_list(struct rum_softc *); static void rum_free_tx_list(struct rum_softc *); Index: if_ural.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/if_ural.c,v retrieving revision 1.62 diff -u -r1.62 if_ural.c --- if_ural.c 20 Jun 2007 05:10:52 -0000 1.62 +++ if_ural.c 21 Jun 2007 04:23:30 -0000 @@ -112,6 +112,7 @@ MODULE_DEPEND(ural, wlan, 1, 1, 1); MODULE_DEPEND(ural, wlan_amrr, 1, 1, 1); +MODULE_DEPEND(ural, usb, 1, 1, 1); static int ural_alloc_tx_list(struct ural_softc *); static void ural_free_tx_list(struct ural_softc *); Index: ohci_pci.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ohci_pci.c,v retrieving revision 1.49 diff -u -r1.49 ohci_pci.c --- ohci_pci.c 23 Feb 2007 12:18:58 -0000 1.49 +++ ohci_pci.c 19 Jun 2007 17:34:38 -0000 @@ -128,10 +128,10 @@ #define PCI_OHCI_BASE_REG 0x10 -static int ohci_pci_attach(device_t self); -static int ohci_pci_detach(device_t self); -static int ohci_pci_suspend(device_t self); -static int ohci_pci_resume(device_t self); +static device_attach_t ohci_pci_attach; +static device_detach_t ohci_pci_detach; +static device_suspend_t ohci_pci_suspend; +static device_resume_t ohci_pci_resume; static int ohci_pci_suspend(device_t self) Index: ubser.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ubser.c,v retrieving revision 1.28 diff -u -r1.28 ubser.c --- ubser.c 20 Jun 2007 05:10:52 -0000 1.28 +++ ubser.c 21 Jun 2007 04:22:52 -0000 @@ -885,5 +885,5 @@ return (SER_DTR | SER_RTS | SER_DCD); } +MODULE_DEPEND(ubser, usb, 1, 1, 1); DRIVER_MODULE(ubser, uhub, ubser_driver, ubser_devclass, usbd_driver_load, 0); - Index: ucycom.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ucycom.c,v retrieving revision 1.5 diff -u -r1.5 ucycom.c --- ucycom.c 9 Jun 2007 06:39:43 -0000 1.5 +++ ucycom.c 19 Jun 2007 17:37:34 -0000 @@ -52,7 +52,6 @@ #include "usbdevs.h" #include -#include #include #include #include @@ -103,9 +102,9 @@ char sc_dying; }; -static int ucycom_probe(device_t); -static int ucycom_attach(device_t); -static int ucycom_detach(device_t); +static device_probe_t ucycom_probe; +static device_attach_t ucycom_attach; +static device_detach_t ucycom_detach; static t_open_t ucycom_open; static t_close_t ucycom_close; static void ucycom_start(struct tty *); Index: udbp.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/udbp.c,v retrieving revision 1.38 diff -u -r1.38 udbp.c --- udbp.c 20 Jun 2007 05:10:52 -0000 1.38 +++ udbp.c 21 Jun 2007 04:22:28 -0000 @@ -623,6 +623,7 @@ DRIVER_MODULE(udbp, uhub, udbp_driver, udbp_devclass, usbd_driver_load, 0); MODULE_DEPEND(udbp, netgraph, NG_ABI_VERSION, NG_ABI_VERSION, NG_ABI_VERSION); +MODULE_DEPEND(udbp, usb, 1, 1, 1); /*********************************************************************** Index: ufm.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ufm.c,v retrieving revision 1.35 diff -u -r1.35 ufm.c --- ufm.c 20 Jun 2007 05:10:53 -0000 1.35 +++ ufm.c 21 Jun 2007 04:22:15 -0000 @@ -372,4 +372,5 @@ return 0; } +MODULE_DEPEND(ufm, usb, 1, 1, 1); DRIVER_MODULE(ufm, uhub, ufm_driver, ufm_devclass, usbd_driver_load, 0); Index: ufoma.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ufoma.c,v retrieving revision 1.8 diff -u -r1.8 ufoma.c --- ufoma.c 18 Jun 2007 22:27:56 -0000 1.8 +++ ufoma.c 19 Jun 2007 17:38:05 -0000 @@ -184,9 +184,9 @@ }; static usbd_status ufoma_set_line_coding(struct ufoma_softc *sc, usb_cdc_line_state_t *state); -static int ufoma_match(device_t); -static int ufoma_attach(device_t); -static int ufoma_detach(device_t); +static device_probe_t ufoma_match; +static device_attach_t ufoma_attach; +static device_detach_t ufoma_detach; static void *ufoma_get_intconf(usb_config_descriptor_t *cd, usb_interface_descriptor_t *id,int type, int subtype); static void ufoma_notify(void * ,int count); static void ufoma_intr(usbd_xfer_handle, usbd_private_handle, usbd_status); Index: uhci_pci.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/uhci_pci.c,v retrieving revision 1.60 diff -u -r1.60 uhci_pci.c --- uhci_pci.c 23 Feb 2007 12:18:58 -0000 1.60 +++ uhci_pci.c 19 Jun 2007 17:33:33 -0000 @@ -58,13 +58,11 @@ #include #include #include -#if defined(__FreeBSD__) #include #include #include #include -#endif #include #include @@ -155,11 +153,10 @@ #define PCI_UHCI_BASE_REG 0x20 -static int uhci_pci_attach(device_t self); -static int uhci_pci_detach(device_t self); -static int uhci_pci_suspend(device_t self); -static int uhci_pci_resume(device_t self); - +static device_attach_t uhci_pci_attach; +static device_detach_t uhci_pci_detach; +static device_suspend_t uhci_pci_suspend; +static device_resume_t uhci_pci_resume; static int uhci_pci_suspend(device_t self) Index: uhid.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/uhid.c,v retrieving revision 1.95 diff -u -r1.95 uhid.c --- uhid.c 20 Jun 2007 05:10:53 -0000 1.95 +++ uhid.c 21 Jun 2007 04:21:32 -0000 @@ -169,7 +169,6 @@ struct thread *); MODULE_DEPEND(uhid, usb, 1, 1, 1); -MODULE_DEPEND(uhid, ether, 1, 1, 1); static device_probe_t uhid_match; static device_attach_t uhid_attach; Index: uhub.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/uhub.c,v retrieving revision 1.79 diff -u -r1.79 uhub.c --- uhub.c 18 Jun 2007 22:32:08 -0000 1.79 +++ uhub.c 21 Jun 2007 04:21:21 -0000 @@ -56,7 +56,6 @@ #include -#include #include #include #include @@ -94,40 +93,58 @@ static usbd_status uhub_explore(usbd_device_handle hub); static void uhub_intr(usbd_xfer_handle, usbd_private_handle,usbd_status); -static bus_child_location_str_t uhub_child_location_str; -static bus_child_pnpinfo_str_t uhub_child_pnpinfo_str; - /* * We need two attachment points: * hub to usb and hub to hub * Every other driver only connects to hubs */ -/* XXX driver_added needs special care */ -USB_DECLARE_DRIVER_INIT(uhub, +static device_probe_t uhub_match; +static device_attach_t uhub_attach; +static device_detach_t uhub_detach; +static bus_child_location_str_t uhub_child_location_str; +static bus_child_pnpinfo_str_t uhub_child_pnpinfo_str; + +static device_method_t uhub_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, uhub_match), + DEVMETHOD(device_attach, uhub_attach), + DEVMETHOD(device_detach, uhub_detach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(bus_child_pnpinfo_str, uhub_child_pnpinfo_str), DEVMETHOD(bus_child_location_str, uhub_child_location_str), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - DEVMETHOD(device_shutdown, bus_generic_shutdown) - ); + /* XXX driver_added needs special care */ + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + { 0, 0 } +}; + +static driver_t uhub_driver = { + "uhub", + uhub_methods, + sizeof(struct uhub_softc) +}; + +static devclass_t uhub_devclass; /* Create the driver instance for the hub connected to usb case. */ devclass_t uhubroot_devclass; -/* XXX driver_added needs special care */ static device_method_t uhubroot_methods[] = { + DEVMETHOD(device_probe, uhub_match), + DEVMETHOD(device_attach, uhub_attach), + DEVMETHOD(device_detach, uhub_detach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_shutdown, bus_generic_shutdown), + DEVMETHOD(bus_child_location_str, uhub_child_location_str), DEVMETHOD(bus_child_pnpinfo_str, uhub_child_pnpinfo_str), - DEVMETHOD(bus_driver_added, bus_generic_driver_added), + /* XXX driver_added needs special care */ + DEVMETHOD(bus_driver_added, bus_generic_driver_added), - DEVMETHOD(device_probe, uhub_match), - DEVMETHOD(device_attach, uhub_attach), - DEVMETHOD(device_detach, uhub_detach), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - DEVMETHOD(device_shutdown, bus_generic_shutdown), {0,0} }; @@ -539,7 +556,7 @@ static int uhub_detach(device_t self) { - USB_DETACH_START(uhub, sc); + struct uhub_softc *sc = device_get_softc(self); struct usbd_hub *hub = sc->sc_hub->hub; struct usbd_port *rup; int port, nports; @@ -680,5 +697,6 @@ usb_needs_explore(sc->sc_hub); } +MODULE_DEPEND(uhub, usb, 1, 1, 1); DRIVER_MODULE(uhub, usb, uhubroot_driver, uhubroot_devclass, 0, 0); DRIVER_MODULE(uhub, uhub, uhub_driver, uhub_devclass, usbd_driver_load, 0); Index: uipaq.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/uipaq.c,v retrieving revision 1.6 diff -u -r1.6 uipaq.c --- uipaq.c 17 Jun 2007 16:24:48 -0000 1.6 +++ uipaq.c 21 Jun 2007 04:21:10 -0000 @@ -356,4 +356,4 @@ DRIVER_MODULE(uipaq, uhub, uipaq_driver, ucom_devclass, usbd_driver_load, 0); MODULE_DEPEND(uipaq, usb, 1, 1, 1); -MODULE_DEPEND(uipaq, ucom,UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); +MODULE_DEPEND(uipaq, ucom, UCOM_MINVER, UCOM_PREFVER, UCOM_MAXVER); Index: ukbd.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ukbd.c,v retrieving revision 1.69 diff -u -r1.69 ukbd.c --- ukbd.c 20 Jun 2007 05:10:53 -0000 1.69 +++ ukbd.c 21 Jun 2007 04:36:56 -0000 @@ -144,6 +144,7 @@ static devclass_t ukbd_devclass; +MODULE_DEPEND(ukbd, usb, 1, 1, 1); DRIVER_MODULE(ukbd, uhub, ukbd_driver, ukbd_devclass, usbd_driver_load, 0); static int @@ -1413,7 +1414,6 @@ init_keyboard(ukbd_state_t *state, int *type, int flags) { usb_endpoint_descriptor_t *ed; - usbd_status err; *type = KB_OTHER; @@ -1439,14 +1439,6 @@ return EINVAL; } - if ((usbd_get_quirks(state->ks_uaa->device)->uq_flags & UQ_NO_SET_PROTO) == 0) { - err = usbd_set_protocol(state->ks_iface, 0); - DPRINTFN(5, ("ukbd:init_keyboard: protocol set\n")); - if (err) { - printf("ukbd: set protocol failed\n"); - return EIO; - } - } /* Ignore if SETIDLE fails since it is not crucial. */ usbd_set_idle(state->ks_iface, 0, 0); Index: ulpt.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ulpt.c,v retrieving revision 1.79 diff -u -r1.79 ulpt.c --- ulpt.c 20 Jun 2007 05:10:53 -0000 1.79 +++ ulpt.c 21 Jun 2007 04:20:22 -0000 @@ -187,6 +187,7 @@ static devclass_t ulpt_devclass; +MODULE_DEPEND(umass, usb, 1, 1, 1); DRIVER_MODULE(ulpt, uhub, ulpt_driver, ulpt_devclass, usbd_driver_load, 0); static int Index: umass.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/umass.c,v retrieving revision 1.151 diff -u -r1.151 umass.c --- umass.c 20 Jun 2007 05:10:53 -0000 1.151 +++ umass.c 21 Jun 2007 04:20:10 -0000 @@ -115,7 +115,6 @@ #include #include -#include #include #include #include @@ -645,7 +644,7 @@ unsigned char cam_scsi_command2[CAM_MAX_CDBLEN]; struct scsi_sense cam_scsi_sense; struct scsi_sense cam_scsi_test_unit_ready; - usb_callout_t cam_scsi_rescan_ch; + struct callout cam_scsi_rescan_ch; int timeout; /* in msecs */ @@ -685,7 +684,27 @@ }; /* USB device probe/attach/detach functions */ -USB_DECLARE_DRIVER(umass); +static device_probe_t umass_match; +static device_attach_t umass_attach; +static device_detach_t umass_detach; + +static device_method_t umass_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, umass_match), + DEVMETHOD(device_attach, umass_attach), + DEVMETHOD(device_detach, umass_detach), + + { 0, 0 } +}; + +static driver_t umass_driver = { + "ums", + umass_methods, + sizeof(struct umass_softc) +}; + +static devclass_t umass_devclass; + static int umass_match_proto (struct umass_softc *sc, usbd_interface_handle iface, usbd_device_handle udev); @@ -784,7 +803,8 @@ int buflen, int printlen); #endif -MODULE_DEPEND(umass, cam, 1,1,1); +MODULE_DEPEND(umass, cam, 1, 1, 1); +MODULE_DEPEND(umass, usb, 1, 1, 1); /* * USB device probe/attach/detach @@ -924,7 +944,8 @@ static int umass_attach(device_t self) { - USB_ATTACH_START(umass, sc, uaa); + struct umass_softc *sc = device_get_softc(self); + struct usb_attach_arg *uaa = device_get_ivars(self); usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; int i; @@ -937,7 +958,7 @@ sc->sc_dev = self; sc->iface = uaa->iface; sc->ifaceno = uaa->ifaceno; - usb_callout_init(sc->cam_scsi_rescan_ch); + callout_init(&sc->cam_scsi_rescan_ch, 0); /* initialise the proto and drive values in the umass_softc (again) */ (void) umass_match_proto(sc, sc->iface, uaa->device); @@ -1179,7 +1200,7 @@ static int umass_detach(device_t self) { - USB_DETACH_START(umass, sc); + struct umass_softc *sc = device_get_softc(self); int err = 0; int i; @@ -1196,7 +1217,7 @@ if (sc->intrin_pipe) usbd_abort_pipe(sc->intrin_pipe); - usb_uncallout_drain(sc->cam_scsi_rescan_ch, umass_cam_rescan, sc); + callout_drain(&sc->cam_scsi_rescan_ch); if ((sc->proto & UMASS_PROTO_SCSI) || (sc->proto & UMASS_PROTO_ATAPI) || (sc->proto & UMASS_PROTO_UFI) || @@ -2339,7 +2360,7 @@ * completed, when interrupts have been enabled. */ - usb_callout(sc->cam_scsi_rescan_ch, MS_TO_TICKS(200), + callout_reset(&sc->cam_scsi_rescan_ch, MS_TO_TICKS(200), umass_cam_rescan, sc); } Index: umodem.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/umodem.c,v retrieving revision 1.67 diff -u -r1.67 umodem.c --- umodem.c 20 Jun 2007 05:10:53 -0000 1.67 +++ umodem.c 20 Jun 2007 23:22:33 -0000 @@ -284,9 +284,6 @@ int i; struct ucom_softc *ucom; - id = usbd_get_interface_descriptor(sc->sc_ctl_iface); - device_printf(self, "iclass %d/%d", id->bInterfaceClass, - id->bInterfaceSubClass); ucom = &sc->sc_ucom; ucom->sc_dev = self; sc->sc_dev = self; @@ -296,6 +293,9 @@ sc->sc_udev = dev; sc->sc_ctl_iface = uaa->iface; sc->sc_ctl_iface_no = id->bInterfaceNumber; + id = usbd_get_interface_descriptor(sc->sc_ctl_iface); + device_printf(self, "iclass %d/%d", id->bInterfaceClass, + id->bInterfaceSubClass); umodem_get_caps(dev, &sc->sc_cm_cap, &sc->sc_acm_cap); @@ -360,16 +360,11 @@ goto bad; } - if (usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_ASSUME_CM_OVER_DATA) { - DPRINTF(("Quirk says to assume CM over data\n")); + if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) { + if (sc->sc_acm_cap & USB_CDC_ACM_HAS_FEATURE) + umodem_set_comm_feature(sc, UCDC_ABSTRACT_STATE, + UCDC_DATA_MULTIPLEXED); sc->sc_cm_over_data = 1; - } else { - if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) { - if (sc->sc_acm_cap & USB_CDC_ACM_HAS_FEATURE) - umodem_set_comm_feature(sc, - UCDC_ABSTRACT_STATE, UCDC_DATA_MULTIPLEXED); - sc->sc_cm_over_data = 1; - } } /* Index: ums.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/ums.c,v retrieving revision 1.93 diff -u -r1.93 ums.c --- ums.c 20 Jun 2007 05:10:53 -0000 1.93 +++ ums.c 21 Jun 2007 04:20:54 -0000 @@ -58,7 +58,6 @@ #include #include -#include #include #include @@ -100,7 +99,7 @@ struct hid_location sc_loc_x, sc_loc_y, sc_loc_z, sc_loc_t; struct hid_location *sc_loc_btn; - usb_callout_t callout_handle; /* for spurious button ups */ + struct callout callout_handle; /* for spurious button ups */ int sc_enabled; int sc_disconnected; /* device is gone */ @@ -158,7 +157,26 @@ .d_name = "ums", }; -USB_DECLARE_DRIVER(ums); +static device_probe_t ums_match; +static device_attach_t ums_attach; +static device_detach_t ums_detach; + +static device_method_t ums_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ums_match), + DEVMETHOD(device_attach, ums_attach), + DEVMETHOD(device_detach, ums_detach), + + { 0, 0 } +}; + +static driver_t ums_driver = { + "ums", + ums_methods, + sizeof(struct ums_softc) +}; + +static devclass_t ums_devclass; static int ums_match(device_t self) @@ -192,7 +210,8 @@ static int ums_attach(device_t self) { - USB_ATTACH_START(ums, sc, uaa); + struct ums_softc *sc = device_get_softc(self); + struct usb_attach_arg *uaa = device_get_ivars(self); usbd_interface_handle iface = uaa->iface; usb_interface_descriptor_t *id; usb_endpoint_descriptor_t *ed; @@ -355,7 +374,7 @@ UID_ROOT, GID_OPERATOR, 0644, "ums%d", device_get_unit(self)); - usb_callout_init(sc->callout_handle); + callout_init(&sc->callout_handle, 0); if (usbd_get_quirks(uaa->device)->uq_flags & UQ_SPUR_BUT_UP) { DPRINTF(("%s: Spurious button up events\n", device_get_nameunit(sc->sc_dev))); @@ -402,10 +421,7 @@ } void -ums_intr(xfer, addr, status) - usbd_xfer_handle xfer; - usbd_private_handle addr; - usbd_status status; +ums_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status) { struct ums_softc *sc = addr; u_char *ibuf; @@ -494,11 +510,10 @@ */ if (sc->flags & UMS_SPUR_BUT_UP && dx == 0 && dy == 0 && dz == 0 && dt == 0 && buttons == 0) { - usb_callout(sc->callout_handle, MS_TO_TICKS(50 /*msecs*/), - ums_add_to_queue_timeout, (void *) sc); + callout_reset(&sc->callout_handle, MS_TO_TICKS(50), + ums_add_to_queue_timeout, (void *) sc); } else { - usb_uncallout(sc->callout_handle, - ums_add_to_queue_timeout, (void *) sc); + callout_stop(&sc->callout_handle); ums_add_to_queue(sc, dx, dy, dz, dt, buttons); } } @@ -603,7 +618,7 @@ { struct ums_softc *sc = priv; - usb_uncallout(sc->callout_handle, ums_add_to_queue_timeout, sc); + callout_stop(&sc->callout_handle); /* Disable interrupts. */ usbd_abort_pipe(sc->sc_intrpipe); @@ -620,7 +635,9 @@ { struct ums_softc *sc; - USB_GET_SC_OPEN(ums, UMSUNIT(dev), sc); + sc = devclass_get_softc(ums_devclass, UMSUNIT(dev)); + if (sc == NULL) + return (ENXIO); return ums_enable(sc); } @@ -630,8 +647,7 @@ { struct ums_softc *sc; - USB_GET_SC(ums, UMSUNIT(dev), sc); - + sc = devclass_get_softc(ums_devclass, UMSUNIT(dev)); if (!sc) return 0; @@ -650,8 +666,7 @@ int l = 0; int error; - USB_GET_SC(ums, UMSUNIT(dev), sc); - + sc = devclass_get_softc(ums_devclass, UMSUNIT(dev)); s = splusb(); if (!sc) { splx(s); @@ -718,8 +733,7 @@ int revents = 0; int s; - USB_GET_SC(ums, UMSUNIT(dev), sc); - + sc = devclass_get_softc(ums_devclass, UMSUNIT(dev)); if (!sc) return 0; @@ -745,8 +759,7 @@ int s; mousemode_t mode; - USB_GET_SC(ums, UMSUNIT(dev), sc); - + sc = devclass_get_softc(ums_devclass, UMSUNIT(dev)); if (!sc) return EIO; @@ -853,4 +866,5 @@ return error; } +MODULE_DEPEND(ums, usb, 1, 1, 1); DRIVER_MODULE(ums, uhub, ums_driver, ums_devclass, usbd_driver_load, 0); Index: urio.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/urio.c,v retrieving revision 1.47 diff -u -r1.47 urio.c --- urio.c 20 Jun 2007 05:10:53 -0000 1.47 +++ urio.c 21 Jun 2007 04:19:26 -0000 @@ -62,7 +62,6 @@ #include #include -#include #include #include #include @@ -124,16 +123,33 @@ int sc_refcnt; struct cdev *sc_dev_t; -#if defined(__NetBSD__) || defined(__OpenBSD__) u_char sc_dying; -#endif }; #define URIOUNIT(n) (minor(n)) #define RIO_RW_TIMEOUT 4000 /* ms */ -USB_DECLARE_DRIVER(urio); +static device_probe_t urio_match; +static device_attach_t urio_attach; +static device_detach_t urio_detach; + +static device_method_t urio_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, urio_match), + DEVMETHOD(device_attach, urio_attach), + DEVMETHOD(device_detach, urio_detach), + + { 0, 0 } +}; + +static driver_t urio_driver = { + "urio", + urio_methods, + sizeof(struct urio_softc) +}; + +static devclass_t urio_devclass; static int urio_match(device_t self) @@ -161,13 +177,11 @@ static int urio_attach(device_t self) { - USB_ATTACH_START(urio, sc, uaa); + struct urio_softc *sc = device_get_softc(self); + struct usb_attach_arg *uaa = device_get_ivars(self); 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 = ""; int i; @@ -176,29 +190,11 @@ 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_pipeh_in = 0; sc->sc_pipeh_out = 0; @@ -233,15 +229,9 @@ goto nobulk; } -#if defined(__FreeBSD__) - /* XXX no error trapping, no storing of struct cdev **/ sc->sc_dev_t = make_dev(&urio_cdevsw, device_get_unit(self), UID_ROOT, GID_OPERATOR, 0644, "urio%d", device_get_unit(self)); -#elif defined(__NetBSD__) || defined(__OpenBSD__) - usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, sc->sc_dev); -#endif - DPRINTFN(10, ("urio_attach: %p\n", sc->sc_udev)); return 0; @@ -255,11 +245,11 @@ int urioopen(struct cdev *dev, int flag, int mode, struct thread *p) { -#if (USBDI >= 1) struct urio_softc * sc; -#endif int unit = URIOUNIT(dev); - USB_GET_SC_OPEN(urio, unit, sc); + sc = devclass_get_softc(urio_devclass, unit); + if (sc == NULL) + return (ENXIO); DPRINTFN(5, ("urioopen: flag=%d, mode=%d, unit=%d\n", flag, mode, unit)); @@ -295,11 +285,9 @@ int urioclose(struct cdev *dev, int flag, int mode, struct thread *p) { -#if (USBDI >= 1) struct urio_softc * sc; -#endif int unit = URIOUNIT(dev); - USB_GET_SC(urio, unit, sc); + sc = devclass_get_softc(urio_devclass, unit); DPRINTFN(5, ("urioclose: flag=%d, mode=%d, unit=%d\n", flag, mode, unit)); if (sc->sc_pipeh_in) @@ -318,49 +306,29 @@ int urioread(struct cdev *dev, struct uio *uio, int flag) { -#if (USBDI >= 1) struct urio_softc * sc; usbd_xfer_handle reqh; -#else - usbd_request_handle reqh; - usbd_private_handle r_priv; - void *r_buff; - usbd_status r_status; -#endif int unit = URIOUNIT(dev); usbd_status r; char buf[URIO_BBSIZE]; u_int32_t n, tn; int error = 0; - USB_GET_SC(urio, unit, sc); + sc = devclass_get_softc(urio_devclass, unit); DPRINTFN(5, ("urioread: %d\n", unit)); if (!sc->sc_opened) return EIO; -#if (USBDI >= 1) sc->sc_refcnt++; reqh = usbd_alloc_xfer(sc->sc_udev); -#else - reqh = usbd_alloc_request(); -#endif if (reqh == 0) return ENOMEM; while ((n = min(URIO_BBSIZE, uio->uio_resid)) != 0) { DPRINTFN(1, ("urioread: start transfer %d bytes\n", n)); tn = n; -#if (USBDI >= 1) usbd_setup_xfer(reqh, sc->sc_pipeh_in, 0, buf, tn, 0, RIO_RW_TIMEOUT, 0); -#else - r = usbd_setup_request(reqh, sc->sc_pipeh_in, 0, buf, tn, - 0, RIO_RW_TIMEOUT, 0); - if (r != USBD_NORMAL_COMPLETION) { - error = EIO; - break; - } -#endif r = usbd_sync_transfer(reqh); if (r != USBD_NORMAL_COMPLETION) { DPRINTFN(1, ("urioread: error=%d\n", r)); @@ -369,53 +337,35 @@ error = EIO; break; } -#if (USBDI >= 1) usbd_get_xfer_status(reqh, 0, 0, &tn, 0); -#else - usbd_get_request_status(reqh, &r_priv, &r_buff, &tn, &r_status); -#endif DPRINTFN(1, ("urioread: got %d bytes\n", tn)); error = uiomove(buf, tn, uio); if (error || tn < n) break; } -#if (USBDI >= 1) usbd_free_xfer(reqh); -#else - usbd_free_request(reqh); -#endif - return error; } int uriowrite(struct cdev *dev, struct uio *uio, int flag) { -#if (USBDI >= 1) struct urio_softc * sc; usbd_xfer_handle reqh; -#else - usbd_request_handle reqh; -#endif int unit = URIOUNIT(dev); usbd_status r; char buf[URIO_BBSIZE]; u_int32_t n; int error = 0; - USB_GET_SC(urio, unit, sc); - + sc = devclass_get_softc(urio_devclass, unit); DPRINTFN(5, ("uriowrite: %d\n", unit)); if (!sc->sc_opened) return EIO; -#if (USBDI >= 1) sc->sc_refcnt++; reqh = usbd_alloc_xfer(sc->sc_udev); -#else - reqh = usbd_alloc_request(); -#endif if (reqh == 0) return EIO; while ((n = min(URIO_BBSIZE, uio->uio_resid)) != 0) { @@ -423,17 +373,8 @@ if (error) break; DPRINTFN(1, ("uriowrite: transfer %d bytes\n", n)); -#if (USBDI >= 1) usbd_setup_xfer(reqh, sc->sc_pipeh_out, 0, buf, n, 0, RIO_RW_TIMEOUT, 0); -#else - r = usbd_setup_request(reqh, sc->sc_pipeh_out, 0, buf, n, - 0, RIO_RW_TIMEOUT, 0); - if (r != USBD_NORMAL_COMPLETION) { - error = EIO; - break; - } -#endif r = usbd_sync_transfer(reqh); if (r != USBD_NORMAL_COMPLETION) { DPRINTFN(1, ("uriowrite: error=%d\n", r)); @@ -441,17 +382,10 @@ error = EIO; break; } -#if (USBDI >= 1) usbd_get_xfer_status(reqh, 0, 0, 0, 0); -#endif } -#if (USBDI >= 1) usbd_free_xfer(reqh); -#else - usbd_free_request(reqh); -#endif - return error; } @@ -459,9 +393,7 @@ int urioioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *p) { -#if (USBDI >= 1) struct urio_softc * sc; -#endif int unit = URIOUNIT(dev); struct RioCommand *rio_cmd; int requesttype, len; @@ -473,8 +405,7 @@ int error = 0; usbd_status r; - USB_GET_SC(urio, unit, sc); - + sc = devclass_get_softc(urio_devclass, unit); switch (cmd) { case RIO_RECV_COMMAND: if (!(flag & FWRITE)) @@ -556,61 +487,14 @@ return error; } - -#if defined(__NetBSD__) || defined(__OpenBSD__) -int -urio_activate(device_t self, enum devact act) -{ - struct urio_softc *sc = (struct urio_softc *)self; - - switch (act) { - case DVACT_ACTIVATE: - return (EOPNOTSUPP); - break; - - case DVACT_DEACTIVATE: - sc->sc_dying = 1; - break; - } - return (0); -} - static int urio_detach(device_t self) { - USB_DETACH_START(urio, sc); - struct urio_endpoint *sce; - int i, dir; + struct urio_softc *sc = device_get_softc(self); int s; -#if defined(__NetBSD__) || defined(__OpenBSD__) - int maj, mn; - DPRINTF(("urio_detach: sc=%p flags=%d\n", sc, flags)); -#elif defined(__FreeBSD__) DPRINTF(("urio_detach: sc=%p\n", sc)); -#endif - sc->sc_dying = 1; - /* Abort all pipes. Causes processes waiting for transfer to wake. */ -#if 0 - for (i = 0; i < USB_MAX_ENDPOINTS; i++) { - for (dir = OUT; dir <= IN; dir++) { - sce = &sc->sc_endpoints[i][dir]; - if (sce && sce->pipeh) - usbd_abort_pipe(sce->pipeh); - } - } - - s = splusb(); - if (--sc->sc_refcnt >= 0) { - /* Wake everyone */ - for (i = 0; i < USB_MAX_ENDPOINTS; i++) - wakeup(&sc->sc_endpoints[i][IN]); - /* Wait for processes to go away. */ - usb_detach_wait(sc->sc_dev); - } - splx(s); -#else if (sc->sc_pipeh_in) usbd_abort_pipe(sc->sc_pipeh_in); @@ -623,37 +507,12 @@ usb_detach_wait(sc->sc_dev); } splx(s); -#endif - -#if defined(__NetBSD__) || defined(__OpenBSD__) - /* locate the major number */ - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == urioopen) - 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); -#endif - - usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev); - - return (0); -} -#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */ - -#if defined(__FreeBSD__) -static int -urio_detach(device_t self) -{ - struct urio_softc *sc = device_get_softc(self); - - DPRINTF(("%s: disconnected\n", device_get_nameunit(self))); destroy_dev(sc->sc_dev_t); /* XXX not implemented yet */ device_set_desc(self, NULL); return 0; } +MODULE_DEPEND(uscanner, usb, 1, 1, 1); DRIVER_MODULE(urio, uhub, urio_driver, urio_devclass, usbd_driver_load, 0); -#endif Index: usb_quirks.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/usb_quirks.c,v retrieving revision 1.59 diff -u -r1.59 usb_quirks.c --- usb_quirks.c 20 Jun 2007 05:10:54 -0000 1.59 +++ usb_quirks.c 20 Jun 2007 23:25:35 -0000 @@ -60,7 +60,6 @@ u_int16_t bcdDevice; struct usbd_quirks quirks; } usb_quirks[] = { - { USB_VENDOR_KYE, USB_PRODUCT_KYE_NICHE, 0x100, { UQ_NO_SET_PROTO}}, { USB_VENDOR_INSIDEOUT, USB_PRODUCT_INSIDEOUT_EDGEPORT4, 0x094, { UQ_SWAP_UNICODE}}, { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_BAD_ADC }}, @@ -71,27 +70,11 @@ { USB_VENDOR_ALCOR2, USB_PRODUCT_ALCOR2_KBD_HUB, 0x001, { UQ_SPUR_BUT_UP }}, { USB_VENDOR_MCT, USB_PRODUCT_MCT_HUB0100, 0x102, { UQ_BUS_POWERED }}, { USB_VENDOR_MCT, USB_PRODUCT_MCT_USB232, 0x102, { UQ_BUS_POWERED }}, - { USB_VENDOR_METRICOM, USB_PRODUCT_METRICOM_RICOCHET_GS, - 0x100, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_SANYO, USB_PRODUCT_SANYO_SCP4900, - 0x000, { UQ_ASSUME_CM_OVER_DATA }}, { USB_VENDOR_TI, USB_PRODUCT_TI_UTUSB41, 0x110, { UQ_POWER_CLAIM }}, { USB_VENDOR_TELEX, USB_PRODUCT_TELEX_MIC1, 0x009, { UQ_AU_NO_FRAC }}, { USB_VENDOR_SILICONPORTALS, USB_PRODUCT_SILICONPORTALS_YAPPHONE, 0x100, { UQ_AU_INP_ASYNC }}, { USB_VENDOR_LOGITECH, USB_PRODUCT_LOGITECH_UN53B, ANY, { UQ_NO_STRINGS }}, - { USB_VENDOR_CMOTECH, USB_PRODUCT_CMOTECH_CNU510, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_CMOTECH, USB_PRODUCT_CMOTECH_CNU550, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_CURITEL, USB_PRODUCT_CURITEL_HX550C, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_CURITEL, USB_PRODUCT_CURITEL_HX57XB, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_UBIQUAM, USB_PRODUCT_UBIQUAM_UALL, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_QUALCOMM, USB_PRODUCT_QUALCOMM_RWT_FCT, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, /* XXX These should have a revision number, but I don't know what they are. */ { USB_VENDOR_HP, USB_PRODUCT_HP_895C, ANY, { UQ_BROKEN_BIDIR }}, { USB_VENDOR_HP, USB_PRODUCT_HP_880C, ANY, { UQ_BROKEN_BIDIR }}, @@ -100,23 +83,6 @@ { USB_VENDOR_HP, USB_PRODUCT_HP_830C, ANY, { UQ_BROKEN_BIDIR }}, { USB_VENDOR_HP, USB_PRODUCT_HP_1220C, ANY, { UQ_BROKEN_BIDIR }}, { USB_VENDOR_XEROX, USB_PRODUCT_XEROX_WCM15, ANY, { UQ_BROKEN_BIDIR }}, - /* YAMAHA router's ucdDevice is the version of farmware and often changes. */ - { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA54I, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTA55I, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTW65B, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_YAMAHA, USB_PRODUCT_YAMAHA_RTW65I, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_QUALCOMM, USB_PRODUCT_QUALCOMM_CDMA_MSM, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_QUALCOMM2, USB_PRODUCT_QUALCOMM2_CDMA_MSM, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_AS64LX, - 0x100, { UQ_ASSUME_CM_OVER_DATA }}, - { USB_VENDOR_MOTOROLA2, USB_PRODUCT_MOTOROLA2_A41XV32X, - ANY, { UQ_ASSUME_CM_OVER_DATA }}, /* Devices which should be ignored by uhid */ { USB_VENDOR_APC, USB_PRODUCT_APC_UPS, ANY, { UQ_HID_IGNORE }}, @@ -130,6 +96,7 @@ ANY, { UQ_HID_IGNORE }}, { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2, ANY, { UQ_HID_IGNORE }}, + /* Devices which should be ignored by both ukbd and uhid */ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_WISPY, ANY, { UQ_KBD_IGNORE }}, Index: usb_quirks.h =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/usb_quirks.h,v retrieving revision 1.23 diff -u -r1.23 usb_quirks.h --- usb_quirks.h 28 Nov 2006 21:13:07 -0000 1.23 +++ usb_quirks.h 20 Jun 2007 22:52:51 -0000 @@ -40,7 +40,6 @@ struct usbd_quirks { u_int32_t uq_flags; /* Device problems: */ -#define UQ_NO_SET_PROTO 0x0001 /* cannot handle SET PROTOCOL. */ #define UQ_SWAP_UNICODE 0x0002 /* has some Unicode strings swapped. */ #define UQ_MS_REVZ 0x0004 /* mouse has Z-axis reversed */ #define UQ_NO_STRINGS 0x0008 /* string descriptors are broken. */ @@ -52,12 +51,10 @@ #define UQ_POWER_CLAIM 0x0200 /* hub lies about power status */ #define UQ_AU_NO_FRAC 0x0400 /* don't adjust for fractional samples */ #define UQ_AU_INP_ASYNC 0x0800 /* input is async despite claim of adaptive */ -#define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */ #define UQ_BROKEN_BIDIR 0x2000 /* printer has broken bidir mode */ #define UQ_OPEN_CLEARSTALL 0x4000 /* device needs clear endpoint stall */ #define UQ_HID_IGNORE 0x8000 /* device should be ignored by hid class */ #define UQ_KBD_IGNORE 0x18000 /* device should be ignored by both kbd and hid class */ - }; extern const struct usbd_quirks usbd_no_quirk; Index: uscanner.c =================================================================== RCS file: /cache/ncvs/src/sys/dev/usb/uscanner.c,v retrieving revision 1.86 diff -u -r1.86 uscanner.c --- uscanner.c 20 Jun 2007 05:10:54 -0000 1.86 +++ uscanner.c 21 Jun 2007 04:19:06 -0000 @@ -64,7 +64,6 @@ #include #include -#include #include #include #include @@ -289,7 +288,26 @@ #define USCANNERUNIT(n) (minor(n)) -USB_DECLARE_DRIVER(uscanner); +static device_probe_t uscanner_match; +static device_attach_t uscanner_attach; +static device_detach_t uscanner_detach; + +static device_method_t uscanner_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, uscanner_match), + DEVMETHOD(device_attach, uscanner_attach), + DEVMETHOD(device_detach, uscanner_detach), + + { 0, 0 } +}; + +static driver_t uscanner_driver = { + "uscanner", + uscanner_methods, + sizeof(struct uscanner_softc) +}; + +static devclass_t uscanner_devclass; static int uscanner_match(device_t self) @@ -306,7 +324,8 @@ static int uscanner_attach(device_t self) { - USB_ATTACH_START(uscanner, sc, uaa); + struct uscanner_softc *sc = device_get_softc(self); + struct usb_attach_arg *uaa = device_get_ivars(self); usb_interface_descriptor_t *id = 0; usb_endpoint_descriptor_t *ed, *ed_bulkin = NULL, *ed_bulkout = NULL; int i; @@ -379,7 +398,9 @@ int unit = USCANNERUNIT(dev); usbd_status err; - USB_GET_SC_OPEN(uscanner, unit, sc); + sc = devclass_get_softc(uscanner_devclass, unit); + if (sc == NULL) + return (ENXIO); DPRINTFN(5, ("uscanneropen: flag=%d, mode=%d, unit=%d\n", flag, mode, unit)); @@ -440,8 +461,7 @@ { struct uscanner_softc *sc; - USB_GET_SC(uscanner, USCANNERUNIT(dev), sc); - + sc = devclass_get_softc(uscanner_devclass, USCANNERUNIT(dev)); DPRINTFN(5, ("uscannerclose: flag=%d, mode=%d, unit=%d\n", flag, mode, USCANNERUNIT(dev))); @@ -539,8 +559,7 @@ struct uscanner_softc *sc; int error; - USB_GET_SC(uscanner, USCANNERUNIT(dev), sc); - + sc = devclass_get_softc(uscanner_devclass, USCANNERUNIT(dev)); sc->sc_refcnt++; error = uscanner_do_read(sc, uio, flag); if (--sc->sc_refcnt < 0) @@ -589,8 +608,7 @@ struct uscanner_softc *sc; int error; - USB_GET_SC(uscanner, USCANNERUNIT(dev), sc); - + sc = devclass_get_softc(uscanner_devclass, USCANNERUNIT(dev)); sc->sc_refcnt++; error = uscanner_do_write(sc, uio, flag); if (--sc->sc_refcnt < 0) @@ -601,7 +619,7 @@ static int uscanner_detach(device_t self) { - USB_DETACH_START(uscanner, sc); + struct uscanner_softc *sc = device_get_softc(self); int s; DPRINTF(("uscanner_detach: sc=%p\n", sc)); @@ -635,8 +653,7 @@ struct uscanner_softc *sc; int revents = 0; - USB_GET_SC(uscanner, USCANNERUNIT(dev), sc); - + sc = devclass_get_softc(uscanner_devclass, USCANNERUNIT(dev)); if (sc->sc_dying) return (EIO); @@ -651,4 +668,5 @@ return (revents); } +MODULE_DEPEND(uscanner, usb, 1, 1, 1); DRIVER_MODULE(uscanner, uhub, uscanner_driver, uscanner_devclass, usbd_driver_load, 0);