static status_t pegasus_device_removed(void *cookie) { pegasus_dev *device = cookie; ASSERT(cookie != NULL); DPRINTF_INFO("device_removed(%s)\n", device->name); aue_uninit(device); usb->cancel_queued_transfers(device->pipe_in); usb->cancel_queued_transfers(device->pipe_out); usb->cancel_queued_transfers(device->pipe_intr); remove_device_info(device); if (device->open == 0) { remove_device(device); } else { DPRINTF_INFO("%s still open\n", device->name); AUE_LOCK(device); device->aue_dying = true; AUE_UNLOCK(device); } return B_OK; }
/* * Attach */ void aue_attach(pegasus_dev *sc) { u_char eaddr[ETHER_ADDRESS_LENGTH]; AUE_LOCK(sc); /* Reset the adapter. */ aue_reset(sc); /* * Get station address from the EEPROM. */ aue_read_eeprom(sc, (caddr_t)&eaddr, 0, 3, 0); memcpy(sc->macaddr, eaddr, ETHER_ADDRESS_LENGTH); if (aue_init_phy(sc) != B_OK) goto done; sc->aue_dying = 0; done: AUE_UNLOCK(sc); }
static int aue_csr_read_1(pegasus_dev *sc, int reg) { status_t err; uint8 val = 0; size_t length; if (sc->aue_dying) return (0); AUE_LOCK(sc); err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, AUE_UR_READREG, 0, reg, 1, &val, &length); AUE_UNLOCK(sc); if (err) { return (0); } return (val); }
static int aue_csr_write_2(pegasus_dev *sc, int reg, int val) { status_t err; size_t length = 2; if (sc->aue_dying) return (0); AUE_LOCK(sc); err = usb->send_request(sc->dev, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, AUE_UR_WRITEREG, val, reg, 2, &val, &length); AUE_UNLOCK(sc); if (err) { return (-1); } return (0); }