staging: csr: Replace wakelock code with wakeup sources
PATCH 1/1 staging: csr: Replace wakelock code with wakeup sources
--- drivers/staging/csr/drv.c | 8 ++++---- drivers/staging/csr/sdio_mmc.c | 23 +++++++---------------- drivers/staging/csr/sme_sys.c | 18 +++++++++--------- drivers/staging/csr/unifi_priv.h | 8 -------- 4 files changed, 20 insertions(+), 37 deletions(-)
drivers/staging/csr/drv.c +4 -4
@@ -67,6 +67,8 @@ int bh_priority = -1;int log_hip_signals =0 ;#endif +extern struct wakeup_source unifi_sdio_wakeup_source; +MODULE_DESCRIPTION ("CSR UniFi (SDIO)" );module_param (buswidth, int,S_IRUGO |S_IWUSR );
@@ -1330,11 +1332,9 @@ unifi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)unifi_info (priv,"UniFi ready\n" ); -#ifdef ANDROID_BUILD -/* Release the wakelock */ unifi_trace (priv,UDBG1 ,"netdev_init: release wake lock\n" ); -wake_unlock (&unifi_sdio_wake_lock); -#endif +__pm_relax (&unifi_sdio_wakeup_source); +#ifdef CSR_NATIVE_SOFTMAC /* For softmac dev, force-enable the network interface rather than wait for a connected-ind */ {struct net_device *dev = priv->netdev[interfaceTag];
drivers/staging/csr/sdio_mmc.c +7 -16
@@ -25,9 +25,8 @@#include "unifi_priv.h" -#ifdef ANDROID_BUILD -struct wake_lock unifi_sdio_wake_lock;/* wakelock to prevent suspend while resuming */ -#endif +/* To prevent suspend while resuming */ +static struct wakeup_source unifi_sdio_wakeup_source;static CsrSdioFunctionDriver *sdio_func_drv;
@@ -1097,11 +1096,9 @@ uf_glue_sdio_probe(struct sdio_func *func,/* We have finished, so release the SDIO driver */ sdio_release_host (func); -#ifdef ANDROID_BUILD -/* Take the wakelock */ +/* Initialize wakeup event */ unifi_trace (NULL ,UDBG1 ,"probe: take wake lock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source);func_exit ();return 0 ;
@@ -1212,10 +1209,8 @@ uf_glue_sdio_resume(struct device *dev)unifi_trace (NULL ,UDBG1 ,"uf_glue_sdio_resume" ); -#ifdef ANDROID_BUILD unifi_trace (NULL ,UDBG1 ,"resume: take wakelock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source);func_exit ();return 0 ;
@@ -1272,9 +1267,7 @@ CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *sdio_drv)return CSR_SDIO_RESULT_INVALID_VALUE ; } -#ifdef ANDROID_BUILD -wake_lock_init (&unifi_sdio_wake_lock,WAKE_LOCK_SUSPEND ,"unifi_sdio_work" ); -#endif +wakeup_source_init (&unifi_sdio_wakeup_source,"unifi_sdio_work" );/* Save the registered driver description */ /*
@@ -1306,9 +1299,7 @@ CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *sdio_drv) {printk (KERN_INFO "UniFi: unregister from MMC sdio\n" ); -#ifdef ANDROID_BUILD -wake_lock_destroy (&unifi_sdio_wake_lock); -#endif +wakeup_source_remove (&unifi_sdio_wakeup_source);sdio_unregister_driver (&unifi_driver); sdio_func_drv =NULL ;
drivers/staging/csr/sme_sys.c +9 -9
@@ -22,6 +22,8 @@#include "csr_wifi_sme_sef.h" #endif +extern struct wakeup_source unifi_sdio_wakeup_source; +/* * This file implements the SME SYS API and contains the following functions: * CsrWifiRouterCtrlMediaStatusReqHandler()
@@ -735,11 +737,11 @@ void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)if ( priv->wol_suspend ) {unifi_trace (priv,UDBG1 ,"CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n" ); }else { -#ifdef ANDROID_BUILD +/* Take the wakelock while Wi-Fi On is in progress */ unifi_trace (priv,UDBG1 ,"CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source); +for (i=0 ; i<CSR_WIFI_NUM_INTERFACES ; i++) {unifi_trace (priv,UDBG1 ,"CsrWifiRouterCtrlWifiOnReqHandler: Setting interface %d to NONE\n" , i );
@@ -1172,11 +1174,10 @@ void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg)#endif unifi_info (priv,"UniFi ready\n" ); -#ifdef ANDROID_BUILD /* Release the wakelock */ unifi_trace (priv,UDBG1 ,"ready: release wake lock\n" ); -wake_unlock (&unifi_sdio_wake_lock); -#endif +__pm_relax (&unifi_sdio_wakeup_source); +/* Firmware initialisation is complete, so let the SDIO bus * clock be raised when convienent to the core. */
@@ -1812,11 +1813,10 @@ void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)CsrWifiRouterCtrlVersions versions;int r; -#ifdef ANDROID_BUILD /* Take the wakelock while switching patch */ unifi_trace (priv,UDBG1 ,"patch switch: take wake lock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source); +unifi_info (priv,"Resetting UniFi with %s patch\n" ,CSR_WIFI_HIP_IS_AP_FW (req->mode) ?"AP" :"STA" ); r =uf_request_firmware_files (priv,UNIFI_FW_STA );
drivers/staging/csr/unifi_priv.h +0 -8
@@ -42,10 +42,6 @@#include <linux/fs.h> -#ifdef ANDROID_BUILD -#include <linux/wakelock.h> -#endif -#include "csr_wifi_hip_unifi.h" #include "csr_wifi_hip_unifi_udi.h" #include "csr_wifi_router_lib.h"
@@ -65,10 +61,6 @@ typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;#include "unifi_wext.h" #endif -#ifdef ANDROID_BUILD -extern struct wake_lock unifi_sdio_wake_lock; -#endif -#include "unifi_clients.h" #ifdef CSR_NATIVE_LINUX
Signature · 1 line
1.7.12
Greg Kroah-Hartman
maintainerQuoted 1 line · Priit Laes
Signed-off-by Priit Laes <[email protected]>
Why?
Please be more dscriptive in the changelog entry for the patch, care to redo this and resend it?
thanks,
greg k-h
PATCH v2 1/1 staging: csr: Replace wakelocks with wakeup interface
In reply to Priit LaesWakelocks are an Android-specific API that never made into mainline. Eventually power management wakeup interface appeared, therefore use this interface instead.
--- drivers/staging/csr/drv.c | 8 ++++---- drivers/staging/csr/sdio_mmc.c | 23 +++++++---------------- drivers/staging/csr/sme_sys.c | 18 +++++++++--------- drivers/staging/csr/unifi_priv.h | 8 -------- 4 files changed, 20 insertions(+), 37 deletions(-)
drivers/staging/csr/drv.c +4 -4
@@ -67,6 +67,8 @@ int bh_priority = -1;int log_hip_signals =0 ;#endif +extern struct wakeup_source unifi_sdio_wakeup_source; +MODULE_DESCRIPTION ("CSR UniFi (SDIO)" );module_param (buswidth, int,S_IRUGO |S_IWUSR );
@@ -1330,11 +1332,9 @@ unifi_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)unifi_info (priv,"UniFi ready\n" ); -#ifdef ANDROID_BUILD -/* Release the wakelock */ unifi_trace (priv,UDBG1 ,"netdev_init: release wake lock\n" ); -wake_unlock (&unifi_sdio_wake_lock); -#endif +__pm_relax (&unifi_sdio_wakeup_source); +#ifdef CSR_NATIVE_SOFTMAC /* For softmac dev, force-enable the network interface rather than wait for a connected-ind */ {struct net_device *dev = priv->netdev[interfaceTag];
drivers/staging/csr/sdio_mmc.c +7 -16
@@ -25,9 +25,8 @@#include "unifi_priv.h" -#ifdef ANDROID_BUILD -struct wake_lock unifi_sdio_wake_lock;/* wakelock to prevent suspend while resuming */ -#endif +/* To prevent suspend while resuming */ +static struct wakeup_source unifi_sdio_wakeup_source;static CsrSdioFunctionDriver *sdio_func_drv;
@@ -1097,11 +1096,9 @@ uf_glue_sdio_probe(struct sdio_func *func,/* We have finished, so release the SDIO driver */ sdio_release_host (func); -#ifdef ANDROID_BUILD -/* Take the wakelock */ +/* Initialize wakeup event */ unifi_trace (NULL ,UDBG1 ,"probe: take wake lock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source);func_exit ();return 0 ;
@@ -1212,10 +1209,8 @@ uf_glue_sdio_resume(struct device *dev)unifi_trace (NULL ,UDBG1 ,"uf_glue_sdio_resume" ); -#ifdef ANDROID_BUILD unifi_trace (NULL ,UDBG1 ,"resume: take wakelock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source);func_exit ();return 0 ;
@@ -1272,9 +1267,7 @@ CsrSdioFunctionDriverRegister(CsrSdioFunctionDriver *sdio_drv)return CSR_SDIO_RESULT_INVALID_VALUE ; } -#ifdef ANDROID_BUILD -wake_lock_init (&unifi_sdio_wake_lock,WAKE_LOCK_SUSPEND ,"unifi_sdio_work" ); -#endif +wakeup_source_init (&unifi_sdio_wakeup_source,"unifi_sdio_work" );/* Save the registered driver description */ /*
@@ -1306,9 +1299,7 @@ CsrSdioFunctionDriverUnregister(CsrSdioFunctionDriver *sdio_drv) {printk (KERN_INFO "UniFi: unregister from MMC sdio\n" ); -#ifdef ANDROID_BUILD -wake_lock_destroy (&unifi_sdio_wake_lock); -#endif +wakeup_source_remove (&unifi_sdio_wakeup_source);sdio_unregister_driver (&unifi_driver); sdio_func_drv =NULL ;
drivers/staging/csr/sme_sys.c +9 -9
@@ -22,6 +22,8 @@#include "csr_wifi_sme_sef.h" #endif +extern struct wakeup_source unifi_sdio_wakeup_source; +/* * This file implements the SME SYS API and contains the following functions: * CsrWifiRouterCtrlMediaStatusReqHandler()
@@ -735,11 +737,11 @@ void CsrWifiRouterCtrlWifiOnReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)if ( priv->wol_suspend ) {unifi_trace (priv,UDBG1 ,"CsrWifiRouterCtrlWifiOnReqHandler: Don't reset mode\n" ); }else { -#ifdef ANDROID_BUILD +/* Take the wakelock while Wi-Fi On is in progress */ unifi_trace (priv,UDBG1 ,"CsrWifiRouterCtrlWifiOnReqHandler: take wake lock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source); +for (i=0 ; i<CSR_WIFI_NUM_INTERFACES ; i++) {unifi_trace (priv,UDBG1 ,"CsrWifiRouterCtrlWifiOnReqHandler: Setting interface %d to NONE\n" , i );
@@ -1172,11 +1174,10 @@ void CsrWifiRouterCtrlWifiOnResHandler(void* drvpriv, CsrWifiFsmEvent* msg)#endif unifi_info (priv,"UniFi ready\n" ); -#ifdef ANDROID_BUILD /* Release the wakelock */ unifi_trace (priv,UDBG1 ,"ready: release wake lock\n" ); -wake_unlock (&unifi_sdio_wake_lock); -#endif +__pm_relax (&unifi_sdio_wakeup_source); +/* Firmware initialisation is complete, so let the SDIO bus * clock be raised when convienent to the core. */
@@ -1812,11 +1813,10 @@ void CsrWifiRouterCtrlModeSetReqHandler(void* drvpriv, CsrWifiFsmEvent* msg)CsrWifiRouterCtrlVersions versions;int r; -#ifdef ANDROID_BUILD /* Take the wakelock while switching patch */ unifi_trace (priv,UDBG1 ,"patch switch: take wake lock\n" ); -wake_lock (&unifi_sdio_wake_lock); -#endif +__pm_stay_awake (&unifi_sdio_wakeup_source); +unifi_info (priv,"Resetting UniFi with %s patch\n" ,CSR_WIFI_HIP_IS_AP_FW (req->mode) ?"AP" :"STA" ); r =uf_request_firmware_files (priv,UNIFI_FW_STA );
drivers/staging/csr/unifi_priv.h +0 -8
@@ -42,10 +42,6 @@#include <linux/fs.h> -#ifdef ANDROID_BUILD -#include <linux/wakelock.h> -#endif -#include "csr_wifi_hip_unifi.h" #include "csr_wifi_hip_unifi_udi.h" #include "csr_wifi_router_lib.h"
@@ -65,10 +61,6 @@ typedef struct CsrWifiSmeApConfig CsrWifiSmeApConfig_t;#include "unifi_wext.h" #endif -#ifdef ANDROID_BUILD -extern struct wake_lock unifi_sdio_wake_lock; -#endif -#include "unifi_clients.h" #ifdef CSR_NATIVE_LINUX
Signature · 1 line
1.7.12
Greg Kroah-Hartman
maintainerRe: [PATCH v2] staging: csr: Replace wakelocks with wakeup interface
Quoted 17 lines · Priit Laes
Wakelocks are an Android-specific API that never made into mainline. Eventually power management wakeup interface appeared, therefore use this interface instead.
Signed-off-by Priit Laes <[email protected]>--- drivers/staging/csr/drv.c | 8 ++++---- drivers/staging/csr/sdio_mmc.c | 23 +++++++---------------- drivers/staging/csr/sme_sys.c | 18 +++++++++--------- drivers/staging/csr/unifi_priv.h | 8 -------- 4 files changed, 20 insertions(+), 37 deletions(-)drivers/staging/csr/drv.c +0
-0
drivers/staging/csr/drv.c int bh_priority = -1; · line 70
Quoted 4 lines
drivers/staging/csr/drv.c +1
-0@@ -67,6 +67,8 @@ int bh_priority = -1;int log_hip_signals =0 ;#endif +extern struct wakeup_source unifi_sdio_wakeup_source;
You obviously didn't run scripts/checkpatch.pl against this patch, did you?
Never put an extern in a .c file, put this in a .h file so that all .c files can access it properly.
Care to fix this up and resend?
thanks,
greg k-h