Currently, the 'dev' pointer is stored in the HAL object, but this is redundant because the HAL object is part of the 'ab' device handle, which already contains a reference to 'dev'. Remove the duplicate 'dev' pointer from the HAL object and update any 'hal->dev' accesses to use the reference in 'ab' instead. Also, pass the device handle 'ab' to ath12k_warn() rather than the HAL object. Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1 Signed-off-by: Karthikeyan Periyasamy --- drivers/net/wireless/ath/ath12k/hal.c | 14 ++++++++------ drivers/net/wireless/ath/ath12k/hal.h | 1 - drivers/net/wireless/ath/ath12k/wifi7/hal.c | 7 +++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/ath/ath12k/hal.c b/drivers/net/wireless/ath/ath12k/hal.c index 8dafbe44df38..4563a3a1a120 100644 --- a/drivers/net/wireless/ath/ath12k/hal.c +++ b/drivers/net/wireless/ath/ath12k/hal.c @@ -153,10 +153,11 @@ ath12k_hal_get_idle_link_rbm(struct ath12k_hal *hal, u8 device_id) static int ath12k_hal_alloc_cont_rdp(struct ath12k_hal *hal) { + struct ath12k_base *ab = container_of(hal, struct ath12k_base, hal); size_t size; size = sizeof(u32) * HAL_SRNG_RING_ID_MAX; - hal->rdp.vaddr = dma_alloc_coherent(hal->dev, size, &hal->rdp.paddr, + hal->rdp.vaddr = dma_alloc_coherent(ab->dev, size, &hal->rdp.paddr, GFP_KERNEL); if (!hal->rdp.vaddr) return -ENOMEM; @@ -166,23 +167,25 @@ static int ath12k_hal_alloc_cont_rdp(struct ath12k_hal *hal) static void ath12k_hal_free_cont_rdp(struct ath12k_hal *hal) { + struct ath12k_base *ab = container_of(hal, struct ath12k_base, hal); size_t size; if (!hal->rdp.vaddr) return; size = sizeof(u32) * HAL_SRNG_RING_ID_MAX; - dma_free_coherent(hal->dev, size, + dma_free_coherent(ab->dev, size, hal->rdp.vaddr, hal->rdp.paddr); hal->rdp.vaddr = NULL; } static int ath12k_hal_alloc_cont_wrp(struct ath12k_hal *hal) { + struct ath12k_base *ab = container_of(hal, struct ath12k_base, hal); size_t size; size = sizeof(u32) * (HAL_SRNG_NUM_PMAC_RINGS + HAL_SRNG_NUM_DMAC_RINGS); - hal->wrp.vaddr = dma_alloc_coherent(hal->dev, size, &hal->wrp.paddr, + hal->wrp.vaddr = dma_alloc_coherent(ab->dev, size, &hal->wrp.paddr, GFP_KERNEL); if (!hal->wrp.vaddr) return -ENOMEM; @@ -192,13 +195,14 @@ static int ath12k_hal_alloc_cont_wrp(struct ath12k_hal *hal) static void ath12k_hal_free_cont_wrp(struct ath12k_hal *hal) { + struct ath12k_base *ab = container_of(hal, struct ath12k_base, hal); size_t size; if (!hal->wrp.vaddr) return; size = sizeof(u32) * (HAL_SRNG_NUM_PMAC_RINGS + HAL_SRNG_NUM_DMAC_RINGS); - dma_free_coherent(hal->dev, size, + dma_free_coherent(ab->dev, size, hal->wrp.vaddr, hal->wrp.paddr); hal->wrp.vaddr = NULL; } @@ -740,8 +744,6 @@ int ath12k_hal_srng_init(struct ath12k_base *ab) if (ret) goto err_hal; - hal->dev = ab->dev; - ret = ath12k_hal_alloc_cont_rdp(hal); if (ret) goto err_free_config; diff --git a/drivers/net/wireless/ath/ath12k/hal.h b/drivers/net/wireless/ath/ath12k/hal.h index 343e1636b4cc..6b26e1e22254 100644 --- a/drivers/net/wireless/ath/ath12k/hal.h +++ b/drivers/net/wireless/ath/ath12k/hal.h @@ -1237,7 +1237,6 @@ struct ath12k_hal { dma_addr_t paddr; } wrp; - struct device *dev; const struct hal_ops *ops; const struct ath12k_hw_regs *regs; const struct ath12k_hw_hal_params *hal_params; diff --git a/drivers/net/wireless/ath/ath12k/wifi7/hal.c b/drivers/net/wireless/ath/ath12k/wifi7/hal.c index 7c468159085f..868b14d17758 100644 --- a/drivers/net/wireless/ath/ath12k/wifi7/hal.c +++ b/drivers/net/wireless/ath/ath12k/wifi7/hal.c @@ -361,11 +361,12 @@ int ath12k_wifi7_hal_srng_get_ring_id(struct ath12k_hal *hal, enum hal_ring_type type, int ring_num, int mac_id) { + struct ath12k_base *ab = container_of(hal, struct ath12k_base, hal); struct hal_srng_config *srng_config = &hal->srng_config[type]; int ring_id; if (ring_num >= srng_config->max_rings) { - ath12k_warn(hal, "invalid ring number :%d\n", ring_num); + ath12k_warn(ab, "invalid ring number: %d\n", ring_num); return -EINVAL; } @@ -710,6 +711,8 @@ void ath12k_wifi7_hal_cc_config(struct ath12k_base *ab) enum hal_rx_buf_return_buf_manager ath12k_wifi7_hal_get_idle_link_rbm(struct ath12k_hal *hal, u8 device_id) { + struct ath12k_base *ab = container_of(hal, struct ath12k_base, hal); + switch (device_id) { case 0: return HAL_RX_BUF_RBM_WBM_DEV0_IDLE_DESC_LIST; @@ -718,7 +721,7 @@ ath12k_wifi7_hal_get_idle_link_rbm(struct ath12k_hal *hal, u8 device_id) case 2: return HAL_RX_BUF_RBM_WBM_DEV2_IDLE_DESC_LIST; default: - ath12k_warn(hal, + ath12k_warn(ab, "invalid %d device id, so choose default rbm\n", device_id); WARN_ON(1); base-commit: 92adc530e9b0c1f680a3b78326e069b55ccf2029 -- 2.34.1