Finish removal of usb_port.h macros.

This commit is contained in:
Warner Losh 2007-06-18 22:27:57 +00:00
parent 528fb030b3
commit 70f16d924f
12 changed files with 143 additions and 48 deletions

View File

@ -279,7 +279,8 @@ ubsa_match(device_t self)
static int
ubsa_attach(device_t self)
{
USB_ATTACH_START(ubsa, sc, uaa);
struct ubsa_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev;
struct ucom_softc *ucom;
usb_config_descriptor_t *cdesc;
@ -409,10 +410,9 @@ ubsa_attach(device_t self)
static int
ubsa_detach(device_t self)
{
USB_DETACH_START(ubsa, sc);
struct ubsa_softc *sc = device_get_softc(self);
int rv;
DPRINTF(("ubsa_detach: sc = %p\n", sc));
if (sc->sc_intr_pipe != NULL) {

View File

@ -177,7 +177,26 @@ static t_open_t ubseropen;
static t_close_t ubserclose;
static t_modem_t ubsermodem;
USB_DECLARE_DRIVER(ubser);
static device_probe_t ubser_match;
static device_attach_t ubser_attach;
static device_detach_t ubser_detach;
static device_method_t ubser_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ubser_match),
DEVMETHOD(device_attach, ubser_attach),
DEVMETHOD(device_detach, ubser_detach),
{ 0, 0 }
};
static driver_t ubser_driver = {
"ubser",
ubser_methods,
sizeof(struct ubser_softc)
};
static devclass_t ubser_devclass;
static int
ubser_match(device_t self)
@ -222,7 +241,8 @@ ubser_match(device_t self)
static int
ubser_attach(device_t self)
{
USB_ATTACH_START(ubser, sc, uaa);
struct ubser_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle udev = uaa->device;
usb_endpoint_descriptor_t *ed;
usb_interface_descriptor_t *id;
@ -416,7 +436,7 @@ ubser_attach(device_t self)
static int
ubser_detach(device_t self)
{
USB_DETACH_START(ubser, sc);
struct ubser_softc *sc = device_get_softc(self);
int i;
struct ubser_port *pp;

View File

@ -214,7 +214,26 @@ static void udbp_out_transfer_cb (usbd_xfer_handle xfer,
usbd_private_handle priv,
usbd_status err);
USB_DECLARE_DRIVER(udbp);
static device_probe_t udbp_match;
static device_attach_t udbp_attach;
static device_detach_t udbp_detach;
static device_method_t udbp_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, udbp_match),
DEVMETHOD(device_attach, udbp_attach),
DEVMETHOD(device_detach, udbp_detach),
{ 0, 0 }
};
static driver_t udbp_driver = {
"udbp",
udbp_methods,
sizeof(struct udbp_softc)
};
static devclass_t udbp_devclass;
static int
udbp_match(device_t self)
@ -252,7 +271,8 @@ udbp_match(device_t self)
static int
udbp_attach(device_t self)
{
USB_ATTACH_START(udbp, sc, uaa);
struct udbp_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, *ed_bulkin = NULL, *ed_bulkout = NULL;
@ -409,7 +429,7 @@ udbp_attach(device_t self)
static int
udbp_detach(device_t self)
{
USB_DETACH_START(udbp, sc);
struct udbp_softc *sc = device_get_softc(self);
sc->flags |= DISCONNECTED;

View File

@ -98,7 +98,26 @@ struct ufm_softc {
#define UFMUNIT(n) (minor(n))
USB_DECLARE_DRIVER(ufm);
static device_probe_t ufm_match;
static device_attach_t ufm_attach;
static device_detach_t ufm_detach;
static device_method_t ufm_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ufm_match),
DEVMETHOD(device_attach, ufm_attach),
DEVMETHOD(device_detach, ufm_detach),
{ 0, 0 }
};
static driver_t ufm_driver = {
"ufm",
ufm_methods,
sizeof(struct ufm_softc)
};
static devclass_t ufm_devclass;
static int
ufm_match(device_t self)
@ -123,7 +142,8 @@ ufm_match(device_t self)
static int
ufm_attach(device_t self)
{
USB_ATTACH_START(ufm, sc, uaa);
struct ufm_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usb_endpoint_descriptor_t *edesc;
usbd_device_handle udev;
usbd_interface_handle iface;
@ -175,7 +195,9 @@ ufmopen(struct cdev *dev, int flag, int mode, struct thread *td)
struct ufm_softc *sc;
int unit = UFMUNIT(dev);
USB_GET_SC_OPEN(ufm, unit, sc);
sc = devclass_get_softc(ufm_devclass, unit);
if (sc == NULL)
return (ENXIO);
DPRINTFN(5, ("ufmopen: flag=%d, mode=%d, unit=%d\n",
flag, mode, unit));
@ -196,7 +218,7 @@ ufmclose(struct cdev *dev, int flag, int mode, struct thread *td)
struct ufm_softc *sc;
int unit = UFMUNIT(dev);
USB_GET_SC(ufm, unit, sc);
sc = devclass_get_softc(ufm_devclass, unit);
DPRINTFN(5, ("ufmclose: flag=%d, mode=%d, unit=%d\n", flag, mode, unit));
sc->sc_opened = 0;
@ -319,7 +341,7 @@ ufmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *td
int unit = UFMUNIT(dev);
int error = 0;
USB_GET_SC(ufm, unit, sc);
sc = devclass_get_softc(ufm_devclass, unit);
switch (cmd) {
case FM_SET_FREQ:

View File

@ -302,7 +302,8 @@ ufoma_match(device_t self)
static int
ufoma_attach(device_t self)
{
USB_ATTACH_START(ufoma, sc, uaa);
struct ufoma_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev = uaa->device;
usb_config_descriptor_t *cd;
usb_interface_descriptor_t *id;
@ -419,18 +420,17 @@ ufoma_attach(device_t self)
static int
ufoma_detach(device_t self)
{
USB_DETACH_START(ufoma, sc);
struct ufoma_softc *sc = device_get_softc(self);
int rv = 0;
usbd_free_xfer(sc->sc_msgxf);
sc->sc_ucom.sc_dying = 1;
usbd_abort_pipe(sc->sc_notify_pipe);
usbd_close_pipe(sc->sc_notify_pipe);
if(sc->sc_is_ucom){
if(sc->sc_is_ucom)
ucom_detach(&sc->sc_ucom);
}else{
else
ttyfree(sc->sc_ucom.sc_tty);
}
free(sc->sc_modetable, M_USBDEV);
return rv;
}

View File

@ -187,7 +187,8 @@ uftdi_match(device_t self)
static int
uftdi_attach(device_t self)
{
USB_ATTACH_START(uftdi, sc, uaa);
struct uftdi_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev = uaa->device;
usbd_interface_handle iface;
usb_interface_descriptor_t *id;
@ -386,11 +387,11 @@ uftdi_activate(device_t self, enum devact act)
return (rv);
}
#endif
#if 1
static int
uftdi_detach(device_t self)
{
USB_DETACH_START(uftdi, sc);
struct uftdi_softc *sc = device_get_softc(self);
int rv = 0;
@ -400,7 +401,7 @@ uftdi_detach(device_t self)
return rv;
}
#endif
static int
uftdi_open(void *vsc, int portno)
{

View File

@ -48,6 +48,11 @@ __FBSDID("$FreeBSD$");
* HID spec: http://www.usb.org/developers/devclass_docs/HID1_11.pdf
*/
/*
* XXX TODO: Convert this driver to use si_drv[12] rather than the
* devclass_get_softc junk
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@ -163,7 +168,31 @@ static int uhid_do_write(struct uhid_softc *, struct uio *uio, int);
static int uhid_do_ioctl(struct uhid_softc *, u_long, caddr_t, int,
struct thread *);
USB_DECLARE_DRIVER(uhid);
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;
static device_detach_t uhid_detach;
static device_method_t uhid_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, uhid_match),
DEVMETHOD(device_attach, uhid_attach),
DEVMETHOD(device_detach, uhid_detach),
{ 0, 0 }
};
static driver_t uhid_driver = {
"uhid",
uhid_methods,
sizeof(struct uhid_softc)
};
static devclass_t uhid_devclass;
DRIVER_MODULE(uhid, uhub, uhid_driver, uhid_devclass, usbd_driver_load, 0);
static int
uhid_match(device_t self)
@ -196,7 +225,8 @@ uhid_match(device_t self)
static int
uhid_attach(device_t self)
{
USB_ATTACH_START(uhid, sc, uaa);
struct uhid_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;
@ -306,7 +336,7 @@ uhid_attach(device_t self)
static int
uhid_detach(device_t self)
{
USB_DETACH_START(uhid, sc);
struct uhid_softc *sc = device_get_softc(self);
int s;
DPRINTF(("uhid_detach: sc=%p\n", sc));
@ -382,7 +412,9 @@ uhidopen(struct cdev *dev, int flag, int mode, struct thread *p)
struct uhid_softc *sc;
usbd_status err;
USB_GET_SC_OPEN(uhid, UHIDUNIT(dev), sc);
sc = devclass_get_softc(uhid_devclass, UHIDUNIT(dev));
if (sc == NULL)
return (ENXIO);
DPRINTF(("uhidopen: sc=%p\n", sc));
@ -424,7 +456,7 @@ uhidclose(struct cdev *dev, int flag, int mode, struct thread *p)
{
struct uhid_softc *sc;
USB_GET_SC(uhid, UHIDUNIT(dev), sc);
sc = devclass_get_softc(uhid_devclass, UHIDUNIT(dev));
DPRINTF(("uhidclose: sc=%p\n", sc));
@ -515,8 +547,7 @@ uhidread(struct cdev *dev, struct uio *uio, int flag)
struct uhid_softc *sc;
int error;
USB_GET_SC(uhid, UHIDUNIT(dev), sc);
sc = devclass_get_softc(uhid_devclass, UHIDUNIT(dev));
sc->sc_refcnt++;
error = uhid_do_read(sc, uio, flag);
if (--sc->sc_refcnt < 0)
@ -561,8 +592,7 @@ uhidwrite(struct cdev *dev, struct uio *uio, int flag)
struct uhid_softc *sc;
int error;
USB_GET_SC(uhid, UHIDUNIT(dev), sc);
sc = devclass_get_softc(uhid_devclass, UHIDUNIT(dev));
sc->sc_refcnt++;
error = uhid_do_write(sc, uio, flag);
if (--sc->sc_refcnt < 0)
@ -691,8 +721,7 @@ uhidioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, struct thread *p
struct uhid_softc *sc;
int error;
USB_GET_SC(uhid, UHIDUNIT(dev), sc);
sc = devclass_get_softc(uhid_devclass, UHIDUNIT(dev));
sc->sc_refcnt++;
error = uhid_do_ioctl(sc, cmd, addr, flag, p);
if (--sc->sc_refcnt < 0)
@ -707,8 +736,7 @@ uhidpoll(struct cdev *dev, int events, struct thread *p)
int revents = 0;
int s;
USB_GET_SC(uhid, UHIDUNIT(dev), sc);
sc = devclass_get_softc(uhid_devclass, UHIDUNIT(dev));
if (sc->sc_dying)
return (EIO);
@ -725,5 +753,3 @@ uhidpoll(struct cdev *dev, int events, struct thread *p)
splx(s);
return (revents);
}
DRIVER_MODULE(uhid, uhub, uhid_driver, uhid_devclass, usbd_driver_load, 0);

View File

@ -160,7 +160,8 @@ umct_match(device_t self)
static int
umct_attach(device_t self)
{
USB_ATTACH_START(umct, sc, uaa);
struct umct_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev;
struct ucom_softc *ucom;
usb_config_descriptor_t *cdesc;
@ -278,7 +279,8 @@ umct_attach(device_t self)
static int
umct_detach(device_t self)
{
USB_DETACH_START(umct, sc);
struct umct_softc *sc = device_get_softc(self);
int rv;
if (sc->sc_intr_pipe != NULL) {

View File

@ -274,7 +274,8 @@ umodem_match(device_t self)
static int
umodem_attach(device_t self)
{
USB_ATTACH_START(umodem, sc, uaa);
struct umodem_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev = uaa->device;
usb_interface_descriptor_t *id;
usb_endpoint_descriptor_t *ed;
@ -809,7 +810,7 @@ umodem_set_comm_feature(struct umodem_softc *sc, int feature, int state)
static int
umodem_detach(device_t self)
{
USB_DETACH_START(umodem, sc);
struct umodem_softc *sc = device_get_softc(self);
int rv = 0;
DPRINTF(("umodem_detach: sc=%p\n", sc));

View File

@ -341,7 +341,8 @@ uplcom_match(device_t self)
static int
uplcom_attach(device_t self)
{
USB_ATTACH_START(uplcom, sc, uaa);
struct uplcom_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev = uaa->device;
struct ucom_softc *ucom;
usb_config_descriptor_t *cdesc;
@ -549,7 +550,7 @@ uplcom_attach(device_t self)
static int
uplcom_detach(device_t self)
{
USB_DETACH_START(uplcom, sc);
struct uplcom_softc *sc = device_get_softc(self);
int rv = 0;
DPRINTF(("uplcom_detach: sc = %p\n", sc));

View File

@ -262,7 +262,8 @@ uvisor_match(device_t self)
static int
uvisor_attach(device_t self)
{
USB_ATTACH_START(uvisor, sc, uaa);
struct uvisor_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev = uaa->device;
usbd_interface_handle iface;
usb_interface_descriptor_t *id;
@ -400,7 +401,7 @@ uvisor_activate(device_t self, enum devact act)
static int
uvisor_detach(device_t self)
{
USB_DETACH_START(uvisor, sc);
struct uvisor_softc *sc = device_get_softc(self);
int rv = 0;
DPRINTF(("uvisor_detach: sc=%p\n", sc));

View File

@ -309,7 +309,8 @@ uvscom_match(device_t self)
static int
uvscom_attach(device_t self)
{
USB_ATTACH_START(uvscom, sc, uaa);
struct uvscom_softc *sc = device_get_softc(self);
struct usb_attach_arg *uaa = device_get_ivars(self);
usbd_device_handle dev = uaa->device;
struct ucom_softc *ucom;
usb_config_descriptor_t *cdesc;
@ -435,7 +436,7 @@ uvscom_attach(device_t self)
static int
uvscom_detach(device_t self)
{
USB_DETACH_START(uvscom, sc);
struct uvscom_softc *sc = device_get_softc(self);
int rv = 0;
DPRINTF(("uvscom_detach: sc = %p\n", sc));