@@ -65,6 +65,11 @@ struct host_if_set_ant {
6565 u8 gpio_mode ;
6666};
6767
68+ struct power_mgmt_param {
69+ bool enabled ;
70+ u32 timeout ;
71+ };
72+
6873struct wilc_del_all_sta {
6974 u8 assoc_sta ;
7075 u8 mac [WILC_MAX_NUM_STA ][ETH_ALEN ];
@@ -79,6 +84,7 @@ union wilc_message_body {
7984 struct host_if_wowlan_trigger wow_trigger ;
8085 struct send_buffered_eap send_buff_eap ;
8186 struct host_if_set_ant set_ant ;
87+ struct power_mgmt_param pwr_mgmt_info ;
8288};
8389
8490struct host_if_msg {
@@ -2347,26 +2353,53 @@ int wilc_edit_station(struct wilc_vif *vif, const u8 *mac,
23472353 return result ;
23482354}
23492355
2350- int wilc_set_power_mgmt (struct wilc_vif * vif , bool enabled , u32 timeout )
2356+ static void handle_power_management (struct work_struct * work )
23512357{
2352- struct wid wid ;
2358+ struct host_if_msg * msg = container_of (work , struct host_if_msg , work );
2359+ struct wilc_vif * vif = msg -> vif ;
2360+ struct power_mgmt_param * pm_param = & msg -> body .pwr_mgmt_info ;
23532361 int result ;
2362+ struct wid wid ;
23542363 s8 power_mode ;
23552364
2356- PRINT_INFO ( vif -> ndev , HOSTINF_DBG , "\n\n>> Setting PS to %d <<\n\n" ,
2357- enabled );
2358- if (enabled )
2365+ wid . id = WID_POWER_MANAGEMENT ;
2366+
2367+ if (pm_param -> enabled )
23592368 power_mode = WILC_FW_MIN_FAST_PS ;
23602369 else
23612370 power_mode = WILC_FW_NO_POWERSAVE ;
2362-
2363- wid . id = WID_POWER_MANAGEMENT ;
2371+ PRINT_INFO ( vif -> ndev , HOSTINF_DBG , "Handling power mgmt to %d\n" ,
2372+ power_mode ) ;
23642373 wid .val = & power_mode ;
23652374 wid .size = sizeof (char );
2375+
2376+ PRINT_INFO (vif -> ndev , HOSTINF_DBG , "Handling Power Management\n" );
23662377 result = wilc_send_config_pkt (vif , WILC_SET_CFG , & wid , 1 );
23672378 if (result )
2368- netdev_err (vif -> ndev , "Failed to send power management\n" );
2379+ PRINT_ER (vif -> ndev , "Failed to send power management\n" );
2380+
2381+ kfree (msg );
2382+ }
23692383
2384+ int wilc_set_power_mgmt (struct wilc_vif * vif , bool enabled , u32 timeout )
2385+ {
2386+ int result ;
2387+ struct host_if_msg * msg ;
2388+
2389+ PRINT_INFO (vif -> ndev , HOSTINF_DBG , "\n\n>> Setting PS to %d <<\n\n" ,
2390+ enabled );
2391+ msg = wilc_alloc_work (vif , handle_power_management , false);
2392+ if (IS_ERR (msg ))
2393+ return PTR_ERR (msg );
2394+
2395+ msg -> body .pwr_mgmt_info .enabled = enabled ;
2396+ msg -> body .pwr_mgmt_info .timeout = timeout ;
2397+
2398+ result = wilc_enqueue_work (msg );
2399+ if (result ) {
2400+ PRINT_ER (vif -> ndev , "enqueue work failed\n" );
2401+ kfree (msg );
2402+ }
23702403 return result ;
23712404}
23722405
0 commit comments