@@ -149,35 +149,38 @@ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter)
149149 */
150150static int mwifiex_pcie_suspend (struct device * dev )
151151{
152+ struct pci_dev * pdev = to_pci_dev (dev );
153+ struct pcie_service_card * card = pci_get_drvdata (pdev );
152154 struct mwifiex_adapter * adapter ;
153- struct pcie_service_card * card = dev_get_drvdata (dev );
154-
155+ struct mwifiex_private * priv ;
156+ const struct mwifiex_pcie_card_reg * reg ;
157+ u32 fw_status ;
158+ int ret ;
155159
156160 /* Might still be loading firmware */
157161 wait_for_completion (& card -> fw_done );
158162
159163 adapter = card -> adapter ;
160- if (!adapter ) {
161- dev_err (dev , "adapter is not valid\n" );
164+ if (!adapter || !adapter -> priv_num )
162165 return 0 ;
163- }
164166
165- mwifiex_enable_wake (adapter );
167+ reg = card -> pcie .reg ;
168+ if (reg )
169+ ret = mwifiex_read_reg (adapter , reg -> fw_status , & fw_status );
170+ else
171+ fw_status = -1 ;
172+
173+ if (fw_status == FIRMWARE_READY_PCIE && !adapter -> mfg_mode ) {
174+ mwifiex_deauthenticate_all (adapter );
166175
167- /* Enable the Host Sleep */
168- if (!mwifiex_enable_hs (adapter )) {
169- mwifiex_dbg (adapter , ERROR ,
170- "cmd: failed to suspend\n" );
171- clear_bit (MWIFIEX_IS_HS_ENABLING , & adapter -> work_flags );
172- mwifiex_disable_wake (adapter );
173- return - EFAULT ;
174- }
176+ priv = mwifiex_get_priv (adapter , MWIFIEX_BSS_ROLE_ANY );
175177
176- flush_workqueue ( adapter -> workqueue );
178+ mwifiex_disable_auto_ds ( priv );
177179
178- /* Indicate device suspended */
179- set_bit (MWIFIEX_IS_SUSPENDED , & adapter -> work_flags );
180- clear_bit (MWIFIEX_IS_HS_ENABLING , & adapter -> work_flags );
180+ mwifiex_init_shutdown_fw (priv , MWIFIEX_FUNC_SHUTDOWN );
181+ }
182+
183+ mwifiex_remove_card (adapter );
181184
182185 return 0 ;
183186}
@@ -192,28 +195,29 @@ static int mwifiex_pcie_suspend(struct device *dev)
192195 */
193196static int mwifiex_pcie_resume (struct device * dev )
194197{
195- struct mwifiex_adapter * adapter ;
196- struct pcie_service_card * card = dev_get_drvdata (dev );
198+ struct pci_dev * pdev = to_pci_dev (dev );
199+ struct pcie_service_card * card = pci_get_drvdata (pdev );
200+ int ret ;
197201
202+ pr_debug ("info: vendor=0x%4.04X device=0x%4.04X rev=%d\n" ,
203+ pdev -> vendor , pdev -> device , pdev -> revision );
198204
199- if (!card -> adapter ) {
200- dev_err (dev , "adapter structure is not valid\n" );
201- return 0 ;
202- }
205+ init_completion (& card -> fw_done );
203206
204- adapter = card -> adapter ;
207+ card -> dev = pdev ;
205208
206- if (!test_bit (MWIFIEX_IS_SUSPENDED , & adapter -> work_flags )) {
207- mwifiex_dbg (adapter , WARN ,
208- "Device already resumed\n" );
209- return 0 ;
209+ /* device tree node parsing and platform specific configuration */
210+ if (pdev -> dev .of_node ) {
211+ ret = mwifiex_pcie_probe_of (& pdev -> dev );
212+ if (ret )
213+ return ret ;
210214 }
211215
212- clear_bit ( MWIFIEX_IS_SUSPENDED , & adapter -> work_flags );
213-
214- mwifiex_cancel_hs ( mwifiex_get_priv ( adapter , MWIFIEX_BSS_ROLE_STA ),
215- MWIFIEX_ASYNC_CMD ) ;
216- mwifiex_disable_wake ( adapter );
216+ if ( mwifiex_add_card ( card , & card -> fw_done , & pcie_ops ,
217+ MWIFIEX_PCIE , & pdev -> dev )) {
218+ pr_err ( "%s failed\n" , __func__ );
219+ return -1 ;
220+ }
217221
218222 return 0 ;
219223}
@@ -267,6 +271,8 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev,
267271 return -1 ;
268272 }
269273
274+ pdev -> bus -> self -> bridge_d3 = false;
275+
270276 return 0 ;
271277}
272278
0 commit comments