lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 22 May 2020 18:31:05 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Jishnu Prakash <jprakash@...eaurora.org>
Cc:     agross@...nel.org, Bjorn Andersson <bjorn.andersson@...aro.org>,
        devicetree <devicetree@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Matthias Kaehlcke <mka@...omium.org>,
        Linus Walleij <linus.walleij@...aro.org>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        Amit Kucheria <amit.kucheria@...durent.com>,
        smohanad@...eaurora.org, kgunda@...eaurora.org,
        aghayal@...eaurora.org, Jonathan Cameron <jic23@...nel.org>,
        Hartmut Knaack <knaack.h@....de>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Peter Meerwald-Stadler <pmeerw@...erw.net>,
        linux-arm-msm@...r.kernel.org,
        linux-iio <linux-iio@...r.kernel.org>,
        linux-arm-msm-owner@...r.kernel.org
Subject: Re: [PATCH V4 3/5] iio: adc: Add support for PMIC7 ADC

On Fri, May 22, 2020 at 2:58 PM Jishnu Prakash <jprakash@...eaurora.org> wrote:
> On 5/13/2020 3:18 PM, Andy Shevchenko wrote:
> > On Wed, May 13, 2020 at 12:23 PM Jishnu Prakash <jprakash@...eaurora.org> wrote:

...

> >> +static int qcom_vadc7_scale_hw_calib_die_temp(
> >> +                               const struct vadc_prescale_ratio *prescale,
> >> +                               const struct adc5_data *data,
> >> +                               u16 adc_code, int *result_mdec)
> >> +{
> >> +
> >> +       int voltage, vtemp0, temp, i = ARRAY_SIZE(adcmap7_die_temp) - 1;
> > How assignment to i is useful?
>
>
> I'm using it in adcmap7_die_temp[i] below, to keep it within the
> character limit per line. I think it's more readable that way.
>
> >
> >> +       voltage = qcom_vadc_scale_code_voltage_factor(adc_code,
> >> +                               prescale, data, 1);
> >> +
> >> +       if (adcmap7_die_temp[0].x > voltage) {
> >> +               *result_mdec = DIE_TEMP_ADC7_SCALE_1;
> >> +               return 0;
> >> +       } else if (adcmap7_die_temp[i].x <= voltage) {

I see now i in use, please, replace with direct meaning.

> > Redundant 'else'.
> The expression is different, it's adcmap7_die_temp[i] here, not
> adcmap7_die_temp[0].

if (a) {
 ...
 return;
} else if (b) {
 ...
}

'else' is redundant due to 'return'. Same when it's 'goto'.

> >> +               *result_mdec = DIE_TEMP_ADC7_MAX;
> >> +               return 0;
> >> +       }
> >> +
> >> +       for (i = 0; i < ARRAY_SIZE(adcmap7_die_temp); i++)
> >> +               if (adcmap7_die_temp[i].x > voltage)
> >> +                       break;
> >> +
> >> +       vtemp0 = adcmap7_die_temp[i - 1].x;
> >> +       voltage = voltage - vtemp0;
> >> +       temp = div64_s64(voltage * DIE_TEMP_ADC7_SCALE_FACTOR,
> >> +               adcmap7_die_temp[i - 1].y);
> >> +       temp += DIE_TEMP_ADC7_SCALE_1 + (DIE_TEMP_ADC7_SCALE_2 * (i - 1));
> >> +       *result_mdec = temp;
> >> +
> >> +       return 0;
> >> +}

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ