* [PATCH] regulator: max8907: fix compile error when !CONFIG_OF
@ 2012-08-20 15:39 Stephen Warren
2012-08-20 19:57 ` Mark Brown
2012-08-21 1:21 ` Axel Lin
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Warren @ 2012-08-20 15:39 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: linux-kernel, Axel Lin, Gyungoh Yoo, Laxman Dewangan,
Stephen Warren
From: Stephen Warren <swarren@nvidia.com>
Fix the following:
CC [M] drivers/regulator/max8907-regulator.o
drivers/regulator/max8907-regulator.c: In function 'max8907_regulator_probe':
drivers/regulator/max8907-regulator.c:297:12: error: 'max8907_matches' undeclared (first use in this function)
by removing direct references to max8907_matches[], which only exists when
CONFIG_OF is defined.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
Note: It's possible that the MAX8907 PMIC is only used with Tegra; there
certainly is a reference to AP15 (an old Tegra version) in the MAX8907
documentation. If so, Tegra implies CONFIG_OF, so we could just make
MAX8907 depend on CONFIG_OF and remove all the ifdefs from the driver.
That said, I'm not at all sure whether the MAX8907 is Tegra-specific.
---
drivers/regulator/max8907-regulator.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c
index 831488f..0d03e71 100644
--- a/drivers/regulator/max8907-regulator.c
+++ b/drivers/regulator/max8907-regulator.c
@@ -248,11 +248,31 @@ static int max8907_regulator_parse_dt(struct platform_device *pdev)
return 0;
}
+
+static inline struct regulator_init_data *match_init_data(int index)
+{
+ return max8907_matches[index].init_data;
+}
+
+static inline struct device_node *match_of_node(int index)
+{
+ return max8907_matches[index].of_node;
+}
#else
static int max8907_regulator_parse_dt(struct platform_device *pdev)
{
return 0;
}
+
+static inline struct regulator_init_data *match_init_data(int index)
+{
+ return NULL;
+}
+
+static inline struct device_node *match_of_node(int index)
+{
+ return NULL;
+}
#endif
static __devinit int max8907_regulator_probe(struct platform_device *pdev)
@@ -294,11 +314,11 @@ static __devinit int max8907_regulator_probe(struct platform_device *pdev)
if (pdata)
idata = pdata->init_data[i];
else
- idata = max8907_matches[i].init_data;
+ idata = match_init_data(i);
config.init_data = idata;
config.driver_data = pmic;
config.regmap = max8907->regmap_gen;
- config.of_node = max8907_matches[i].of_node;
+ config.of_node = match_of_node(i);
switch (pmic->desc[i].id) {
case MAX8907_MBATT:
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: max8907: fix compile error when !CONFIG_OF
2012-08-20 15:39 [PATCH] regulator: max8907: fix compile error when !CONFIG_OF Stephen Warren
@ 2012-08-20 19:57 ` Mark Brown
2012-08-21 1:21 ` Axel Lin
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-08-20 19:57 UTC (permalink / raw)
To: Stephen Warren
Cc: Liam Girdwood, linux-kernel, Axel Lin, Gyungoh Yoo,
Laxman Dewangan, Stephen Warren
[-- Attachment #1: Type: text/plain, Size: 688 bytes --]
On Mon, Aug 20, 2012 at 09:39:10AM -0600, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
>
> Fix the following:
Applied, thanks.
> Note: It's possible that the MAX8907 PMIC is only used with Tegra; there
> certainly is a reference to AP15 (an old Tegra version) in the MAX8907
> documentation. If so, Tegra implies CONFIG_OF, so we could just make
> MAX8907 depend on CONFIG_OF and remove all the ifdefs from the driver.
> That said, I'm not at all sure whether the MAX8907 is Tegra-specific.
I think this would be a step backwards, if it's that hard to make DT
optional we ought to look at the DT infrastructure. Otherwise build
coverage is good.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] regulator: max8907: fix compile error when !CONFIG_OF
2012-08-20 15:39 [PATCH] regulator: max8907: fix compile error when !CONFIG_OF Stephen Warren
2012-08-20 19:57 ` Mark Brown
@ 2012-08-21 1:21 ` Axel Lin
1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-08-21 1:21 UTC (permalink / raw)
To: Stephen Warren
Cc: Mark Brown, Liam Girdwood, linux-kernel, Gyungoh Yoo,
Laxman Dewangan, Stephen Warren
> +
> +static inline struct regulator_init_data *match_init_data(int index)
> +{
> + return NULL;
> +}
> +
Now match_init_data() returns NULL if !CONFIG_OF, so idata may be NULL.
Then I think we may hit NULL pointer dereference here:
switch (pmic->desc[i].id) {
case MAX8907_MBATT:
mbatt_rail_name = idata->constraints.name;
break;
Regards,
Axel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-21 1:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-20 15:39 [PATCH] regulator: max8907: fix compile error when !CONFIG_OF Stephen Warren
2012-08-20 19:57 ` Mark Brown
2012-08-21 1:21 ` Axel Lin
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).