@@ -3473,25 +3473,60 @@ int ath10k_pci_setup_resource(struct ath10k *ar)
34733473
34743474 timer_setup (& ar_pci -> rx_post_retry , ath10k_pci_rx_replenish_retry , 0 );
34753475
3476+ ar_pci -> attr = kmemdup (pci_host_ce_config_wlan ,
3477+ sizeof (pci_host_ce_config_wlan ),
3478+ GFP_KERNEL );
3479+ if (!ar_pci -> attr )
3480+ return - ENOMEM ;
3481+
3482+ ar_pci -> pipe_config = kmemdup (pci_target_ce_config_wlan ,
3483+ sizeof (pci_target_ce_config_wlan ),
3484+ GFP_KERNEL );
3485+ if (!ar_pci -> pipe_config ) {
3486+ ret = - ENOMEM ;
3487+ goto err_free_attr ;
3488+ }
3489+
3490+ ar_pci -> serv_to_pipe = kmemdup (pci_target_service_to_ce_map_wlan ,
3491+ sizeof (pci_target_service_to_ce_map_wlan ),
3492+ GFP_KERNEL );
3493+ if (!ar_pci -> serv_to_pipe ) {
3494+ ret = - ENOMEM ;
3495+ goto err_free_pipe_config ;
3496+ }
3497+
34763498 if (QCA_REV_6174 (ar ) || QCA_REV_9377 (ar ))
34773499 ath10k_pci_override_ce_config (ar );
34783500
34793501 ret = ath10k_pci_alloc_pipes (ar );
34803502 if (ret ) {
34813503 ath10k_err (ar , "failed to allocate copy engine pipes: %d\n" ,
34823504 ret );
3483- return ret ;
3505+ goto err_free_serv_to_pipe ;
34843506 }
34853507
34863508 return 0 ;
3509+
3510+ err_free_serv_to_pipe :
3511+ kfree (ar_pci -> serv_to_pipe );
3512+ err_free_pipe_config :
3513+ kfree (ar_pci -> pipe_config );
3514+ err_free_attr :
3515+ kfree (ar_pci -> attr );
3516+ return ret ;
34873517}
34883518
34893519void ath10k_pci_release_resource (struct ath10k * ar )
34903520{
3521+ struct ath10k_pci * ar_pci = ath10k_pci_priv (ar );
3522+
34913523 ath10k_pci_rx_retry_sync (ar );
34923524 netif_napi_del (& ar -> napi );
34933525 ath10k_pci_ce_deinit (ar );
34943526 ath10k_pci_free_pipes (ar );
3527+ kfree (ar_pci -> attr );
3528+ kfree (ar_pci -> pipe_config );
3529+ kfree (ar_pci -> serv_to_pipe );
34953530}
34963531
34973532static const struct ath10k_bus_ops ath10k_pci_bus_ops = {
@@ -3601,30 +3636,6 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
36013636
36023637 timer_setup (& ar_pci -> ps_timer , ath10k_pci_ps_timer , 0 );
36033638
3604- ar_pci -> attr = kmemdup (pci_host_ce_config_wlan ,
3605- sizeof (pci_host_ce_config_wlan ),
3606- GFP_KERNEL );
3607- if (!ar_pci -> attr ) {
3608- ret = - ENOMEM ;
3609- goto err_free ;
3610- }
3611-
3612- ar_pci -> pipe_config = kmemdup (pci_target_ce_config_wlan ,
3613- sizeof (pci_target_ce_config_wlan ),
3614- GFP_KERNEL );
3615- if (!ar_pci -> pipe_config ) {
3616- ret = - ENOMEM ;
3617- goto err_free ;
3618- }
3619-
3620- ar_pci -> serv_to_pipe = kmemdup (pci_target_service_to_ce_map_wlan ,
3621- sizeof (pci_target_service_to_ce_map_wlan ),
3622- GFP_KERNEL );
3623- if (!ar_pci -> serv_to_pipe ) {
3624- ret = - ENOMEM ;
3625- goto err_free ;
3626- }
3627-
36283639 ret = ath10k_pci_setup_resource (ar );
36293640 if (ret ) {
36303641 ath10k_err (ar , "failed to setup resource: %d\n" , ret );
@@ -3705,10 +3716,9 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
37053716
37063717err_free_irq :
37073718 ath10k_pci_free_irq (ar );
3708- ath10k_pci_rx_retry_sync (ar );
37093719
37103720err_deinit_irq :
3711- ath10k_pci_deinit_irq (ar );
3721+ ath10k_pci_release_resource (ar );
37123722
37133723err_sleep :
37143724 ath10k_pci_sleep_sync (ar );
@@ -3720,39 +3730,25 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
37203730err_core_destroy :
37213731 ath10k_core_destroy (ar );
37223732
3723- err_free :
3724- kfree (ar_pci -> attr );
3725- kfree (ar_pci -> pipe_config );
3726- kfree (ar_pci -> serv_to_pipe );
3727-
37283733 return ret ;
37293734}
37303735
37313736static void ath10k_pci_remove (struct pci_dev * pdev )
37323737{
37333738 struct ath10k * ar = pci_get_drvdata (pdev );
3734- struct ath10k_pci * ar_pci ;
37353739
37363740 ath10k_dbg (ar , ATH10K_DBG_PCI , "pci remove\n" );
37373741
37383742 if (!ar )
37393743 return ;
37403744
3741- ar_pci = ath10k_pci_priv (ar );
3742-
3743- if (!ar_pci )
3744- return ;
3745-
37463745 ath10k_core_unregister (ar );
37473746 ath10k_pci_free_irq (ar );
37483747 ath10k_pci_deinit_irq (ar );
37493748 ath10k_pci_release_resource (ar );
37503749 ath10k_pci_sleep_sync (ar );
37513750 ath10k_pci_release (ar );
37523751 ath10k_core_destroy (ar );
3753- kfree (ar_pci -> attr );
3754- kfree (ar_pci -> pipe_config );
3755- kfree (ar_pci -> serv_to_pipe );
37563752}
37573753
37583754MODULE_DEVICE_TABLE (pci , ath10k_pci_id_table );
0 commit comments