Skip to content

Commit

Permalink
lib: Delete redundant ulong
Browse files Browse the repository at this point in the history
In `csr_read_allowed` and `csr_write_allowed` macros, has already
converted second param to `ulong`. So delete redundant `ulong`
where uses csr_read/write_allowed macros.

Signed-off-by: Zhang RunMin <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
  • Loading branch information
Zhang RunMin authored and avpatel committed Aug 24, 2024
1 parent b0ad9e0 commit ef4520b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions lib/sbi/sbi_dbtr.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ int sbi_dbtr_init(struct sbi_scratch *scratch, bool coldboot)
goto _probed;

for (i = 0; i < RV_MAX_TRIGGERS; i++) {
csr_write_allowed(CSR_TSELECT, (ulong)&trap, i);
csr_write_allowed(CSR_TSELECT, &trap, i);
if (trap.cause)
break;

val = csr_read_allowed(CSR_TSELECT, (ulong)&trap);
val = csr_read_allowed(CSR_TSELECT, &trap);
if (trap.cause)
break;

Expand All @@ -182,15 +182,15 @@ int sbi_dbtr_init(struct sbi_scratch *scratch, bool coldboot)
if (val != i)
break;

val = csr_read_allowed(CSR_TINFO, (ulong)&trap);
val = csr_read_allowed(CSR_TINFO, &trap);
if (trap.cause) {
/*
* If reading tinfo caused an exception, the
* debugger must read tdata1 to discover the
* type.
*/
tdata1 = csr_read_allowed(CSR_TDATA1,
(ulong)&trap);
&trap);
if (trap.cause)
break;

Expand Down
28 changes: 14 additions & 14 deletions lib/sbi/sbi_hart.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,13 @@ static unsigned long hart_pmp_get_allowed_addr(void)
unsigned long val = 0;
struct sbi_trap_info trap = {0};

csr_write_allowed(CSR_PMPCFG0, (ulong)&trap, 0);
csr_write_allowed(CSR_PMPCFG0, &trap, 0);
if (trap.cause)
return 0;

csr_write_allowed(CSR_PMPADDR0, (ulong)&trap, PMP_ADDR_MASK);
csr_write_allowed(CSR_PMPADDR0, &trap, PMP_ADDR_MASK);
if (!trap.cause) {
val = csr_read_allowed(CSR_PMPADDR0, (ulong)&trap);
val = csr_read_allowed(CSR_PMPADDR0, &trap);
if (trap.cause)
val = 0;
}
Expand All @@ -747,17 +747,17 @@ static int hart_mhpm_get_allowed_bits(void)
* It is assumed that platforms will implement same number of bits for
* all the performance counters including mcycle/minstret.
*/
csr_write_allowed(CSR_MHPMCOUNTER3, (ulong)&trap, val);
csr_write_allowed(CSR_MHPMCOUNTER3, &trap, val);
if (!trap.cause) {
val = csr_read_allowed(CSR_MHPMCOUNTER3, (ulong)&trap);
val = csr_read_allowed(CSR_MHPMCOUNTER3, &trap);
if (trap.cause)
return 0;
}
num_bits = sbi_fls(val) + 1;
#if __riscv_xlen == 32
csr_write_allowed(CSR_MHPMCOUNTER3H, (ulong)&trap, val);
csr_write_allowed(CSR_MHPMCOUNTER3H, &trap, val);
if (!trap.cause) {
val = csr_read_allowed(CSR_MHPMCOUNTER3H, (ulong)&trap);
val = csr_read_allowed(CSR_MHPMCOUNTER3H, &trap);
if (trap.cause)
return num_bits;
}
Expand Down Expand Up @@ -788,9 +788,9 @@ static int hart_detect_features(struct sbi_scratch *scratch)
hfeatures->priv_version = SBI_HART_PRIV_VER_UNKNOWN;

#define __check_hpm_csr(__csr, __mask) \
oldval = csr_read_allowed(__csr, (ulong)&trap); \
oldval = csr_read_allowed(__csr, &trap); \
if (!trap.cause) { \
csr_write_allowed(__csr, (ulong)&trap, 1UL); \
csr_write_allowed(__csr, &trap, 1UL); \
if (!trap.cause && csr_swap(__csr, oldval) == 1UL) { \
(hfeatures->__mask) |= 1 << (__csr - CSR_MCYCLE); \
} \
Expand All @@ -809,13 +809,13 @@ static int hart_detect_features(struct sbi_scratch *scratch)
__check_hpm_csr_8(__csr + 0, __mask) \
__check_hpm_csr_8(__csr + 8, __mask)

#define __check_csr(__csr, __rdonly, __wrval, __field, __skip) \
oldval = csr_read_allowed(__csr, (ulong)&trap); \
#define __check_csr(__csr, __rdonly, __wrval, __field, __skip) \
oldval = csr_read_allowed(__csr, &trap); \
if (!trap.cause) { \
if (__rdonly) { \
(hfeatures->__field)++; \
} else { \
csr_write_allowed(__csr, (ulong)&trap, __wrval);\
csr_write_allowed(__csr, &trap, __wrval); \
if (!trap.cause) { \
if (csr_swap(__csr, oldval) == __wrval) \
(hfeatures->__field)++; \
Expand Down Expand Up @@ -880,7 +880,7 @@ static int hart_detect_features(struct sbi_scratch *scratch)


#define __check_priv(__csr, __base_priv, __priv) \
val = csr_read_allowed(__csr, (ulong)&trap); \
val = csr_read_allowed(__csr, &trap); \
if (!trap.cause && (hfeatures->priv_version >= __base_priv)) { \
hfeatures->priv_version = __priv; \
}
Expand All @@ -899,7 +899,7 @@ static int hart_detect_features(struct sbi_scratch *scratch)

#define __check_ext_csr(__base_priv, __csr, __ext) \
if (hfeatures->priv_version >= __base_priv) { \
csr_read_allowed(__csr, (ulong)&trap); \
csr_read_allowed(__csr, &trap); \
if (!trap.cause) \
__sbi_hart_update_extension(hfeatures, \
__ext, true); \
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/irqchip/imsic.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ void imsic_local_irqchip_init(void)
*/

/* If Smaia not available then do nothing */
csr_read_allowed(CSR_MTOPI, (ulong)&trap);
csr_read_allowed(CSR_MTOPI, &trap);
if (trap.cause)
return;

Expand Down

0 comments on commit ef4520b

Please sign in to comment.