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]
Message-ID: <ykyi4qot6nh5nickidkpepwxoeoxey3fdfsybjj4edmldn73no@x3c3cytyzo6n>
Date: Fri, 19 Sep 2025 01:07:18 +0200
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Dzmitry Sankouski <dsankouski@...il.com>
Cc: Chanwoo Choi <cw00.choi@...sung.com>, 
	Krzysztof Kozlowski <krzk@...nel.org>, Lee Jones <lee@...nel.org>, 
	Luca Ceresoli <luca.ceresoli@...tlin.com>, Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>, 
	linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH v4 9/9] power: supply: max77705_charger: implement aicl
 feature

Hi,

On Thu, Sep 18, 2025 at 08:06:53PM +0300, Dzmitry Sankouski wrote:
> Adaptive input current allows charger to reduce it's current
> consumption, when source is not able to provide enough power.
> 
> Signed-off-by: Dzmitry Sankouski <dsankouski@...il.com>
> ---
> Changes in v4:
> - fix intendation
> - use IRQF_TRIGGER_NONE, because this is not physical irq
> - use dev_err_probe instead of pr_err
> - remove excessive chgin irq request
> - remove pr_infos
> ---
>  drivers/power/supply/max77705_charger.c | 58 +++++++++++++++++++++++++++++++++
>  include/linux/power/max77705_charger.h  |  5 +++
>  2 files changed, 63 insertions(+)
> 
> diff --git a/drivers/power/supply/max77705_charger.c b/drivers/power/supply/max77705_charger.c
> index 8032dfa0c9a2..168a67819a51 100644
> --- a/drivers/power/supply/max77705_charger.c
> +++ b/drivers/power/supply/max77705_charger.c
> @@ -40,6 +40,16 @@ static enum power_supply_property max77705_charger_props[] = {
>  	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
>  };
>  
> +static irqreturn_t max77705_aicl_irq(int irq, void *irq_drv_data)
> +{
> +	struct max77705_charger_data *chg = irq_drv_data;

If you do this here:

disable_irq(chg->aicl_irq);

[...]

> +	queue_delayed_work(chg->wqueue, &chg->aicl_work,
> +		     msecs_to_jiffies(AICL_WORK_DELAY));
> +
> +	return IRQ_HANDLED;
> +}
> +
>  static irqreturn_t max77705_chgin_irq(int irq, void *irq_drv_data)
>  {
>  	struct max77705_charger_data *chg = irq_drv_data;
> @@ -445,6 +455,38 @@ static const struct power_supply_desc max77705_charger_psy_desc = {
>  	.set_property		= max77705_set_property,
>  };
>  
> +static void max77705_aicl_isr_work(struct work_struct *work)
> +{
> +	unsigned int regval, irq_status;
> +	int err;
> +	struct max77705_charger_data *chg =
> +		container_of(work, struct max77705_charger_data, aicl_work.work);
> +
> +	regmap_read(chg->regmap, MAX77705_CHG_REG_INT_OK, &irq_status);

[...] You can drop the following code block and completley get rid
of the is_aicl_irq_disabled variable.

> +	if (!chg->is_aicl_irq_disabled) {
> +		disable_irq(chg->aicl_irq);
> +		chg->is_aicl_irq_disabled = true;
> +	}
> +
> +	if (!(irq_status & BIT(MAX77705_AICL_I))) {
> +		err = regmap_field_read(chg->rfield[MAX77705_CHG_CHGIN_LIM], &regval);
> +		if (err < 0)
> +			return;
> +
> +		regval--;
> +
> +		err = regmap_field_write(chg->rfield[MAX77705_CHG_CHGIN_LIM], regval);
> +		if (err < 0)
> +			return;
> +
> +		queue_delayed_work(chg->wqueue, &chg->aicl_work,
> +		     msecs_to_jiffies(AICL_WORK_DELAY));
> +	} else {
> +		enable_irq(chg->aicl_irq);
> +		chg->is_aicl_irq_disabled = false;
> +	}
> +}
> +
>  static void max77705_chgin_isr_work(struct work_struct *work)
>  {
>  	struct max77705_charger_data *chg =
> @@ -617,6 +659,12 @@ static int max77705_charger_probe(struct i2c_client *i2c)
>  		goto destroy_wq;
>  	}
>  
> +	ret = devm_delayed_work_autocancel(dev, &chg->aicl_work, max77705_aicl_isr_work);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "failed to initialize interrupt work\n");
> +		goto destroy_wq;
> +	}
> +
>  	ret = max77705_charger_initialize(chg);
>  	if (ret) {
>  		dev_err_probe(dev, ret, "failed to initialize charger IC\n");
> @@ -632,6 +680,16 @@ static int max77705_charger_probe(struct i2c_client *i2c)
>  		goto destroy_wq;
>  	}
>  
> +	chg->aicl_irq = regmap_irq_get_virq(irq_data, MAX77705_AICL_I);
> +	ret = devm_request_threaded_irq(dev, chg->aicl_irq,
> +					NULL, max77705_aicl_irq,
> +					IRQF_TRIGGER_NONE,
> +					"aicl-irq", chg);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "Failed to Request aicl IRQ\n");
> +		goto destroy_wq;
> +	}
> +
>  	ret = max77705_charger_enable(chg);
>  	if (ret) {
>  		dev_err_probe(dev, ret, "failed to enable charge\n");
> diff --git a/include/linux/power/max77705_charger.h b/include/linux/power/max77705_charger.h
> index 6653abfdf747..92fef95e4ac4 100644
> --- a/include/linux/power/max77705_charger.h
> +++ b/include/linux/power/max77705_charger.h
> @@ -123,6 +123,8 @@
>  #define MAX77705_DISABLE_SKIP		1
>  #define MAX77705_AUTO_SKIP		0
>  
> +#define AICL_WORK_DELAY		100

Add _MS suffix

> +
>  /* uA */
>  #define MAX77705_CURRENT_CHGIN_STEP	25000
>  #define MAX77705_CURRENT_CHG_STEP	50000
> @@ -185,7 +187,10 @@ struct max77705_charger_data {
>  	struct power_supply_battery_info *bat_info;
>  	struct workqueue_struct *wqueue;
>  	struct work_struct	chgin_work;
> +	struct delayed_work	aicl_work;
>  	struct power_supply	*psy_chg;
> +	int			is_aicl_irq_disabled;
> +	int			aicl_irq;
>  };
>  
>  #endif /* __MAX77705_CHARGER_H */

Otherwise LGTM.

Greetings,

-- Sebastian

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