From: Liam Breck <liam@networkimprov.net>
To: "Andrew F. Davis" <afd@ti.com>, linux-pm@vger.kernel.org
Cc: Liam Breck <kernel@networkimprov.net>
Subject: [PATCH v12.6 09/11] power: bq27xxx_battery: Flag identical register maps when in debug mode
Date: Sun, 9 Apr 2017 22:07:10 -0700 [thread overview]
Message-ID: <20170410050712.930-6-liam@networkimprov.net> (raw)
In-Reply-To: <20170410050712.930-1-liam@networkimprov.net>
From: Liam Breck <kernel@networkimprov.net>
We tie multiple chips to unique register maps. When supporting a new chip,
it's easy to add a duplicate map by mistake.
In debug mode we now scan the register maps for duplicates.
Signed-off-by: Liam Breck <kernel@networkimprov.net>
---
drivers/power/supply/bq27xxx_battery.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/power/supply/bq27xxx_battery.c b/drivers/power/supply/bq27xxx_battery.c
index cebaf59..9b0b6b2 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -1919,6 +1919,25 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)
schedule_delayed_work(&di->work, 0);
}
+#ifdef DEBUG
+static void bq27xxx_battery_dbg_regs_dupes(struct bq27xxx_device_info *di)
+{
+ const size_t max = ARRAY_SIZE(bq27xxx_regs);
+ int a, b;
+
+ for (a = 1; a < max-1; a++) {
+ for (b = a+1; b < max; b++) {
+ if (!memcmp(bq27xxx_regs[a], bq27xxx_regs[b],
+ sizeof(bq27xxx_regs[0])))
+ dev_warn(di->dev,
+ "bq27xxx_regs[%d] & [%d] are identical\n", a, b);
+ }
+ }
+}
+#else
+static inline void bq27xxx_battery_dbg_regs_dupes(struct bq27xxx_device_info *di) {}
+#endif
+
int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
{
struct power_supply_desc *psy_desc;
@@ -1927,6 +1946,8 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
.drv_data = di,
};
+ bq27xxx_battery_dbg_regs_dupes(di);
+
di->unseal_key = bq27xxx_unseal_keys[di->chip];
di->dm_regs = bq27xxx_dm_regs[di->chip];
di->chip = bq27xxx_chips[di->chip];
--
2.9.3
next prev parent reply other threads:[~2017-04-10 5:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 5:07 [PATCH v12.6 0/11] bq27xxx_battery partial series Liam Breck
2017-04-10 5:07 ` [PATCH v12.6 05/11] power: bq27xxx_battery: Add chip data memory read/write support Liam Breck
2017-04-10 14:47 ` Andrew F. Davis
2017-04-10 5:07 ` [PATCH v12.6 06/11] power: bq27xxx_battery: Add power_supply_battery_info support Liam Breck
2017-04-10 5:07 ` [PATCH v12.6 07/11] power: bq27xxx_battery: Enable data memory update for certain chips Liam Breck
2017-04-10 5:07 ` [PATCH v12.6 08/11] devicetree: power: bq27xxx: Add monitored-battery documentation Liam Breck
2017-04-13 20:15 ` Rob Herring
2017-04-10 5:07 ` Liam Breck [this message]
2017-04-10 5:07 ` [PATCH v12.6 10/11] power: bq27xxx_battery: Remove duplicate register arrays Liam Breck
2017-04-10 5:07 ` [PATCH v12.6 11/11] power: bq27xxx_battery: Disable flash/NVM data memory update Liam Breck
2017-04-10 14:46 ` [PATCH v12.6 0/11] bq27xxx_battery partial series Andrew F. Davis
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=20170410050712.930-6-liam@networkimprov.net \
--to=liam@networkimprov.net \
--cc=afd@ti.com \
--cc=kernel@networkimprov.net \
--cc=linux-pm@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).