summaryrefslogtreecommitdiff
path: root/lib/sbi
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2020-03-09 06:52:41 +0300
committerAnup Patel <anup@brainfault.org>2020-03-10 07:57:28 +0300
commit650c0e525ce60e80b6756aa8cc4eeae5b20ccbd8 (patch)
tree579e92ff39fa780818fe483337850d28df5ddb15 /lib/sbi
parent6e87507db6ce7be39ccccb33d6283814f0283c09 (diff)
downloadopensbi-650c0e525ce60e80b6756aa8cc4eeae5b20ccbd8.tar.xz
lib: sbi: Fix coding style issues
This fixes various coding style issues found in the SBI codes. No functional changes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'lib/sbi')
-rw-r--r--lib/sbi/riscv_asm.c2
-rw-r--r--lib/sbi/riscv_atomic.c42
-rw-r--r--lib/sbi/sbi_bitops.c12
-rw-r--r--lib/sbi/sbi_ecall.c3
-rw-r--r--lib/sbi/sbi_hart.c4
-rw-r--r--lib/sbi/sbi_hsm.c14
-rw-r--r--lib/sbi/sbi_tlb.c4
-rw-r--r--lib/sbi/sbi_trap.c2
8 files changed, 42 insertions, 41 deletions
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c
index 7b612d4..79c45f5 100644
--- a/lib/sbi/riscv_asm.c
+++ b/lib/sbi/riscv_asm.c
@@ -207,7 +207,7 @@ int pmp_set(unsigned int n, unsigned long prot, unsigned long addr,
if (n >= PMP_COUNT || log2len > __riscv_xlen || log2len < PMP_SHIFT)
return SBI_EINVAL;
- /* calculate PMP register and offset */
+ /* calculate PMP register and offset */
#if __riscv_xlen == 32
pmpcfg_csr = CSR_PMPCFG0 + (n >> 2);
pmpcfg_shift = (n & 3) << 3;
diff --git a/lib/sbi/riscv_atomic.c b/lib/sbi/riscv_atomic.c
index 9d8199e..fcf3ed1 100644
--- a/lib/sbi/riscv_atomic.c
+++ b/lib/sbi/riscv_atomic.c
@@ -49,7 +49,7 @@ long atomic_sub_return(atomic_t *atom, long value)
return ret - value;
}
-#define __axchg(ptr, new, size) \
+#define __axchg(ptr, new, size) \
({ \
__typeof__(ptr) __ptr = (ptr); \
__typeof__(new) __new = (new); \
@@ -70,12 +70,12 @@ long atomic_sub_return(atomic_t *atom, long value)
: "memory"); \
break; \
default: \
- break; \
+ break; \
} \
__ret; \
})
-#define axchg(ptr, x) \
+#define axchg(ptr, x) \
({ \
__typeof__(*(ptr)) _x_ = (x); \
(__typeof__(*(ptr))) __axchg((ptr), _x_, sizeof(*(ptr))); \
@@ -90,20 +90,20 @@ long atomic_sub_return(atomic_t *atom, long value)
register unsigned int __rc; \
switch (size) { \
case 4: \
- __asm__ __volatile__("0: lr.w %0, %2\n" \
- " sc.w.rl %1, %z3, %2\n" \
- " bnez %1, 0b\n" \
- " fence rw, rw\n" \
+ __asm__ __volatile__("0: lr.w %0, %2\n" \
+ " sc.w.rl %1, %z3, %2\n" \
+ " bnez %1, 0b\n" \
+ " fence rw, rw\n" \
: "=&r"(__ret), "=&r"(__rc), \
"+A"(*__ptr) \
: "rJ"(__new) \
: "memory"); \
break; \
case 8: \
- __asm__ __volatile__("0: lr.d %0, %2\n" \
- " sc.d.rl %1, %z3, %2\n" \
- " bnez %1, 0b\n" \
- " fence rw, rw\n" \
+ __asm__ __volatile__("0: lr.d %0, %2\n" \
+ " sc.d.rl %1, %z3, %2\n" \
+ " bnez %1, 0b\n" \
+ " fence rw, rw\n" \
: "=&r"(__ret), "=&r"(__rc), \
"+A"(*__ptr) \
: "rJ"(__new) \
@@ -130,11 +130,11 @@ long atomic_sub_return(atomic_t *atom, long value)
register unsigned int __rc; \
switch (size) { \
case 4: \
- __asm__ __volatile__("0: lr.w %0, %2\n" \
- " bne %0, %z3, 1f\n" \
- " sc.w.rl %1, %z4, %2\n" \
- " bnez %1, 0b\n" \
- " fence rw, rw\n" \
+ __asm__ __volatile__("0: lr.w %0, %2\n" \
+ " bne %0, %z3, 1f\n" \
+ " sc.w.rl %1, %z4, %2\n" \
+ " bnez %1, 0b\n" \
+ " fence rw, rw\n" \
"1:\n" \
: "=&r"(__ret), "=&r"(__rc), \
"+A"(*__ptr) \
@@ -142,11 +142,11 @@ long atomic_sub_return(atomic_t *atom, long value)
: "memory"); \
break; \
case 8: \
- __asm__ __volatile__("0: lr.d %0, %2\n" \
- " bne %0, %z3, 1f\n" \
- " sc.d.rl %1, %z4, %2\n" \
- " bnez %1, 0b\n" \
- " fence rw, rw\n" \
+ __asm__ __volatile__("0: lr.d %0, %2\n" \
+ " bne %0, %z3, 1f\n" \
+ " sc.d.rl %1, %z4, %2\n" \
+ " bnez %1, 0b\n" \
+ " fence rw, rw\n" \
"1:\n" \
: "=&r"(__ret), "=&r"(__rc), \
"+A"(*__ptr) \
diff --git a/lib/sbi/sbi_bitops.c b/lib/sbi/sbi_bitops.c
index 1355243..de9d045 100644
--- a/lib/sbi/sbi_bitops.c
+++ b/lib/sbi/sbi_bitops.c
@@ -20,7 +20,7 @@
* Returns the bit number of the first set bit.
*/
unsigned long find_first_bit(const unsigned long *addr,
- unsigned long size)
+ unsigned long size)
{
const unsigned long *p = addr;
unsigned long result = 0;
@@ -50,7 +50,7 @@ found:
* Returns the bit number of the first cleared bit.
*/
unsigned long find_first_zero_bit(const unsigned long *addr,
- unsigned long size)
+ unsigned long size)
{
const unsigned long *p = addr;
unsigned long result = 0;
@@ -80,7 +80,7 @@ found:
* Returns the bit number of the first set bit, or size.
*/
unsigned long find_last_bit(const unsigned long *addr,
- unsigned long size)
+ unsigned long size)
{
unsigned long words;
unsigned long tmp;
@@ -115,7 +115,7 @@ found:
* @size: The bitmap size in bits
*/
unsigned long find_next_bit(const unsigned long *addr,
- unsigned long size, unsigned long offset)
+ unsigned long size, unsigned long offset)
{
const unsigned long *p = addr + BITOP_WORD(offset);
unsigned long result = offset & ~(BITS_PER_LONG-1);
@@ -160,8 +160,8 @@ found_middle:
* @size: The bitmap size in bits
*/
unsigned long find_next_zero_bit(const unsigned long *addr,
- unsigned long size,
- unsigned long offset)
+ unsigned long size,
+ unsigned long offset)
{
const unsigned long *p = addr + BITOP_WORD(offset);
unsigned long result = offset & ~(BITS_PER_LONG-1);
diff --git a/lib/sbi/sbi_ecall.c b/lib/sbi/sbi_ecall.c
index 2383e4f..6d7b152 100644
--- a/lib/sbi/sbi_ecall.c
+++ b/lib/sbi/sbi_ecall.c
@@ -105,7 +105,8 @@ int sbi_ecall_handler(u32 hartid, ulong mcause, struct sbi_trap_regs *regs,
trap.epc = regs->mepc;
sbi_trap_redirect(regs, &trap, scratch);
} else {
- /* This function should return non-zero value only in case of
+ /*
+ * This function should return non-zero value only in case of
* fatal error. However, there is no good way to distinguish
* between a fatal and non-fatal errors yet. That's why we treat
* every return value except ETRAP as non-fatal and just return
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index bce2fb5..c00e16a 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -75,7 +75,7 @@ static int delegate_traps(struct sbi_scratch *scratch, u32 hartid)
unsigned long interrupts, exceptions;
if (!misa_extension('S'))
- /* No delegation possible as mideleg does not exist*/
+ /* No delegation possible as mideleg does not exist */
return 0;
/* Send M-mode interrupts and most exceptions to S-mode */
@@ -342,7 +342,7 @@ sbi_hart_switch_mode(unsigned long arg0, unsigned long arg1,
__builtin_unreachable();
}
-static spinlock_t avail_hart_mask_lock = SPIN_LOCK_INITIALIZER;
+static spinlock_t avail_hart_mask_lock = SPIN_LOCK_INITIALIZER;
static volatile unsigned long avail_hart_mask = 0;
void sbi_hart_mark_available(u32 hartid)
diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c
index c1fd950..14a2d84 100644
--- a/lib/sbi/sbi_hsm.c
+++ b/lib/sbi/sbi_hsm.c
@@ -81,7 +81,7 @@ void sbi_hsm_prepare_next_jump(struct sbi_scratch *scratch, u32 hartid)
{
u32 oldstate;
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
- hart_data_offset);
+ hart_data_offset);
oldstate = arch_atomic_cmpxchg(&hdata->state, SBI_HART_STARTING,
SBI_HART_STARTED);
@@ -94,7 +94,7 @@ static void sbi_hsm_hart_wait(struct sbi_scratch *scratch, u32 hartid)
unsigned long saved_mie;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
- hart_data_offset);
+ hart_data_offset);
/* Save MIE CSR */
saved_mie = csr_read(CSR_MIE);
@@ -122,7 +122,7 @@ int sbi_hsm_init(struct sbi_scratch *scratch, u32 hartid, bool cold_boot)
if (cold_boot) {
hart_data_offset = sbi_scratch_alloc_offset(sizeof(*hdata),
- "HART_DATA");
+ "HART_DATA");
if (!hart_data_offset)
return SBI_ENOMEM;
hart_count = sbi_platform_hart_count(plat);
@@ -147,7 +147,7 @@ void __noreturn sbi_hsm_exit(struct sbi_scratch *scratch)
u32 hstate;
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
- hart_data_offset);
+ hart_data_offset);
void (*jump_warmboot)(void) = (void (*)(void))scratch->warmboot_addr;
hstate = arch_atomic_cmpxchg(&hdata->state, SBI_HART_STOPPING,
@@ -183,7 +183,7 @@ int sbi_hsm_hart_start(struct sbi_scratch *scratch, u32 hartid,
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
struct sbi_scratch *rscratch = sbi_hart_id_to_scratch(scratch, hartid);
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(rscratch,
- hart_data_offset);
+ hart_data_offset);
if (sbi_platform_hart_disabled(plat, hartid))
return SBI_EINVAL;
@@ -225,14 +225,14 @@ int sbi_hsm_hart_stop(struct sbi_scratch *scratch, bool exitnow)
u32 hartid = sbi_current_hartid();
const struct sbi_platform *plat = sbi_platform_ptr(scratch);
struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
- hart_data_offset);
+ hart_data_offset);
if (sbi_platform_hart_disabled(plat, hartid) ||
!sbi_hsm_hart_started(scratch, hartid))
return SBI_EINVAL;
oldstate = arch_atomic_cmpxchg(&hdata->state, SBI_HART_STARTED,
- SBI_HART_STOPPING);
+ SBI_HART_STOPPING);
if (oldstate != SBI_HART_STARTED) {
sbi_printf("%s: ERR: The hart is in invalid state [%u]\n",
__func__, oldstate);
diff --git a/lib/sbi/sbi_tlb.c b/lib/sbi/sbi_tlb.c
index 072915f..21e2436 100644
--- a/lib/sbi/sbi_tlb.c
+++ b/lib/sbi/sbi_tlb.c
@@ -392,11 +392,11 @@ int sbi_tlb_init(struct sbi_scratch *scratch, bool cold_boot)
if (cold_boot) {
tlb_sync_off = sbi_scratch_alloc_offset(sizeof(*tlb_sync),
- "IPI_TLB_SYNC");
+ "IPI_TLB_SYNC");
if (!tlb_sync_off)
return SBI_ENOMEM;
tlb_fifo_off = sbi_scratch_alloc_offset(sizeof(*tlb_q),
- "IPI_TLB_FIFO");
+ "IPI_TLB_FIFO");
if (!tlb_fifo_off) {
sbi_scratch_free_offset(tlb_sync_off);
return SBI_ENOMEM;
diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c
index d5ab24b..b5fbc5e 100644
--- a/lib/sbi/sbi_trap.c
+++ b/lib/sbi/sbi_trap.c
@@ -178,7 +178,7 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs,
regs->mstatus &= ~MSTATUS_MPP;
regs->mstatus |= (PRV_S << MSTATUS_MPP_SHIFT);
- /* Set SPP for S-mode*/
+ /* Set SPP for S-mode */
regs->mstatus &= ~MSTATUS_SPP;
if (prev_mode == PRV_S)
regs->mstatus |= (1UL << MSTATUS_SPP_SHIFT);