static int rt_pci_resume(struct pci_dev *pci_dev) { struct net_device *net_dev = pci_get_drvdata(pci_dev); VOID *pAd = NULL; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10) INT32 retval; /* Set the power state of a PCI device PCI has 4 power states, DO (normal) ~ D3(less power) you can find that in include/linux/pci.h #define PCI_D0 ((pci_power_t __force) 0) #define PCI_D1 ((pci_power_t __force) 1) #define PCI_D2 ((pci_power_t __force) 2) #define PCI_D3hot ((pci_power_t __force) 3) #define PCI_D3cold ((pci_power_t __force) 4) #define PCI_UNKNOWN ((pci_power_t __force) 5) #define PCI_POWER_ERROR ((pci_power_t __force) -1) */ retval = pci_set_power_state(pci_dev, PCI_D0); /* restore the saved state of a PCI device */ pci_restore_state(pci_dev); /* initialize device before it's used by a driver */ if (pci_enable_device(pci_dev)) { printk("pci enable fail!\n"); return 0; } #endif DBGPRINT(RT_DEBUG_TRACE, ("===>%s()\n", __FUNCTION__)); if (net_dev == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n")); } else GET_PAD_FROM_NET_DEV(pAd, net_dev); if (pAd != NULL) { ULONG IfNum; /* we can not use IFF_UP because ra0 down but ra1 up and 1 suspend/resume function for 1 module, not for each interface so Linux will call suspend/resume function once */ RTMP_DRIVER_VIRTUAL_INF_NUM_GET(pAd, &IfNum); if (IfNum > 0) /* if (VIRTUAL_IF_NUM(pAd) > 0) */ { /* mark device as attached from system and restart if needed */ netif_device_attach(net_dev); if (rt28xx_open((PNET_DEV)net_dev) != 0) { /* open fail */ DBGPRINT(RT_DEBUG_TRACE, ("<===%s()\n", __FUNCTION__)); return 0; } /* increase MODULE use count */ RT_MOD_INC_USE_COUNT(); /* RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); */ /* RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); */ RTMP_DRIVER_PCI_RESUME(pAd); netif_start_queue(net_dev); netif_carrier_on(net_dev); netif_wake_queue(net_dev); } } DBGPRINT(RT_DEBUG_TRACE, ("<=== %s()\n", __FUNCTION__)); return 0; }
static int rt2860_resume( struct pci_dev *pci_dev) { struct net_device *net_dev = pci_get_drvdata(pci_dev); PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL; #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,10) INT32 retval; // set the power state of a PCI device // PCI has 4 power states, DO (normal) ~ D3(less power) // in include/linux/pci.h, you can find that // #define PCI_D0 ((pci_power_t __force) 0) // #define PCI_D1 ((pci_power_t __force) 1) // #define PCI_D2 ((pci_power_t __force) 2) // #define PCI_D3hot ((pci_power_t __force) 3) // #define PCI_D3cold ((pci_power_t __force) 4) // #define PCI_UNKNOWN ((pci_power_t __force) 5) // #define PCI_POWER_ERROR ((pci_power_t __force) -1) retval = pci_set_power_state(pci_dev, PCI_D0); // restore the saved state of a PCI device pci_restore_state(pci_dev); // initialize device before it's used by a driver if (pci_enable_device(pci_dev)) { printk("pci enable fail!\n"); return 0; } #endif DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_resume()\n")); if (net_dev == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n")); } else GET_PAD_FROM_NET_DEV(pAd, net_dev); if (pAd != NULL) { /* we can not use IFF_UP because ra0 down but ra1 up */ /* and 1 suspend/resume function for 1 module, not for each interface */ /* so Linux will call suspend/resume function once */ if (VIRTUAL_IF_NUM(pAd) > 0) { // mark device as attached from system and restart if needed netif_device_attach(net_dev); if (rt28xx_open((PNET_DEV)net_dev) != 0) { // open fail DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_resume()\n")); return 0; } // increase MODULE use count RT_MOD_INC_USE_COUNT(); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); netif_start_queue(net_dev); netif_carrier_on(net_dev); netif_wake_queue(net_dev); } } DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_resume()\n")); return 0; }
static int rt2860_resume( struct pci_dev *pci_dev) { struct net_device *net_dev = pci_get_drvdata(pci_dev); PRTMP_ADAPTER pAd = (PRTMP_ADAPTER)NULL; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10) INT32 retval; retval = pci_set_power_state(pci_dev, PCI_D0); pci_restore_state(pci_dev); if (pci_enable_device(pci_dev)) { printk("pci enable fail!\n"); return 0; } #endif DBGPRINT(RT_DEBUG_TRACE, ("===> rt2860_resume()\n")); if (net_dev == NULL) { DBGPRINT(RT_DEBUG_ERROR, ("net_dev == NULL!\n")); } else pAd = (PRTMP_ADAPTER)RTMP_OS_NETDEV_GET_PRIV(net_dev); if (pAd != NULL) { if (VIRTUAL_IF_NUM(pAd) > 0) { netif_device_attach(net_dev); if (rt28xx_open((PNET_DEV)net_dev) != 0) { DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_resume()\n")); return 0; } RT_MOD_INC_USE_COUNT(); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_HALT_IN_PROGRESS); RTMP_CLEAR_FLAG(pAd, fRTMP_ADAPTER_RADIO_OFF); netif_start_queue(net_dev); netif_carrier_on(net_dev); netif_wake_queue(net_dev); } } DBGPRINT(RT_DEBUG_TRACE, ("<=== rt2860_resume()\n")); return 0; }