Skip to content

Commit e8a1d87

Browse files
minwooimmartinkpetersen
authored andcommitted
scsi: ufs: mcq: Convert MCQ_CFG_n to an inline function
Inline functions are preferred over macros. Convert the MCQ_CFG_n macro to an inline function. Signed-off-by: Minwoo Im <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Bart Van Assche <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 2fc3984 commit e8a1d87

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

drivers/ufs/core/ufs-mcq.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#define QUEUE_ID_OFFSET 16
2626

2727
#define MCQ_CFG_MAC_MASK GENMASK(16, 8)
28-
#define MCQ_QCFG_SIZE 0x40
2928
#define MCQ_ENTRY_SIZE_IN_DWORD 8
3029
#define CQE_UCD_BA GENMASK_ULL(63, 7)
3130

@@ -228,10 +227,6 @@ int ufshcd_mcq_memory_alloc(struct ufs_hba *hba)
228227
return 0;
229228
}
230229

231-
232-
/* Operation and runtime registers configuration */
233-
#define MCQ_CFG_n(r, i) ((r) + MCQ_QCFG_SIZE * (i))
234-
235230
static void __iomem *mcq_opr_base(struct ufs_hba *hba,
236231
enum ufshcd_mcq_opr n, int i)
237232
{
@@ -336,29 +331,29 @@ void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba)
336331

337332
/* Submission Queue Lower Base Address */
338333
ufsmcq_writelx(hba, lower_32_bits(hwq->sqe_dma_addr),
339-
MCQ_CFG_n(REG_SQLBA, i));
334+
ufshcd_mcq_cfg_offset(REG_SQLBA, i));
340335
/* Submission Queue Upper Base Address */
341336
ufsmcq_writelx(hba, upper_32_bits(hwq->sqe_dma_addr),
342-
MCQ_CFG_n(REG_SQUBA, i));
337+
ufshcd_mcq_cfg_offset(REG_SQUBA, i));
343338
/* Submission Queue Doorbell Address Offset */
344339
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_SQD, i),
345-
MCQ_CFG_n(REG_SQDAO, i));
340+
ufshcd_mcq_cfg_offset(REG_SQDAO, i));
346341
/* Submission Queue Interrupt Status Address Offset */
347342
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_SQIS, i),
348-
MCQ_CFG_n(REG_SQISAO, i));
343+
ufshcd_mcq_cfg_offset(REG_SQISAO, i));
349344

350345
/* Completion Queue Lower Base Address */
351346
ufsmcq_writelx(hba, lower_32_bits(hwq->cqe_dma_addr),
352-
MCQ_CFG_n(REG_CQLBA, i));
347+
ufshcd_mcq_cfg_offset(REG_CQLBA, i));
353348
/* Completion Queue Upper Base Address */
354349
ufsmcq_writelx(hba, upper_32_bits(hwq->cqe_dma_addr),
355-
MCQ_CFG_n(REG_CQUBA, i));
350+
ufshcd_mcq_cfg_offset(REG_CQUBA, i));
356351
/* Completion Queue Doorbell Address Offset */
357352
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_CQD, i),
358-
MCQ_CFG_n(REG_CQDAO, i));
353+
ufshcd_mcq_cfg_offset(REG_CQDAO, i));
359354
/* Completion Queue Interrupt Status Address Offset */
360355
ufsmcq_writelx(hba, ufshcd_mcq_opr_offset(hba, OPR_CQIS, i),
361-
MCQ_CFG_n(REG_CQISAO, i));
356+
ufshcd_mcq_cfg_offset(REG_CQISAO, i));
362357

363358
/* Save the base addresses for quicker access */
364359
hwq->mcq_sq_head = mcq_opr_base(hba, OPR_SQD, i) + REG_SQHP;
@@ -375,15 +370,15 @@ void ufshcd_mcq_make_queues_operational(struct ufs_hba *hba)
375370

376371
/* Completion Queue Enable|Size to Completion Queue Attribute */
377372
ufsmcq_writel(hba, (1 << QUEUE_EN_OFFSET) | qsize,
378-
MCQ_CFG_n(REG_CQATTR, i));
373+
ufshcd_mcq_cfg_offset(REG_CQATTR, i));
379374

380375
/*
381376
* Submission Qeueue Enable|Size|Completion Queue ID to
382377
* Submission Queue Attribute
383378
*/
384379
ufsmcq_writel(hba, (1 << QUEUE_EN_OFFSET) | qsize |
385380
(i << QUEUE_ID_OFFSET),
386-
MCQ_CFG_n(REG_SQATTR, i));
381+
ufshcd_mcq_cfg_offset(REG_SQATTR, i));
387382
}
388383
}
389384
EXPORT_SYMBOL_GPL(ufshcd_mcq_make_queues_operational);

include/ufs/ufshcd.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,8 @@ struct ufs_hw_queue {
11301130
struct mutex sq_mutex;
11311131
};
11321132

1133+
#define MCQ_QCFG_SIZE 0x40
1134+
11331135
static inline bool is_mcq_enabled(struct ufs_hba *hba)
11341136
{
11351137
return hba->mcq_enabled;
@@ -1141,6 +1143,11 @@ static inline unsigned int ufshcd_mcq_opr_offset(struct ufs_hba *hba,
11411143
return hba->mcq_opr[opr].offset + hba->mcq_opr[opr].stride * idx;
11421144
}
11431145

1146+
static inline unsigned int ufshcd_mcq_cfg_offset(unsigned int reg, int idx)
1147+
{
1148+
return reg + MCQ_QCFG_SIZE * idx;
1149+
}
1150+
11441151
#ifdef CONFIG_SCSI_UFS_VARIABLE_SG_ENTRY_SIZE
11451152
static inline size_t ufshcd_sg_entry_size(const struct ufs_hba *hba)
11461153
{

0 commit comments

Comments
 (0)