[PATCH v3 06/11] power: supply: bq257xx: Make the default current limit a per-chip attribute

Alexey Charkov posted 11 patches 4 weeks, 1 day ago
There is a newer version of this series
[PATCH v3 06/11] power: supply: bq257xx: Make the default current limit a per-chip attribute
Posted by Alexey Charkov 4 weeks, 1 day ago
Add a field for the default current limit to the bq257xx_info structure and
use it instead of the hardcoded value in the probe function.

This prepares the driver for allowing different electrical constraints for
different chip variants.

Tested-by: Chris Morgan <macromorgan@hotmail.com>
Signed-off-by: Alexey Charkov <alchark@flipper.net>
---
 drivers/power/supply/bq257xx_charger.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq257xx_charger.c b/drivers/power/supply/bq257xx_charger.c
index 7ca4ae610902..e14dd16f9d08 100644
--- a/drivers/power/supply/bq257xx_charger.c
+++ b/drivers/power/supply/bq257xx_charger.c
@@ -26,6 +26,7 @@ struct bq257xx_chg;
  * @bq257xx_set_iindpm: set maximum input current (in uA)
  */
 struct bq257xx_chip_info {
+	int default_iindpm_uA;
 	int (*bq257xx_hw_init)(struct bq257xx_chg *pdata);
 	void (*bq257xx_hw_shutdown)(struct bq257xx_chg *pdata);
 	int (*bq257xx_get_state)(struct bq257xx_chg *pdata);
@@ -627,6 +628,7 @@ static const struct power_supply_desc bq257xx_power_supply_desc = {
 };
 
 static const struct bq257xx_chip_info bq25703_chip_info = {
+		.default_iindpm_uA = BQ25703_IINDPM_DEFAULT_UA,
 		.bq257xx_hw_init = &bq25703_hw_init,
 		.bq257xx_hw_shutdown = &bq25703_hw_shutdown,
 		.bq257xx_get_state = &bq25703_get_state,
@@ -675,7 +677,7 @@ static int bq257xx_parse_dt(struct bq257xx_chg *pdata,
 				       "input-current-limit-microamp",
 				       &pdata->iindpm_max);
 	if (ret)
-		pdata->iindpm_max = BQ25703_IINDPM_DEFAULT_UA;
+		pdata->iindpm_max = pdata->chip->default_iindpm_uA;
 
 	return 0;
 }

-- 
2.52.0
Re: [PATCH v3 06/11] power: supply: bq257xx: Make the default current limit a per-chip attribute
Posted by Sebastian Reichel 4 weeks, 1 day ago
Hi,

On Tue, Mar 10, 2026 at 01:28:30PM +0400, Alexey Charkov wrote:
> Add a field for the default current limit to the bq257xx_info structure and
> use it instead of the hardcoded value in the probe function.
> 
> This prepares the driver for allowing different electrical constraints for
> different chip variants.
> 
> Tested-by: Chris Morgan <macromorgan@hotmail.com>
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/power/supply/bq257xx_charger.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/power/supply/bq257xx_charger.c b/drivers/power/supply/bq257xx_charger.c
> index 7ca4ae610902..e14dd16f9d08 100644
> --- a/drivers/power/supply/bq257xx_charger.c
> +++ b/drivers/power/supply/bq257xx_charger.c
> @@ -26,6 +26,7 @@ struct bq257xx_chg;
>   * @bq257xx_set_iindpm: set maximum input current (in uA)
>   */
>  struct bq257xx_chip_info {
> +	int default_iindpm_uA;
>  	int (*bq257xx_hw_init)(struct bq257xx_chg *pdata);
>  	void (*bq257xx_hw_shutdown)(struct bq257xx_chg *pdata);
>  	int (*bq257xx_get_state)(struct bq257xx_chg *pdata);
> @@ -627,6 +628,7 @@ static const struct power_supply_desc bq257xx_power_supply_desc = {
>  };
>  
>  static const struct bq257xx_chip_info bq25703_chip_info = {
> +		.default_iindpm_uA = BQ25703_IINDPM_DEFAULT_UA,
>  		.bq257xx_hw_init = &bq25703_hw_init,
>  		.bq257xx_hw_shutdown = &bq25703_hw_shutdown,
>  		.bq257xx_get_state = &bq25703_get_state,
> @@ -675,7 +677,7 @@ static int bq257xx_parse_dt(struct bq257xx_chg *pdata,
>  				       "input-current-limit-microamp",
>  				       &pdata->iindpm_max);
>  	if (ret)
> -		pdata->iindpm_max = BQ25703_IINDPM_DEFAULT_UA;
> +		pdata->iindpm_max = pdata->chip->default_iindpm_uA;
>  
>  	return 0;
>  }
> 
> -- 
> 2.52.0
> 
>