From: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
To: Liam Breck <liam@networkimprov.net>
Cc: "Pali Rohár" <pali.rohar@gmail.com>,
linux-pm@vger.kernel.org, "Paul Kocialkowski" <contact@paulk.fr>,
"Liam Breck" <kernel@networkimprov.net>
Subject: Re: [RFC v1 4/6] power: supply: bq27xxx: Add chip data options for cfgupdate & ram-only
Date: Tue, 25 Jul 2017 13:24:58 +0200 [thread overview]
Message-ID: <20170725112458.m7k2h6o4yz3z4kp6@earth> (raw)
In-Reply-To: <20170709021700.14354-5-liam@networkimprov.net>
[-- Attachment #1: Type: text/plain, Size: 4299 bytes --]
Hi,
On Sat, Jul 08, 2017 at 07:16:58PM -0700, Liam Breck wrote:
> From: Liam Breck <kernel@networkimprov.net>
>
> Add BQ27XXX_O_CFGUP & _O_RAM for use in bq27xxx_chip_data[n].opts
> Replace related uses of di->chip == BQ27nnn with (BQ27XXX_O_XYZ & di->opts)
In the kernel we prefer (variable & mask), so it should be (di->opts
& BQ27XXX_O_XYZ). Otherwise looks good.
-- Sebastian
> No functional changes to the driver.
>
> Signed-off-by: Liam Breck <kernel@networkimprov.net>
> ---
> drivers/power/supply/bq27xxx_battery.c | 22 +++++++++++-----------
> include/linux/power/bq27xxx_battery.h | 1 -
> 2 files changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
> index 0bd46fae..5d3893a9 100644
> --- a/drivers/power/supply/bq27xxx_battery.c
> +++ b/drivers/power/supply/bq27xxx_battery.c
> @@ -871,6 +871,9 @@ static struct bq27xxx_dm_reg bq27621_dm_regs[] = {
> #define bq27621_dm_regs 0
> #endif
>
> +#define BQ27XXX_O_CFGUP 0x00000001
> +#define BQ27XXX_O_RAM 0x00000002
> +
> #define BQ27XXX_DATA(ref, act, key, opt) { \
> .opts = (opt), \
> .acts_like = act, \
> @@ -909,10 +912,10 @@ static struct {
> [BQ27546] = BQ27XXX_DATA(546, BQ27541, 0, 0),
> [BQ27742] = BQ27XXX_DATA(742, BQ27541, 0, 0),
> [BQ27545] = BQ27XXX_DATA(545, 0, 0x04143672, 0),
> - [BQ27421] = BQ27XXX_DATA(421, 0, 0x80008000, 0),
> - [BQ27425] = BQ27XXX_DATA(425, BQ27421, 0x04143672, 0),
> - [BQ27441] = BQ27XXX_DATA(441, BQ27421, 0x80008000, 0),
> - [BQ27621] = BQ27XXX_DATA(621, BQ27421, 0x80008000, 0),
> + [BQ27421] = BQ27XXX_DATA(421, 0, 0x80008000, BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
> + [BQ27425] = BQ27XXX_DATA(425, BQ27421, 0x04143672, BQ27XXX_O_CFGUP),
> + [BQ27441] = BQ27XXX_DATA(441, BQ27421, 0x80008000, BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
> + [BQ27621] = BQ27XXX_DATA(621, BQ27421, 0x80008000, BQ27XXX_O_CFGUP | BQ27XXX_O_RAM),
> };
>
> static DEFINE_MUTEX(bq27xxx_list_lock);
> @@ -1196,9 +1199,9 @@ static void bq27xxx_battery_update_dm_block(struct bq27xxx_device_info *di,
> }
>
> #ifdef CONFIG_BATTERY_BQ27XXX_DT_UPDATES_NVM
> - if (!di->ram_chip && !bq27xxx_dt_to_nvm) {
> + if (!(BQ27XXX_O_RAM & di->opts) && !bq27xxx_dt_to_nvm) {
> #else
> - if (!di->ram_chip) {
> + if (!(BQ27XXX_O_RAM & di->opts)) {
> #endif
> /* devicetree and NVM differ; defer to NVM */
> dev_warn(di->dev, "%s has %u; update to %u disallowed "
> @@ -1266,7 +1269,7 @@ static inline int bq27xxx_battery_soft_reset(struct bq27xxx_device_info *di)
> static int bq27xxx_battery_write_dm_block(struct bq27xxx_device_info *di,
> struct bq27xxx_dm_buf *buf)
> {
> - bool cfgup = di->chip == BQ27421; /* assume related chips need cfgupdate */
> + bool cfgup = BQ27XXX_O_CFGUP & di->opts;
> int ret;
>
> if (!buf->dirty)
> @@ -1365,7 +1368,7 @@ static void bq27xxx_battery_set_config(struct bq27xxx_device_info *di,
>
> bq27xxx_battery_seal(di);
>
> - if (updated && di->chip != BQ27421) { /* not a cfgupdate chip, so reset */
> + if (updated && !(BQ27XXX_O_CFGUP & di->opts)) {
> bq27xxx_write(di, BQ27XXX_REG_CTRL, BQ27XXX_RESET, false);
> BQ27XXX_MSLEEP(300); /* reset time is not documented */
> }
> @@ -1993,9 +1996,6 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
> di->unseal_key = bq27xxx_chip_data[di->chip].unseal_key;
> di->dm_regs = bq27xxx_chip_data[di->chip].dm_regs;
> di->opts = bq27xxx_chip_data[di->chip].opts;
> - di->ram_chip = di->chip == BQ27421 ||
> - di->chip == BQ27441 ||
> - di->chip == BQ27621;
>
> psy_desc = devm_kzalloc(di->dev, sizeof(*psy_desc), GFP_KERNEL);
> if (!psy_desc)
> diff --git a/include/linux/power/bq27xxx_battery.h b/include/linux/power/bq27xxx_battery.h
> index 77fe94f1..8a8a3f61 100644
> --- a/include/linux/power/bq27xxx_battery.h
> +++ b/include/linux/power/bq27xxx_battery.h
> @@ -71,7 +71,6 @@ struct bq27xxx_device_info {
> struct device *dev;
> int id;
> enum bq27xxx_chip chip;
> - bool ram_chip;
> u32 opts;
> const char *name;
> struct bq27xxx_dm_reg *dm_regs;
> --
> 2.13.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2017-07-25 11:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-09 2:16 [RFC v1 0/6] bq27xxx_battery data memory update Liam Breck
2017-07-09 2:16 ` [RFC v1 1/6] power: supply: bq27xxx: Create single chip data table Liam Breck
2017-07-25 11:21 ` Sebastian Reichel
2017-07-09 2:16 ` [RFC v1 2/6] power: supply: bq27xxx: Add chip IDs for previously shadowed chips Liam Breck
2017-07-25 12:52 ` Sebastian Reichel
2017-07-09 2:16 ` [RFC v1 3/6] power: supply: bq27xxx: Enable data memory update for certain chips Liam Breck
2017-07-09 9:07 ` Pali Rohár
2017-07-09 14:13 ` Liam Breck
2017-07-09 15:12 ` Pali Rohár
2017-07-25 11:17 ` Sebastian Reichel
2017-07-09 2:16 ` [RFC v1 4/6] power: supply: bq27xxx: Add chip data options for cfgupdate & ram-only Liam Breck
2017-07-25 11:24 ` Sebastian Reichel [this message]
2017-07-09 2:16 ` [RFC v1 5/6] power: supply: bq27xxx: Flag identical chip data when in debug mode Liam Breck
2017-07-25 13:04 ` Sebastian Reichel
2017-07-09 2:17 ` [RFC v1 6/6] power: supply: bq27xxx: Remove duplicate chip data arrays Liam Breck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170725112458.m7k2h6o4yz3z4kp6@earth \
--to=sebastian.reichel@collabora.co.uk \
--cc=contact@paulk.fr \
--cc=kernel@networkimprov.net \
--cc=liam@networkimprov.net \
--cc=linux-pm@vger.kernel.org \
--cc=pali.rohar@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox