Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: cqhci: introduce get_trans_desc_offset()

The same calculation to get transfer descriptor offset is already used
at 3 different locations. Let's create a new helper to simplify code.

Signed-off-by: Yue Hu <huyue2@yulong.com>
Link: https://lore.kernel.org/r/20210521034432.2321-1-zbestahu@gmail.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Yue Hu and committed by
Ulf Hansson
83c49302 47d23c95

+12 -7
+12 -7
drivers/mmc/host/cqhci-core.c
··· 45 45 return desc + cq_host->task_desc_len; 46 46 } 47 47 48 + static inline size_t get_trans_desc_offset(struct cqhci_host *cq_host, u8 tag) 49 + { 50 + return cq_host->trans_desc_len * cq_host->mmc->max_segs * tag; 51 + } 52 + 48 53 static inline dma_addr_t get_trans_desc_dma(struct cqhci_host *cq_host, u8 tag) 49 54 { 50 - return cq_host->trans_desc_dma_base + 51 - (cq_host->mmc->max_segs * tag * 52 - cq_host->trans_desc_len); 55 + size_t offset = get_trans_desc_offset(cq_host, tag); 56 + 57 + return cq_host->trans_desc_dma_base + offset; 53 58 } 54 59 55 60 static inline u8 *get_trans_desc(struct cqhci_host *cq_host, u8 tag) 56 61 { 57 - return cq_host->trans_desc_base + 58 - (cq_host->trans_desc_len * cq_host->mmc->max_segs * tag); 62 + size_t offset = get_trans_desc_offset(cq_host, tag); 63 + 64 + return cq_host->trans_desc_base + offset; 59 65 } 60 66 61 67 static void setup_trans_desc(struct cqhci_host *cq_host, u8 tag) ··· 200 194 201 195 cq_host->desc_size = cq_host->slot_sz * cq_host->num_slots; 202 196 203 - cq_host->data_size = cq_host->trans_desc_len * cq_host->mmc->max_segs * 204 - cq_host->mmc->cqe_qdepth; 197 + cq_host->data_size = get_trans_desc_offset(cq_host, cq_host->mmc->cqe_qdepth); 205 198 206 199 pr_debug("%s: cqhci: desc_size: %zu data_sz: %zu slot-sz: %d\n", 207 200 mmc_hostname(cq_host->mmc), cq_host->desc_size, cq_host->data_size,