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: <20200728001807.zjyfgz2sphcysgx5@earth.universe>
Date:   Tue, 28 Jul 2020 02:18:07 +0200
From:   Sebastian Reichel <sre@...nel.org>
To:     Matheus Castello <matheus@...tello.eng.br>
Cc:     linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH v1] power: supply: max17040: Add
 POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN

Hi,

On Sun, Jul 05, 2020 at 09:10:03PM -0300, Matheus Castello wrote:
> Adds the property POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN to export the
> chip->low_soc_alert and add the property as writeable, implementing
> max17040_prop_writeable and max17040_set_property, so with that the
> user space can readjust the alerts.
> 
> Signed-off-by: Matheus Castello <matheus@...tello.eng.br>
> ---

Thanks, queued.

-- Sebastian

>  drivers/power/supply/max17040_battery.c | 51 ++++++++++++++++++++++---
>  1 file changed, 46 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c
> index 48aa44665e2f..6cb31b9a958d 100644
> --- a/drivers/power/supply/max17040_battery.c
> +++ b/drivers/power/supply/max17040_battery.c
> @@ -69,6 +69,9 @@ static int max17040_get_property(struct power_supply *psy,
>  	case POWER_SUPPLY_PROP_CAPACITY:
>  		val->intval = chip->soc;
>  		break;
> +	case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
> +		val->intval = chip->low_soc_alert;
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> @@ -256,19 +259,57 @@ static int max17040_enable_alert_irq(struct max17040_chip *chip)
>  	return ret;
>  }
> 
> +static int max17040_prop_writeable(struct power_supply *psy,
> +				   enum power_supply_property psp)
> +{
> +	switch (psp) {
> +	case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
> +		return 1;
> +	default:
> +		return 0;
> +	}
> +}
> +
> +static int max17040_set_property(struct power_supply *psy,
> +			    enum power_supply_property psp,
> +			    const union power_supply_propval *val)
> +{
> +	struct max17040_chip *chip = power_supply_get_drvdata(psy);
> +	int ret;
> +
> +	switch (psp) {
> +	case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN:
> +		/* alert threshold can be programmed from 1% up to 32% */
> +		if ((val->intval < 1) || (val->intval > 32)) {
> +			ret = -EINVAL;
> +			break;
> +		}
> +		ret = max17040_set_low_soc_alert(chip->client, val->intval);
> +		chip->low_soc_alert = val->intval;
> +		break;
> +	default:
> +		ret = -EINVAL;
> +	}
> +
> +	return ret;
> +}
> +
>  static enum power_supply_property max17040_battery_props[] = {
>  	POWER_SUPPLY_PROP_STATUS,
>  	POWER_SUPPLY_PROP_ONLINE,
>  	POWER_SUPPLY_PROP_VOLTAGE_NOW,
>  	POWER_SUPPLY_PROP_CAPACITY,
> +	POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN,
>  };
> 
>  static const struct power_supply_desc max17040_battery_desc = {
> -	.name		= "battery",
> -	.type		= POWER_SUPPLY_TYPE_BATTERY,
> -	.get_property	= max17040_get_property,
> -	.properties	= max17040_battery_props,
> -	.num_properties	= ARRAY_SIZE(max17040_battery_props),
> +	.name			= "battery",
> +	.type			= POWER_SUPPLY_TYPE_BATTERY,
> +	.get_property		= max17040_get_property,
> +	.set_property		= max17040_set_property,
> +	.property_is_writeable  = max17040_prop_writeable,
> +	.properties		= max17040_battery_props,
> +	.num_properties		= ARRAY_SIZE(max17040_battery_props),
>  };
> 
>  static int max17040_probe(struct i2c_client *client,
> --
> 2.27.0
> 

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