mirror of https://gitee.com/openkylin/linux.git
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 <bp@alien8.de> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/15ba03856f1d944468ee6f44e3fd7aa548293ede.1561408280.git.reinette.chatre@intel.com
This commit is contained in:
parent
4fedcde702
commit
2ef085bd11
|
@ -2488,21 +2488,21 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn,
|
||||||
* modification to the CBM if the default does not satisfy the
|
* modification to the CBM if the default does not satisfy the
|
||||||
* requirements.
|
* requirements.
|
||||||
*/
|
*/
|
||||||
static void cbm_ensure_valid(u32 *_val, struct rdt_resource *r)
|
static u32 cbm_ensure_valid(u32 _val, struct rdt_resource *r)
|
||||||
{
|
{
|
||||||
unsigned long val = *_val;
|
|
||||||
unsigned int cbm_len = r->cache.cbm_len;
|
unsigned int cbm_len = r->cache.cbm_len;
|
||||||
unsigned long first_bit, zero_bit;
|
unsigned long first_bit, zero_bit;
|
||||||
|
unsigned long val = _val;
|
||||||
|
|
||||||
if (val == 0)
|
if (!val)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
first_bit = find_first_bit(&val, cbm_len);
|
first_bit = find_first_bit(&val, cbm_len);
|
||||||
zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
|
zero_bit = find_next_zero_bit(&val, cbm_len, first_bit);
|
||||||
|
|
||||||
/* Clear any remaining bits to ensure contiguous region */
|
/* Clear any remaining bits to ensure contiguous region */
|
||||||
bitmap_clear(&val, zero_bit, cbm_len - zero_bit);
|
bitmap_clear(&val, zero_bit, cbm_len - zero_bit);
|
||||||
*_val = (u32)val;
|
return (u32)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2560,7 +2560,7 @@ static int __init_one_rdt_domain(struct rdt_domain *d, struct rdt_resource *r,
|
||||||
* Force the initial CBM to be valid, user can
|
* Force the initial CBM to be valid, user can
|
||||||
* modify the CBM based on system availability.
|
* modify the CBM based on system availability.
|
||||||
*/
|
*/
|
||||||
cbm_ensure_valid(&d->new_ctrl, r);
|
d->new_ctrl = cbm_ensure_valid(d->new_ctrl, r);
|
||||||
/*
|
/*
|
||||||
* Assign the u32 CBM to an unsigned long to ensure that
|
* Assign the u32 CBM to an unsigned long to ensure that
|
||||||
* bitmap_weight() does not access out-of-bound memory.
|
* bitmap_weight() does not access out-of-bound memory.
|
||||||
|
|
Loading…
Reference in New Issue