[PATCH v11 2/8] power: reset: reboot-mode: Add support for 64 bit magic
Shivendra Pratap
shivendra.pratap at oss.qualcomm.com
Sun Jul 20 08:24:02 PDT 2025
On 7/20/2025 8:46 PM, Andrew Lunn wrote:
> On Sat, Jul 19, 2025 at 11:07:47PM +0530, Shivendra Pratap wrote:
>>
>>
>> On 7/19/2025 10:27 PM, Andrew Lunn wrote:
>>>>>> +static int qcom_pon_reboot_mode_write(struct reboot_mode_driver *reboot, u64 magic)
>>>>>> {
>>>>>> struct qcom_pon *pon = container_of
>>>>>> (reboot, struct qcom_pon, reboot_mode);
>>>>>> @@ -37,7 +36,7 @@ static int qcom_pon_reboot_mode_write(struct reboot_mode_driver *reboot,
>>>>>> ret = regmap_update_bits(pon->regmap,
>>>>>> pon->baseaddr + PON_SOFT_RB_SPARE,
>>>>>> GENMASK(7, pon->reason_shift),
>>>>>> - magic << pon->reason_shift);
>>>>>> + ((u32)magic) << pon->reason_shift);
>>>
>>> As a general rule of thumb, code with casts is poor quality code. Try
>>> to write the code without casts.
>>>
>>> Maybe something like
>>>
>>> If (magic > MAX_U32)
>>> return -EINVAL;
>>>
>>> magic_32 = magic;
>> sure will update it. And in above, should it be recommended to add a explicit
>> cast(for any avoiding any compiler complains)?
>> like: magic_32 = (u32)magic;
>
> I would hope the compiler/optimiser can figure out from the test the
> line before that this is a safe conversion. So i don't think you need
> a cast.
sure, thanks.
>
> Andrew
More information about the linux-arm-kernel
mailing list