From: Bart Van Assche <bvanassche@acm.org>
To: "Peter Wang (王信友)" <peter.wang@mediatek.com>,
"avri.altman@wdc.com" <avri.altman@wdc.com>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"tanghuan@vivo.com" <tanghuan@vivo.com>,
"quic_nguyenb@quicinc.com" <quic_nguyenb@quicinc.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"manivannan.sadhasivam@linaro.org"
<manivannan.sadhasivam@linaro.org>,
"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
"luhongfei@vivo.com" <luhongfei@vivo.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"James.Bottomley@HansenPartnership.com"
<James.Bottomley@HansenPartnership.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: "opensource.kernel@vivo.com" <opensource.kernel@vivo.com>,
"wenxing.cheng@vivo.com" <wenxing.cheng@vivo.com>
Subject: Re: [PATCH v5] ufs: core: Add HID support
Date: Tue, 20 May 2025 13:13:57 -0700 [thread overview]
Message-ID: <3ba29109-86d8-4bc1-8f2f-49fa2e56673e@acm.org> (raw)
In-Reply-To: <ab468bb26dafca673d7ffca7dff519b7cf024cdc.camel@mediatek.com>
On 5/20/25 6:14 AM, Peter Wang (王信友) wrote:
> On Tue, 2025-05-20 at 17:40 +0800, Huan Tang wrote:
>> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
>> index 3e2097e65964..8ccd923a5761 100644
>> --- a/drivers/ufs/core/ufshcd.c
>> +++ b/drivers/ufs/core/ufshcd.c
>> @@ -8390,6 +8390,10 @@ static int ufs_get_device_desc(struct ufs_hba
>> *hba)
>>
>> dev_info->rtt_cap = desc_buf[DEVICE_DESC_PARAM_RTT_CAP];
>>
>> + dev_info->hid_sup = get_unaligned_be32(desc_buf +
>> +
>> DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP) &
>> + UFS_DEV_HID_SUPPORT;
>> +
>>
>
> Could add the double negation (!!) ensures the value is exactly 0 or 1.
> dev_info->hid_sup = !!(get_unaligned_be32(desc_buf +
> DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP) &
> UFS_DEV_HID_SUPPORT);
Hi Peter,
I do not agree that this change is required. ufs_dev_info.hid_sup has
type bool and hence the compiler will convert the result of the binary
and operation implicitly into a boolean value (0/1). From the C23
standard: "When any scalar value is converted to bool, the result is
false if the value is a zero (for arithmetic types), null (for pointer
types), or the scalar has type nullptr_t; otherwise, the result is
true."
A double negation does not occur elsewhere in the kernel if an integer
value is assigned to a boolean variable so I think that it shouldn't be
added here either.
Bart.
next prev parent reply other threads:[~2025-05-20 20:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 9:40 Huan Tang
2025-05-20 13:14 ` Peter Wang (王信友)
2025-05-20 20:13 ` Bart Van Assche [this message]
2025-05-21 2:22 ` Peter Wang (王信友)
2025-05-21 14:33 ` Huan Tang
2025-05-22 3:26 ` Peter Wang (王信友)
2025-05-20 16:01 ` Bean Huo
2025-05-20 20:22 ` Bart Van Assche
2025-05-21 14:32 ` Huan Tang
2025-05-21 14:56 ` Bean Huo
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=3ba29109-86d8-4bc1-8f2f-49fa2e56673e@acm.org \
--to=bvanassche@acm.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=avri.altman@wdc.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=luhongfei@vivo.com \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=opensource.kernel@vivo.com \
--cc=peter.wang@mediatek.com \
--cc=quic_nguyenb@quicinc.com \
--cc=tanghuan@vivo.com \
--cc=wenxing.cheng@vivo.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
all inboxes | Powered by JetHome®