usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, USBDEV(sc->sc_dev));
USB_ATTACH(ural){	USB_ATTACH_START(ural, sc, uaa);	struct ieee80211com *ic = &sc->sc_ic;	struct ifnet *ifp = &ic->ic_if;	usb_interface_descriptor_t *id;	usb_endpoint_descriptor_t *ed;	usbd_status error;	char devinfo[1024];	int i;	sc->sc_udev = uaa->device;	usbd_devinfo(sc->sc_udev, 0, devinfo, sizeof devinfo);	USB_ATTACH_SETUP;	printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo);	if (usbd_set_config_no(sc->sc_udev, RAL_CONFIG_NO, 0) != 0) {		printf("%s: could not set configuration no\n",		    USBDEVNAME(sc->sc_dev));		USB_ATTACH_ERROR_RETURN;	}	/* get the first interface handle */	error = usbd_device2interface_handle(sc->sc_udev, RAL_IFACE_INDEX,	    &sc->sc_iface);	if (error != 0) {		printf("%s: could not get interface handle\n",		    USBDEVNAME(sc->sc_dev));		USB_ATTACH_ERROR_RETURN;	}	/*	 * Find endpoints.	 */	id = usbd_get_interface_descriptor(sc->sc_iface);	for (i = 0; i < id->bNumEndpoints; i++) {		ed = usbd_interface2endpoint_descriptor(sc->sc_iface, i);		if (ed == NULL) {			printf("%s: no endpoint descriptor for %d\n",			    USBDEVNAME(sc->sc_dev), i);			USB_ATTACH_ERROR_RETURN;		}		if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)			sc->sc_rx_no = ed->bEndpointAddress;		else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&		    UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK)			sc->sc_tx_no = ed->bEndpointAddress;	}	usb_init_task(&sc->sc_task, ural_task, sc);	timeout_set(&sc->scan_ch, ural_next_scan, sc);	/* retrieve RT2570 rev. no */	sc->asic_rev = ural_read(sc, RAL_MAC_CSR0);	/* retrieve MAC address and various other things from EEPROM */	ural_read_eeprom(sc);	printf("%s: MAC/BBP RT2570 (rev 0x%02x), RF %s\n",	    USBDEVNAME(sc->sc_dev), sc->asic_rev, ural_get_rf(sc->rf_rev));	ic->ic_phytype = IEEE80211_T_OFDM; /* not only, but not used */	ic->ic_opmode = IEEE80211_M_STA; /* default to BSS mode */	ic->ic_state = IEEE80211_S_INIT;	/* set device capabilities */	ic->ic_caps = IEEE80211_C_MONITOR | IEEE80211_C_SHPREAMBLE |	    IEEE80211_C_PMGT | IEEE80211_C_TXPMGT | IEEE80211_C_WEP;	if (sc->rf_rev == RAL_RF_5222) {		/* set supported .11a rates */		ic->ic_sup_rates[IEEE80211_MODE_11A] = ural_rateset_11a;		/* set supported .11a channels */		for (i = 36; i <= 64; i += 4) {			ic->ic_channels[i].ic_freq =			    ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ);			ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A;		}		for (i = 100; i <= 140; i += 4) {			ic->ic_channels[i].ic_freq =			    ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ);			ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A;		}		for (i = 149; i <= 161; i += 4) {			ic->ic_channels[i].ic_freq =			    ieee80211_ieee2mhz(i, IEEE80211_CHAN_5GHZ);			ic->ic_channels[i].ic_flags = IEEE80211_CHAN_A;		}	}	/* set supported .11b and .11g rates */	ic->ic_sup_rates[IEEE80211_MODE_11B] = ural_rateset_11b;	ic->ic_sup_rates[IEEE80211_MODE_11G] = ural_rateset_11g;	/* set supported .11b and .11g channels (1 through 14) */	for (i = 1; i <= 11; i++) {		ic->ic_channels[i].ic_freq =		    ieee80211_ieee2mhz(i, IEEE80211_CHAN_2GHZ);		ic->ic_channels[i].ic_flags =		    IEEE80211_CHAN_CCK | IEEE80211_CHAN_OFDM |		    IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ;	}	ifp->if_softc = sc;	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;	ifp->if_init = ural_init;	ifp->if_ioctl = ural_ioctl;	ifp->if_start = ural_start;	ifp->if_watchdog = ural_watchdog;	IFQ_SET_READY(&ifp->if_snd);	memcpy(ifp->if_xname, USBDEVNAME(sc->sc_dev), IFNAMSIZ);	if_attach(ifp);	ieee80211_ifattach(ifp);	/* override state transition machine */	sc->sc_newstate = ic->ic_newstate;	ic->ic_newstate = ural_newstate;	ieee80211_media_init(ifp, ural_media_change, ieee80211_media_status);#if NBPFILTER > 0	bpfattach(&sc->sc_drvbpf, ifp, DLT_IEEE802_11_RADIO,	    sizeof (struct ieee80211_frame) + 64);	sc->sc_rxtap_len = sizeof sc->sc_rxtapu;	sc->sc_rxtap.wr_ihdr.it_len = htole16(sc->sc_rxtap_len);	sc->sc_rxtap.wr_ihdr.it_present = htole32(RAL_RX_RADIOTAP_PRESENT);	sc->sc_txtap_len = sizeof sc->sc_txtapu;	sc->sc_txtap.wt_ihdr.it_len = htole16(sc->sc_txtap_len);	sc->sc_txtap.wt_ihdr.it_present = htole32(RAL_TX_RADIOTAP_PRESENT);#endif	USB_ATTACH_SUCCESS_RETURN;}