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] [thread-next>] [day] [month] [year] [list]
Message-ID: <p3uryekxe66hd2n7svp4j4laqjaycv5o6qu6b37shwxmiuljur@23o44yw6jmkv>
Date: Thu, 5 Dec 2024 12:01:16 +0100
From: Sebastian Reichel <sre@...nel.org>
To: Csókás, Bence <csokas.bence@...lan.hu>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Samuel Holland <samuel@...lland.org>
Subject: Re: [PATCH v5 5/8] power: ip5xxx_power: Check for optional bits

Hi,

On Tue, Nov 19, 2024 at 07:07:37PM +0100, Csókás, Bence wrote:
> Some parts may not have certain control bits. These bits
> however may be non-essential to the system's operation,
> as the default behaviour is the one we would set anyways,
> or the bits are not applicable for said part (e. g. enabling
> NTC on a part without an NTC pin, or one where it cannot
> be disabled via registers anyways).
> 
> Signed-off-by: Csókás, Bence <csokas.bence@...lan.hu>
> ---
>  drivers/power/supply/ip5xxx_power.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/power/supply/ip5xxx_power.c b/drivers/power/supply/ip5xxx_power.c
> index f64767b81c3b..f47198731a0c 100644
> --- a/drivers/power/supply/ip5xxx_power.c
> +++ b/drivers/power/supply/ip5xxx_power.c
> @@ -113,6 +113,7 @@ struct ip5xxx {
>  	u8 chg_end_inverted;
>  };
>  
> +#define REG_FIELD_UNSUPPORTED { .lsb = 1 }

This belongs into the last patch. I fixed it up while applying the
series.

Greetings,

-- Sebastian

>  /* Register fields layout. Unsupported registers marked as { .lsb = 1 } */
>  struct ip5xxx_regfield_config {
>  	const struct reg_field charger_enable;
> @@ -206,9 +207,11 @@ static int ip5xxx_initialize(struct power_supply *psy)
>  	 * Disable shutdown under light load.
>  	 * Enable power on when under load.
>  	 */
> -	ret = ip5xxx_write(ip5xxx, ip5xxx->regs.boost.light_load_shutdown.enable, 0);
> -	if (ret)
> -		return ret;
> +	if (ip5xxx->regs.boost.light_load_shutdown.enable) {
> +		ret = ip5xxx_write(ip5xxx, ip5xxx->regs.boost.light_load_shutdown.enable, 0);
> +		if (ret)
> +			return ret;
> +	}
>  	ret = ip5xxx_write(ip5xxx, ip5xxx->regs.boost.load_powerup_en, 1);
>  	if (ret)
>  		return ret;
> @@ -231,9 +234,11 @@ static int ip5xxx_initialize(struct power_supply *psy)
>  	 * Enable the NTC.
>  	 * Configure the button for two presses => LED, long press => shutdown.
>  	 */
> -	ret = ip5xxx_write(ip5xxx, ip5xxx->regs.battery.ntc_dis, 0);
> -	if (ret)
> -		return ret;
> +	if (ip5xxx->regs.battery.ntc_dis) {
> +		ret = ip5xxx_write(ip5xxx, ip5xxx->regs.battery.ntc_dis, 0);
> +		if (ret)
> +			return ret;
> +	}
>  	ret = ip5xxx_write(ip5xxx, ip5xxx->regs.btn.wled_mode, 1);
>  	if (ret)
>  		return ret;
> @@ -507,9 +512,12 @@ static int ip5xxx_battery_set_voltage_max(struct ip5xxx *ip5xxx, int val)
>  	if (ret)
>  		return ret;
>  
> -	ret = ip5xxx_write(ip5xxx, ip5xxx->regs.battery.vset_en, 1);
> -	if (ret)
> -		return ret;
> +	/* Don't try to auto-detect battery type, even if the IC could */
> +	if (ip5xxx->regs.battery.vset_en) {
> +		ret = ip5xxx_write(ip5xxx, ip5xxx->regs.battery.vset_en, 1);
> +		if (ret)
> +			return ret;
> +	}
>  
>  	return 0;
>  }
> -- 
> 2.34.1
> 
> 
> 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ