From: Dan Carpenter <dan.carpenter@oracle.com>
To: Avri Altman <Avri.Altman@wdc.com>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
Bart Van Assche <bvanassche@acm.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Daejun Park <daejun7.park@samsung.com>,
Bean Huo <beanhuo@micron.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] scsi: ufs: clean up ufshpb_check_hpb_reset_query()
Date: Wed, 1 Jun 2022 10:09:33 +0300 [thread overview]
Message-ID: <20220601070933.GA2168@kadam> (raw)
In-Reply-To: <DM6PR04MB65755C66140BDDF550DCE75AFCDF9@DM6PR04MB6575.namprd04.prod.outlook.com>
On Wed, Jun 01, 2022 at 06:25:01AM +0000, Avri Altman wrote:
> > Smatch complains that the if (flag_res) is not required:
> >
> > drivers/ufs/core/ufshpb.c:2306 ufshpb_check_hpb_reset_query()
> > warn: duplicate check 'flag_res' (previous on line 2301)
> >
> > Re-write the "if (flag_res)" checking to be more clear.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> In HPB Reset, the Host set this flag as '1' to inform the device that host reset its L2P data.
> The Device resets flag as '0' when the device inactivated all region information.
> 0h: HPB reset completed or not started yet.
> 1h: HPB reset in progress.
>
> Would make sense to me to contain this logic within this function,
> Instead of returning just the flag value.
>
> Thanks,
> Avri
I am not sure I understand.
To be honest, this function is not beautiful at all. With boolean
functions, the name should tell you what the return means. Examples
are: if (!access_ok()), if (IS_ERR() etc. In this case the return is
not clear from the name.
The second thing is that I really don't like returning true for failure
and returning false for success. Returning zero and negatives is good
but with true/false it should be true == success.
So, yes, I wasn't super happy with this function either. But I just
did a minimal clean up to make the returns more clear. If you want to
drop this patch and write a more extensive one then I would be really
happy about that.
regards,
dan carpenter
next prev parent reply other threads:[~2022-06-01 7:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-31 7:29 [PATCH] scsi: ufs: clean up ufshpb_check_hpb_reset_query() Dan Carpenter
2022-06-01 6:25 ` Avri Altman
2022-06-01 7:09 ` Dan Carpenter [this message]
2022-06-01 7:14 ` Avri Altman
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=20220601070933.GA2168@kadam \
--to=dan.carpenter@oracle.com \
--cc=Avri.Altman@wdc.com \
--cc=alim.akhtar@samsung.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=daejun7.park@samsung.com \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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