Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp112505ybg; Mon, 27 Jul 2020 17:19:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVG30VmFRqUsLDldNM3VdyqdBsiFIOtKENc/TDARDwdBZq7Sjf5fK62cazkxfcIxPXTRR5 X-Received: by 2002:aa7:d7cf:: with SMTP id e15mr24094096eds.236.1595895543312; Mon, 27 Jul 2020 17:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595895543; cv=none; d=google.com; s=arc-20160816; b=KyK43aSxjg3yejPNYhUeEI9oeu/cNSg7+WMBSKcA+p+ou0YZ7RZRph9a6h+/AGInm3 tndVQbdUS5slc4cMD3PBWLy0WFFx3VQlh1yDh0SLrr4a6TSeNAiOAw0CcfkhnAmL0JQN NhAs1xSXvTWU5kKDz0KWHBaRaWclrNQ7YGkjImV5JJJ+1SMR+jPoTytStGgmN6DbbeRJ d6arNkdQF/1Ee5spuK7jg3ORvQGSF9pyJHYMJPB9gOub00PlE4jHJ5/gUWrQ2RMcOomh oY91lzdFo4QELvL0+vR1Uf4ghRr+OJGn7ONDz21g+qg6nREF47OCDSNS9HkIHrfhOyGw AIsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qaqT2HL+djm0NxH3gU4ZFK4ok9Hs1QLY2RB9Nac+24Q=; b=vbgoB7BY6ctrBV0cRWU7dt/8KGqwBaCHyMgyMKD6qJnVXXbrmXeFtIJ7S7SbGCXnvO iqYZFXoQ9mRGvPldGEnei9u/PGkazG/ZaefFt3Bg6k7yHna34ylzP/2AjPekgTwgo1yL pOT31WcFxjNci3KzjyQOWpWD8EKHPkwS1EYATlF8oKFxVzZB3H4udZL3I2THpESml1aF KlJngGHlcw8HThoDMFcXSWCjeEYNOrDC7dIrgijRsu5kOBd6cFUme5OydU1nzvsfUeHF 7dYe0Jw4AXQY5SZb6kaovxhOGFJL7FQc90dj1LY4atGXdayL2PZG1FeVAeuB+++6QIRU 4ZTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rtGWh2cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n24si6615485edt.561.2020.07.27.17.18.41; Mon, 27 Jul 2020 17:19:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rtGWh2cb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbgG1ASL (ORCPT + 99 others); Mon, 27 Jul 2020 20:18:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:49342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbgG1ASK (ORCPT ); Mon, 27 Jul 2020 20:18:10 -0400 Received: from earth.universe (unknown [185.213.155.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4189020786; Tue, 28 Jul 2020 00:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595895489; bh=wWr2t+myCz/OZLXxwsQOJSX9Lblh8zNQcneKG8XmBR8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rtGWh2cbv6sHXFH7lMi8Ke5ENZAG2MDClKJhz029nioffMK3RxaZj6CpDcNJOkUMe wBF0FR54wPfAnBYx34anG0/CNSO7x4VNbf74TG44Kr8AiNsprdNc6IL4WJAHa3dazh We6B8GwdI7WEuCRJLTpCJyueb61QSAKXknhBPw0A= Received: by earth.universe (Postfix, from userid 1000) id 7CBFD3C0B87; Tue, 28 Jul 2020 02:18:07 +0200 (CEST) Date: Tue, 28 Jul 2020 02:18:07 +0200 From: Sebastian Reichel To: Matheus Castello Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v1] power: supply: max17040: Add POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN Message-ID: <20200728001807.zjyfgz2sphcysgx5@earth.universe> References: <20200706001003.663763-1-matheus@castello.eng.br> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vnx7d7i7pnisscty" Content-Disposition: inline In-Reply-To: <20200706001003.663763-1-matheus@castello.eng.br> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --vnx7d7i7pnisscty Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Matheus Castello > --- Thanks, queued. -- Sebastian > drivers/power/supply/max17040_battery.c | 51 ++++++++++++++++++++++--- > 1 file changed, 46 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supp= ly/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 *p= sy, > case POWER_SUPPLY_PROP_CAPACITY: > val->intval =3D chip->soc; > break; > + case POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN: > + val->intval =3D chip->low_soc_alert; > + break; > default: > return -EINVAL; > } > @@ -256,19 +259,57 @@ static int max17040_enable_alert_irq(struct max1704= 0_chip *chip) > return ret; > } >=20 > +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 =3D 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 =3D -EINVAL; > + break; > + } > + ret =3D max17040_set_low_soc_alert(chip->client, val->intval); > + chip->low_soc_alert =3D val->intval; > + break; > + default: > + ret =3D -EINVAL; > + } > + > + return ret; > +} > + > static enum power_supply_property max17040_battery_props[] =3D { > POWER_SUPPLY_PROP_STATUS, > POWER_SUPPLY_PROP_ONLINE, > POWER_SUPPLY_PROP_VOLTAGE_NOW, > POWER_SUPPLY_PROP_CAPACITY, > + POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, > }; >=20 > static const struct power_supply_desc max17040_battery_desc =3D { > - .name =3D "battery", > - .type =3D POWER_SUPPLY_TYPE_BATTERY, > - .get_property =3D max17040_get_property, > - .properties =3D max17040_battery_props, > - .num_properties =3D ARRAY_SIZE(max17040_battery_props), > + .name =3D "battery", > + .type =3D POWER_SUPPLY_TYPE_BATTERY, > + .get_property =3D max17040_get_property, > + .set_property =3D max17040_set_property, > + .property_is_writeable =3D max17040_prop_writeable, > + .properties =3D max17040_battery_props, > + .num_properties =3D ARRAY_SIZE(max17040_battery_props), > }; >=20 > static int max17040_probe(struct i2c_client *client, > -- > 2.27.0 >=20 --vnx7d7i7pnisscty Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE72YNB0Y/i3JqeVQT2O7X88g7+poFAl8fbr8ACgkQ2O7X88g7 +prB2w//XmjG/PbpXEnkEr9h9fHUQ3Str1QbxDFn+3JPh9W9G4RT+4caMAVS240t NdIOpfZP7ZvpyPksHP5FHavBxTTgtz+jhly38PZajKSMH20kdIqSeRH2wOscn+dI 9LlXMX3Q417sC6+CvFprwrjZ4yWjMn8XBsnzvQtjzESuYhfHJrM8N0HpiaHrnWIl lmQYfSWTQ0Z94ikPP5COG074Ahhc+Mw8az/kE+QnGT/ToXVlv4VG3mLYJggaNeSN /BdywhelGennvrgwPWU6nzZ21HU+OBhYnKDxq6opXgbNhaCHA8dqSERIbl/AP4+R +4g3ODrD4swvNY+/VzvcJjQ+Q8yRX/EbSeAqwK1sta1gAj4g+lLFXdtNaBopBJo3 DaRttGLxERvrIbJs2smIjrorTeO5ndn8W8a8iA39uAPqrJxr4zRqYGwdlCBh/hco 3O3Q8kDGvSQcqawrVtB3FZtJLyd916ltitoNVUaXuQxGBbKvoLIfaguTYU86rvZ6 hmTXfEiScuFbyB7WZ99ssGEtMOY4gD6v2gEEBskwZUC6ppVI7kz7SH/XN4RdQ9+E CABVPBTX4jHNUeG/0gDc1yuwOZY/fWqF7HS7QK6vh5o4jPB9MVWD3flb6ppW+PVS aT6c6JrSNEjWNQsV2ETm044Xcjl9OvpEk6goP3AfqoDKTjRLJKs= =fqVI -----END PGP SIGNATURE----- --vnx7d7i7pnisscty--