From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: David Laight <david.laight.linux@gmail.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 3/9] powercap: intel_rapl: Use GENMASK() and BIT() macros
Date: Thu, 29 Jan 2026 14:17:55 -0800 [thread overview]
Message-ID: <962b2210-5dac-45a6-8ef0-894b337e74cc@linux.intel.com> (raw)
In-Reply-To: <20260129215225.33cce6dc@pumpkin>
On 1/29/2026 1:52 PM, David Laight wrote:
> On Thu, 29 Jan 2026 10:36:40 -0800
> Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
>
>> Replace hardcoded bitmasks and bit shift operations with standard
>> GENMASK(), GENMASK_ULL(), BIT(), and BIT_ULL() macros for better
>> readability and to follow kernel coding conventions.
>>
>> No functional changes.
>
> Assuming that changing values to 'unsigned long' doesn't have any
> subtle side effects.
>
> ...
>> value = (ra.value & ENERGY_UNIT_MASK) >> ENERGY_UNIT_OFFSET;
>> - rd->energy_unit = ENERGY_UNIT_SCALE * 1000000 / (1 << value);
>> + rd->energy_unit = ENERGY_UNIT_SCALE * 1000000 / BIT(value);
>
> That should really be:
> rd->energy_unit = ENERGY_UNIT_SCALE * 1000000 >> value;
Type change to unsigned long will not have any impact for this use case.
However, as you noted, using right shift (>>) instead of division by
BIT() is the correct approach here anyway.
>
> While using BIT() for bit patterns is resonable, wholesale substition
> isn't really right - and that isn't a bit pattern.
Agreed. I will use right shift for 1 / (1 << value) use cases.
>
> David
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer
next prev parent reply other threads:[~2026-01-29 22:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 18:36 [PATCH v1 0/9] Move RAPL defaults to interface drivers Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 1/9] powercap: intel_rapl: Add a symbol namespace for intel_rapl exports Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 2/9] powercap: intel_rapl: Cleanup coding style Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 3/9] powercap: intel_rapl: Use GENMASK() and BIT() macros Kuppuswamy Sathyanarayanan
2026-01-29 21:52 ` David Laight
2026-01-29 22:17 ` Kuppuswamy Sathyanarayanan [this message]
2026-01-29 18:36 ` [PATCH v1 4/9] powercap: intel_rapl: Use unit conversion macros from units.h Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 5/9] powercap: intel_rapl: Allow interface drivers to configure rapl_defaults Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 6/9] powercap: intel_rapl: Move TPMI default settings into TPMI interface driver Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 7/9] thermal: intel: int340x: processor: Move RAPL defaults to MMIO driver Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 8/9] powercap: intel_rapl: Register PM notifier only when RAPL package exists Kuppuswamy Sathyanarayanan
2026-01-29 18:36 ` [PATCH v1 9/9] powercap: intel_rapl: Move MSR default settings into MSR interface driver Kuppuswamy Sathyanarayanan
2026-01-29 19:20 ` [PATCH v1 0/9] Move RAPL defaults to interface drivers srinivas pandruvada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=962b2210-5dac-45a6-8ef0-894b337e74cc@linux.intel.com \
--to=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=daniel.lezcano@linaro.org \
--cc=david.laight.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome