/* * Probe a i2400m interface and register it * * @iface: USB interface to link to * @id: USB class/subclass/protocol id * @returns: 0 if ok, < 0 errno code on error. * * Alloc a net device, initialize the bus-specific details and then * calls the bus-generic initialization routine. That will register * the wimax and netdev devices, upload the firmware [using * _bus_bm_*()], call _bus_dev_start() to finalize the setup of the * communication with the device and then will start to talk to it to * finnish setting it up. */ static int i2400mu_probe(struct usb_interface *iface, const struct usb_device_id *id) { int result; struct net_device *net_dev; struct device *dev = &iface->dev; struct i2400m *i2400m; struct i2400mu *i2400mu; struct usb_device *usb_dev = interface_to_usbdev(iface); if (usb_dev->speed != USB_SPEED_HIGH) dev_err(dev, "device not connected as high speed\n"); /* Allocate instance [calls i2400m_netdev_setup() on it]. */ result = -ENOMEM; net_dev = alloc_netdev(sizeof(*i2400mu), "wmx%d", i2400mu_netdev_setup); if (net_dev == NULL) { dev_err(dev, "no memory for network device instance\n"); goto error_alloc_netdev; } SET_NETDEV_DEV(net_dev, dev); SET_NETDEV_DEVTYPE(net_dev, &i2400mu_type); i2400m = net_dev_to_i2400m(net_dev); i2400mu = container_of(i2400m, struct i2400mu, i2400m); i2400m->wimax_dev.net_dev = net_dev; i2400mu->usb_dev = usb_get_dev(usb_dev); i2400mu->usb_iface = iface; usb_set_intfdata(iface, i2400mu); i2400m->bus_tx_block_size = I2400MU_BLK_SIZE; i2400m->bus_pl_size_max = I2400MU_PL_SIZE_MAX; i2400m->bus_dev_start = i2400mu_bus_dev_start; i2400m->bus_dev_stop = i2400mu_bus_dev_stop; i2400m->bus_tx_kick = i2400mu_bus_tx_kick; i2400m->bus_reset = i2400mu_bus_reset; i2400m->bus_bm_retries = I2400M_BOOT_RETRIES; i2400m->bus_bm_cmd_send = i2400mu_bus_bm_cmd_send; i2400m->bus_bm_wait_for_ack = i2400mu_bus_bm_wait_for_ack; i2400m->bus_fw_names = i2400mu_bus_fw_names; i2400m->bus_bm_mac_addr_impaired = 0; #ifdef CONFIG_PM iface->needs_remote_wakeup = 1; /* autosuspend (15s delay) */ device_init_wakeup(dev, 1); usb_autopm_enable(i2400mu->usb_iface); usb_dev->autosuspend_delay = 15 * HZ; usb_dev->autosuspend_disabled = 0; #endif result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT); if (result < 0) { dev_err(dev, "cannot setup device: %d\n", result); goto error_setup; } result = i2400mu_debugfs_add(i2400mu); if (result < 0) { dev_err(dev, "Can't register i2400mu's debugfs: %d\n", result); goto error_debugfs_add; } return 0; error_debugfs_add: i2400m_release(i2400m); error_setup: usb_set_intfdata(iface, NULL); usb_put_dev(i2400mu->usb_dev); free_netdev(net_dev); error_alloc_netdev: return result; }
/*=========================================================================== METHOD: GobiUSBNetOpen (Public Method) DESCRIPTION: Wrapper to usbnet_open, correctly handling autosuspend Start AutoPM thread (if CONFIG_PM is defined) PARAMETERS pNet [ I ] - Pointer to net device RETURN VALUE: int - 0 for success Negative errno for error ===========================================================================*/ int GobiUSBNetOpen( struct net_device * pNet ) { int status = 0; struct sGobiUSBNet * pGobiDev; struct usbnet * pDev = netdev_priv( pNet ); if (pDev == NULL) { DBG( "failed to get usbnet device\n" ); return -ENXIO; } pGobiDev = (sGobiUSBNet *)pDev->data[0]; if (pGobiDev == NULL) { DBG( "failed to get QMIDevice\n" ); return -ENXIO; } DBG( "\n" ); #ifdef CONFIG_PM // Start the AutoPM thread pGobiDev->mAutoPM.mpIntf = pGobiDev->mpIntf; pGobiDev->mAutoPM.mbExit = false; pGobiDev->mAutoPM.mpURBList = NULL; pGobiDev->mAutoPM.mpActiveURB = NULL; spin_lock_init( &pGobiDev->mAutoPM.mURBListLock ); spin_lock_init( &pGobiDev->mAutoPM.mActiveURBLock ); atomic_set( &pGobiDev->mAutoPM.mURBListLen, 0 ); init_completion( &pGobiDev->mAutoPM.mThreadDoWork ); pGobiDev->mAutoPM.mpThread = kthread_run( GobiUSBNetAutoPMThread, &pGobiDev->mAutoPM, "GobiUSBNetAutoPMThread" ); if (IS_ERR( pGobiDev->mAutoPM.mpThread )) { DBG( "AutoPM thread creation error\n" ); return PTR_ERR( pGobiDev->mAutoPM.mpThread ); } #endif /* CONFIG_PM */ // Allow traffic GobiClearDownReason( pGobiDev, NET_IFACE_STOPPED ); // Pass to usbnet_open if defined if (pGobiDev->mpUSBNetOpen != NULL) { status = pGobiDev->mpUSBNetOpen( pNet ); #ifdef CONFIG_PM // If usbnet_open was successful enable Auto PM if (status == 0) { #if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) usb_autopm_enable( pGobiDev->mpIntf ); #else usb_autopm_put_interface( pGobiDev->mpIntf ); #endif } #endif /* CONFIG_PM */ } else { DBG( "no USBNetOpen defined\n" ); } return status; }
void rts51x_try_to_enter_ss(struct rts51x_chip *chip) { RTS51X_DEBUGP("Ready to enter SS state\n"); usb_autopm_enable(chip->usb->pusb_intf); }