From: Arnd Bergmann <arnd@arndb.de>
To: Mark Brown <broonie@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
Arnd Bergmann <arnd@arndb.de>,
Liam Girdwood <lgirdwood@gmail.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH] regulator: return NULL for dummy bulk_get operation
Date: Mon, 25 Jan 2016 16:58:50 +0100 [thread overview]
Message-ID: <1453737537-1960121-1-git-send-email-arnd@arndb.de> (raw)
Drivers that call regulator_bulk_get or devm_regulator_bulk_get when
CONFIG_REGULATOR is disabled see the function return successfully, but
cannot use the "consumer" pointers that are meant to be returned from
the functions, as the values are uninitialized. Gcc warns about this:
drivers/usb/phy/phy-qcom-8x16-usb.c: In function 'phy_8x16_probe':
drivers/usb/phy/phy-qcom-8x16-usb.c:284:13: error: 'regs[0].consumer' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/usb/phy/phy-qcom-8x16-usb.c:285:13: error: 'regs[1].consumer' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/usb/phy/phy-qcom-8x16-usb.c:286:12: error: 'regs[2].consumer' may be used uninitialized in this function [-Werror=maybe-uninitialized]
To make the code behave in a reproducible way, this changes the
two dummy function to behave like the non-bulk regulator_get
and devm_regulator_get functions to, returning a NULL pointer with
a successful return code. This also gets rid of the warnings.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/linux/regulator/consumer.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 48603506f8de..f4774bf707c2 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -404,13 +404,17 @@ static inline int regulator_bulk_get(struct device *dev,
int num_consumers,
struct regulator_bulk_data *consumers)
{
+ int i;
+ for (i=0; i < num_consumers; i++)
+ consumers[i].consumer = NULL;
+
return 0;
}
static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
struct regulator_bulk_data *consumers)
{
- return 0;
+ return regulator_bulk_get(dev, num_consumers, consumers);
}
static inline int regulator_bulk_enable(int num_consumers,
--
2.7.0
next reply other threads:[~2016-01-25 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-25 15:58 Arnd Bergmann [this message]
2016-01-26 12:04 ` Mark Brown
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=1453737537-1960121-1-git-send-email-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®