Skip to content

Commit 90188f8

Browse files
Raja Manikvalo
authored andcommitted
ath10k: pull reusable code from pci probe and remove for ahb
Some of the code present in ath10k_pci_{probe|remove} are reusable in ahb case too. To avoid code duplication, move reusable code to new functions. Later, those new functions can be called from ahb module's probe and exit functions. Signed-off-by: Raja Mani <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 4ddb329 commit 90188f8

File tree

2 files changed

+44
-22
lines changed

2 files changed

+44
-22
lines changed

drivers/net/wireless/ath/ath10k/pci.c

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,6 +3009,37 @@ static bool ath10k_pci_chip_is_supported(u32 dev_id, u32 chip_id)
30093009
return false;
30103010
}
30113011

3012+
int ath10k_pci_setup_resource(struct ath10k *ar)
3013+
{
3014+
struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
3015+
int ret;
3016+
3017+
spin_lock_init(&ar_pci->ce_lock);
3018+
spin_lock_init(&ar_pci->ps_lock);
3019+
3020+
setup_timer(&ar_pci->rx_post_retry, ath10k_pci_rx_replenish_retry,
3021+
(unsigned long)ar);
3022+
3023+
if (QCA_REV_6174(ar))
3024+
ath10k_pci_override_ce_config(ar);
3025+
3026+
ret = ath10k_pci_alloc_pipes(ar);
3027+
if (ret) {
3028+
ath10k_err(ar, "failed to allocate copy engine pipes: %d\n",
3029+
ret);
3030+
return ret;
3031+
}
3032+
3033+
return 0;
3034+
}
3035+
3036+
void ath10k_pci_release_resource(struct ath10k *ar)
3037+
{
3038+
ath10k_pci_kill_tasklet(ar);
3039+
ath10k_pci_ce_deinit(ar);
3040+
ath10k_pci_free_pipes(ar);
3041+
}
3042+
30123043
static const struct ath10k_bus_ops ath10k_pci_bus_ops = {
30133044
.read32 = ath10k_bus_pci_read32,
30143045
.write32 = ath10k_bus_pci_write32,
@@ -3072,34 +3103,25 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
30723103
ar->id.subsystem_vendor = pdev->subsystem_vendor;
30733104
ar->id.subsystem_device = pdev->subsystem_device;
30743105

3075-
spin_lock_init(&ar_pci->ce_lock);
3076-
spin_lock_init(&ar_pci->ps_lock);
3077-
3078-
setup_timer(&ar_pci->rx_post_retry, ath10k_pci_rx_replenish_retry,
3079-
(unsigned long)ar);
30803106
setup_timer(&ar_pci->ps_timer, ath10k_pci_ps_timer,
30813107
(unsigned long)ar);
30823108

3083-
ret = ath10k_pci_claim(ar);
3109+
ret = ath10k_pci_setup_resource(ar);
30843110
if (ret) {
3085-
ath10k_err(ar, "failed to claim device: %d\n", ret);
3111+
ath10k_err(ar, "failed to setup resource: %d\n", ret);
30863112
goto err_core_destroy;
30873113
}
30883114

3089-
if (QCA_REV_6174(ar))
3090-
ath10k_pci_override_ce_config(ar);
3091-
3092-
ret = ath10k_pci_alloc_pipes(ar);
3115+
ret = ath10k_pci_claim(ar);
30933116
if (ret) {
3094-
ath10k_err(ar, "failed to allocate copy engine pipes: %d\n",
3095-
ret);
3096-
goto err_sleep;
3117+
ath10k_err(ar, "failed to claim device: %d\n", ret);
3118+
goto err_free_pipes;
30973119
}
30983120

30993121
ret = ath10k_pci_force_wake(ar);
31003122
if (ret) {
31013123
ath10k_warn(ar, "failed to wake up device : %d\n", ret);
3102-
goto err_free_pipes;
3124+
goto err_sleep;
31033125
}
31043126

31053127
ath10k_pci_ce_deinit(ar);
@@ -3108,7 +3130,7 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
31083130
ret = ath10k_pci_init_irq(ar);
31093131
if (ret) {
31103132
ath10k_err(ar, "failed to init irqs: %d\n", ret);
3111-
goto err_free_pipes;
3133+
goto err_sleep;
31123134
}
31133135

31143136
ath10k_info(ar, "pci irq %s interrupts %d irq_mode %d reset_mode %d\n",
@@ -3154,13 +3176,13 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
31543176
err_deinit_irq:
31553177
ath10k_pci_deinit_irq(ar);
31563178

3157-
err_free_pipes:
3158-
ath10k_pci_free_pipes(ar);
3159-
31603179
err_sleep:
31613180
ath10k_pci_sleep_sync(ar);
31623181
ath10k_pci_release(ar);
31633182

3183+
err_free_pipes:
3184+
ath10k_pci_free_pipes(ar);
3185+
31643186
err_core_destroy:
31653187
ath10k_core_destroy(ar);
31663188

@@ -3184,10 +3206,8 @@ static void ath10k_pci_remove(struct pci_dev *pdev)
31843206

31853207
ath10k_core_unregister(ar);
31863208
ath10k_pci_free_irq(ar);
3187-
ath10k_pci_kill_tasklet(ar);
31883209
ath10k_pci_deinit_irq(ar);
3189-
ath10k_pci_ce_deinit(ar);
3190-
ath10k_pci_free_pipes(ar);
3210+
ath10k_pci_release_resource(ar);
31913211
ath10k_pci_sleep_sync(ar);
31923212
ath10k_pci_release(ar);
31933213
ath10k_core_destroy(ar);

drivers/net/wireless/ath/ath10k/pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ void ath10k_pci_enable_legacy_irq(struct ath10k *ar);
292292
bool ath10k_pci_irq_pending(struct ath10k *ar);
293293
void ath10k_pci_disable_and_clear_legacy_irq(struct ath10k *ar);
294294
int ath10k_pci_wait_for_target_init(struct ath10k *ar);
295+
int ath10k_pci_setup_resource(struct ath10k *ar);
296+
void ath10k_pci_release_resource(struct ath10k *ar);
295297

296298
/* QCA6174 is known to have Tx/Rx issues when SOC_WAKE register is poked too
297299
* frequently. To avoid this put SoC to sleep after a very conservative grace

0 commit comments

Comments
 (0)