On 15.08.2024 12:00, oleksii.kuroc...@gmail.com wrote: > On Wed, 2024-08-14 at 17:53 +0200, Jan Beulich wrote: >> On 14.08.2024 17:41, oleksii.kuroc...@gmail.com wrote: >>> On Tue, 2024-08-13 at 11:34 +0200, Jan Beulich wrote: >>>> On 09.08.2024 18:19, Oleksii Kurochko wrote: >>>>> +static unsigned long sbi_major_version(void) >>>>> +{ >>>>> + return (sbi_spec_version >> SBI_SPEC_VERSION_MAJOR_SHIFT) >>>>> & >>>>> + SBI_SPEC_VERSION_MAJOR_MASK; >>>>> +} >>>> >>>> Can you use MASK_EXTR() here, allowing to even drop the separate >>>> SBI_SPEC_VERSION_MAJOR_SHIFT? >>> I am not sure that: >>> (sbi_spec_version >> SBI_SPEC_VERSION_MAJOR_SHIFT) & >>> SBI_SPEC_VERSION_MAJOR_MASK == MASK_EXTR(sbi_spec_version, >>> SBI_SPEC_VERSION_MAJOR_MASK) >> >> How come you're not sure? That's precisely what MASK_EXTR() is for. > As the order matter here. First should be shift then applying > SBI_SPEC_VERSION_MAJOR_MASK, as SBI_SPEC_VERSION_MAJOR_MASK is defined > now as 7f. If SBI_SPEC_VERSION_MAJOR_MASK set to 0x7F000000 then it > will work.
The assumption was of course that you'd adjust SBI_SPEC_VERSION_MAJOR_MASK. That's the underlying idea after all: When the mask is shifted to its appropriate position, the shift amount needed can be calculated from it. Hence the lack of a need for SBI_SPEC_VERSION_MAJOR_SHIFT (and alike). Jan