lkml.org 
[lkml]   [2022]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 14/16] power: axp20x_battery: Add constant charge current table
On Sat, Jun 18, 2022 at 11:40 PM Aidan MacDonald
<aidanmacdonald.0x0@gmail.com> wrote:
>
> Add a table-based lookup method for constant charge current,
> which is necessary when the setting cannot be represented as
> a linear range.
>
> This also replaces the hard-coded 300 mA default ccc setting
> if the DT-specified value is unsupported; the minimum value
> for the device is now set exactly instead of relying on the
> value being rounded down to a supported value.

...

> +static int axp20x_get_constant_charge_current_sel(struct axp20x_batt_ps *axp_batt,
> + int charge_current)
> +{
> + int i;
> +
> + if (axp_batt->data->ccc_table) {
> + for (i = AXP20X_CHRG_CTRL1_TGT_CURR; i >= 0; --i) {

i-- should give the same result.

> + if (axp_batt->data->ccc_table[i] <= charge_current)
> + return i;
> + }
> +
> + return -EINVAL;
> + }

> + i = (charge_current - axp_batt->data->ccc_offset) / axp_batt->data->ccc_scale;

> +

No need to have a blank line here.

> + if (i > AXP20X_CHRG_CTRL1_TGT_CURR || i < 0)
> + return -EINVAL;
> +
> + return i;
> +}

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2022-06-19 13:31    [W:0.175 / U:0.056 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site