Skip to content

Commit 2ef085b

Browse files
rchatreKAGA-KOKO
authored andcommitted
x86/resctrl: Cleanup cbm_ensure_valid()
A recent fix to the cbm_ensure_valid() function left some coding style issues that are now addressed: - Return a value instead of using a function parameter as input and output - Use if (!val) instead of if (val == 0) - Follow reverse fir tree ordering of variable declarations Suggested-by: Borislav Petkov <[email protected]> Signed-off-by: Reinette Chatre <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/15ba03856f1d944468ee6f44e3fd7aa548293ede.1561408280.git.reinette.chatre@intel.com
1 parent 4fedcde commit 2ef085b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,21 +2488,21 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn,
24882488
* modification to the CBM if the default does not satisfy the
24892489
* requirements.
24902490
*/
2491-
static void cbm_ensure_valid(u32 *_val, struct rdt_resource *r)
2491+
static u32 cbm_ensure_valid(u32 _val, struct rdt_resource *r)
24922492
{
2493-
unsigned long val = *_val;
24942493
unsigned int cbm_len = r->cache.cbm_len;
24952494
unsigned long first_bit, zero_bit;
2495+
unsigned long val = _val;
24962496

2497-
if (val == 0)
2498-
return;
2497+
if (!val)
2498+
return 0;
24992499

25002500
first_bit = find_first_bit(&val, cbm_len);
25012501
zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
25022502

25032503
/* Clear any remaining bits to ensure contiguous region */
25042504
bitmap_clear(&val, zero_bit, cbm_len - zero_bit);
2505-
*_val = (u32)val;
2505+
return (u32)val;
25062506
}
25072507

25082508
/*
@@ -2560,7 +2560,7 @@ static int __init_one_rdt_domain(struct rdt_domain *d, struct rdt_resource *r,
25602560
* Force the initial CBM to be valid, user can
25612561
* modify the CBM based on system availability.
25622562
*/
2563-
cbm_ensure_valid(&d->new_ctrl, r);
2563+
d->new_ctrl = cbm_ensure_valid(d->new_ctrl, r);
25642564
/*
25652565
* Assign the u32 CBM to an unsigned long to ensure that
25662566
* bitmap_weight() does not access out-of-bound memory.

0 commit comments

Comments
 (0)