From: Sayali Lokhande <sayalil@codeaurora.org>
To: Avri Altman <Avri.Altman@wdc.com>,
"subhashj@codeaurora.org" <subhashj@codeaurora.org>,
"cang@codeaurora.org" <cang@codeaurora.org>,
"vivek.gautam@codeaurora.org" <vivek.gautam@codeaurora.org>,
"rnayak@codeaurora.org" <rnayak@codeaurora.org>,
"vinholikatti@gmail.com" <vinholikatti@gmail.com>,
"jejb@linux.vnet.ibm.com" <jejb@linux.vnet.ibm.com>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"asutoshd@codeaurora.org" <asutoshd@codeaurora.org>,
"evgreen@chromium.org" <evgreen@chromium.org>,
"riteshh@codeaurora.org" <riteshh@codeaurora.org>
Cc: "stummala@codeaurora.org" <stummala@codeaurora.org>,
"adrian.hunter@intel.com" <adrian.hunter@intel.com>,
"jlbec@evilplan.org" <jlbec@evilplan.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V14 1/2] scsi: ufs: set the device reference clock setting
Date: Mon, 24 Sep 2018 14:17:54 +0530 [thread overview]
Message-ID: <0761c2c2-4366-0a20-6789-10c4c9498908@codeaurora.org> (raw)
In-Reply-To: <SN6PR04MB49250F1D665127DBA82137A3FC170@SN6PR04MB4925.namprd04.prod.outlook.com>
On 9/24/2018 1:28 PM, Avri Altman wrote:
>> +static struct ufs_ref_clk ufs_ref_clk_freqs[] = {
>> + {19200000, REF_CLK_FREQ_19_2_MHZ},
>> + {26000000, REF_CLK_FREQ_26_MHZ},
>> + {38400000, REF_CLK_FREQ_38_4_MHZ},
>> + {52000000, REF_CLK_FREQ_52_MHZ},
>> + {0, REF_CLK_FREQ_INVAL},
>> +};
>> +
>> +static inline enum ufs_ref_clk_freq
>> +ufs_get_bref_clk_from_hz(u32 freq)
>> +{
>> + int i = 0;
>> +
>> + while (ufs_ref_clk_freqs[i].freq_hz != freq) {
>> + if (!ufs_ref_clk_freqs[i].freq_hz)
>> + return REF_CLK_FREQ_INVAL;
> Is the if clause really needed?
> you will return REF_CLK_FREQ_INVAL anyway
Yes. the if condition makes sure to return REF_CLK_FREQ_INVAL if freq is
not what we expect.
>
>> + i++;
> You might overrun here if freq is not what you've expected
Above if condition "if (!ufs_ref_clk_freqs[i].freq_hz)" prevents such
overrun
as we will reach end of ufs_ref_clk_freqs[] (i.e upto 0,
REF_CLK_FREQ_INVAL) when there is no match and thus we will return
REF_CLK_FREQ_INVAL.
>> + }
>> +
>> + return ufs_ref_clk_freqs[i].val;
>> +}
next prev parent reply other threads:[~2018-09-24 8:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1537770516-28410-1-git-send-email-sayalil@codeaurora.org>
2018-09-24 6:28 ` [PATCH V14 1/2] scsi: ufs: set the device reference clock setting Sayali Lokhande
2018-09-24 7:58 ` Avri Altman
2018-09-24 8:47 ` Sayali Lokhande [this message]
2018-10-12 22:50 ` Doug Anderson
2018-10-15 10:57 ` Sayali Lokhande
2018-09-24 6:28 ` [PATCH V14 2/2] scsi: ufs: Add configfs support for UFS provisioning Sayali Lokhande
2018-09-24 10:03 ` Avri Altman
2018-10-04 10:40 ` Sayali Lokhande
2018-09-24 20:38 ` Evan Green
2018-10-03 18:01 ` Evan Green
2018-10-04 7:39 ` Sayali Lokhande
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=0761c2c2-4366-0a20-6789-10c4c9498908@codeaurora.org \
--to=sayalil@codeaurora.org \
--cc=Avri.Altman@wdc.com \
--cc=adrian.hunter@intel.com \
--cc=asutoshd@codeaurora.org \
--cc=cang@codeaurora.org \
--cc=evgreen@chromium.org \
--cc=jejb@linux.vnet.ibm.com \
--cc=jlbec@evilplan.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=riteshh@codeaurora.org \
--cc=rnayak@codeaurora.org \
--cc=stummala@codeaurora.org \
--cc=subhashj@codeaurora.org \
--cc=vinholikatti@gmail.com \
--cc=vivek.gautam@codeaurora.org \
/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