Add the cpus_copy() helper

This helper is useful when updating a global mask with a local value. The
upcoming thermal-event handler Handling thermal events has the case.

Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
This commit is contained in:
Chang S. Bae 2022-02-25 02:46:20 -08:00
parent ac7869cba3
commit df3436b966
1 changed files with 9 additions and 0 deletions

View File

@ -40,6 +40,7 @@
*
* void cpus_shift_right(dst, src, n) Shift right
* void cpus_shift_left(dst, src, n) Shift left
* void cpus_copy(dst, src) Copy from src to dst
*
* int first_cpu(mask) Number lowest set bit, or NR_CPUS
* int next_cpu(cpu, mask) Next cpu past 'cpu', or NR_CPUS
@ -197,6 +198,14 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
}
#define cpus_copy(dst, src) \
__cpus_copy(&(dst), &(src), NR_CPUS)
static inline void __cpus_copy(cpumask_t *dstp,
const cpumask_t *srcp, int nbits)
{
bitmap_copy(dstp->bits, srcp->bits, nbits);
}
static inline int __first_cpu(const cpumask_t *srcp)
{
return ffs(*srcp->bits)-1;