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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 12 Sep 2023 22:37:38 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
Cc:     Alexandre Courbot <acourbot@...dia.com>,
        azkali <a.ffcc7@...il.com>, CTCaer <ctcaer@...il.com>,
        Sebastian Reichel <sre@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Conor Dooley <conor+dt@...nel.org>, linux-pm@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/3] power: supply: bq24190_charger: Export current
 regulator

Le 24/08/2023 à 15:13, Emmanuel Gil Peyrot a écrit :
> From: Alexandre Courbot <acourbot@...dia.com>
> 
> This prevents the charger from ever going over the current limit.
> 
> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
> Signed-off-by: Emmanuel Gil Peyrot <linkmauve@...kmauve.fr>
> ---
>   drivers/power/supply/bq24190_charger.c | 82 ++++++++++++++++++++++++++
>   1 file changed, 82 insertions(+)
> 
> diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
> index a56122b39687..cc1bd87f4982 100644
> --- a/drivers/power/supply/bq24190_charger.c
> +++ b/drivers/power/supply/bq24190_charger.c
> @@ -530,6 +530,79 @@ static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
>   }
>   
>   #ifdef CONFIG_REGULATOR
> +static int bq24190_set_charging_current(struct regulator_dev *dev,
> +			int min_uA, int max_uA)
> +{
> +	struct bq24190_dev_info *bdi = rdev_get_drvdata(dev);
> +	u8 ss_reg;
> +	int in_current_limit;
> +	int ret = 0;

Nit: Un-needed init.

> +
> +	ret = bq24190_read(bdi, BQ24190_REG_SS, &ss_reg);
> +	if (ret < 0)
> +		goto error;
> +
> +	if (max_uA == 0 && ss_reg != 0)
> +		return ret;

ret is known to be 0 here. If it is the intension, return 0 would be 
more explicit. Otherwise a ret = -<error_code> is missing.

Just my 2c,

CJ

> +
> +	if (!(ss_reg & BQ24190_REG_SS_VBUS_STAT_MASK))
> +		in_current_limit = 500;
> +	else
> +		in_current_limit = max_uA / 1000;
> +
> +	return bq24190_set_field_val(bdi, BQ24190_REG_ISC,
> +			BQ24190_REG_ISC_IINLIM_MASK,
> +			BQ24190_REG_ISC_IINLIM_SHIFT,
> +			bq24190_isc_iinlim_values,
> +			ARRAY_SIZE(bq24190_isc_iinlim_values),
> +			in_current_limit);
> +error:
> +	dev_err(bdi->dev, "Charger enable failed, err = %d\n", ret);
> +	return ret;
> +}

...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ