* [PATCH] mfd: max8997: Enforce mfd_add_devices() return value check
@ 2013-12-17 12:45 Laszlo Papp
0 siblings, 0 replies; 3+ messages in thread
From: Laszlo Papp @ 2013-12-17 12:45 UTC (permalink / raw)
To: sameo, lee.jones; +Cc: linux-kernel, Laszlo Papp
The original author provided a random return value check which is
redundant and seemingly floating. This patch not only relocates
the check so it is more clearly associated with the invokation of
mfd_add_devices(), but provides a store for the error value. We
also print a meaningful message on error before returning.
Signed-off-by: Laszlo Papp <lpapp@kde.org>
---
drivers/mfd/max8997.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 791aea3..ace1a2b 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -227,19 +227,19 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
pm_runtime_set_active(max8997->dev);
max8997_irq_init(max8997);
-
- mfd_add_devices(max8997->dev, -1, max8997_devs,
+ ret = mfd_add_devices(max8997->dev, -1, max8997_devs,
ARRAY_SIZE(max8997_devs),
NULL, 0, NULL);
+ if (ret < 0) {
+ dev_err(max8997->dev, "cannot add mfd cells\n");
+ goto err_mfd;
+ }
/*
* TODO: enable others (flash, muic, rtc, battery, ...) and
* check the return value
*/
- if (ret < 0)
- goto err_mfd;
-
/* MAX8997 has a power button input. */
device_init_wakeup(max8997->dev, pdata->wakeup);
--
1.8.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] mfd: max8997: Enforce mfd_add_devices() return value check
@ 2013-12-17 12:49 Laszlo Papp
2013-12-17 13:23 ` Lee Jones
0 siblings, 1 reply; 3+ messages in thread
From: Laszlo Papp @ 2013-12-17 12:49 UTC (permalink / raw)
To: sameo, lee.jones; +Cc: linux-kernel, Laszlo Papp
The original author provided a random return value check which is
redundant and seemingly floating. This patch not only relocates
the check so it is more clearly associated with the invokation of
mfd_add_devices(), but provides a store for the error value. We
also print a meaningful message on error before returning.
Signed-off-by: Laszlo Papp <lpapp@kde.org>
---
drivers/mfd/max8997.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/max8997.c b/drivers/mfd/max8997.c
index 791aea3..7846460 100644
--- a/drivers/mfd/max8997.c
+++ b/drivers/mfd/max8997.c
@@ -228,18 +228,19 @@ static int max8997_i2c_probe(struct i2c_client *i2c,
max8997_irq_init(max8997);
- mfd_add_devices(max8997->dev, -1, max8997_devs,
+ ret = mfd_add_devices(max8997->dev, -1, max8997_devs,
ARRAY_SIZE(max8997_devs),
NULL, 0, NULL);
+ if (ret < 0) {
+ dev_err(max8997->dev, "failed to add MFD devices %d\n", ret);
+ goto err_mfd;
+ }
/*
* TODO: enable others (flash, muic, rtc, battery, ...) and
* check the return value
*/
- if (ret < 0)
- goto err_mfd;
-
/* MAX8997 has a power button input. */
device_init_wakeup(max8997->dev, pdata->wakeup);
--
1.8.5.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mfd: max8997: Enforce mfd_add_devices() return value check
2013-12-17 12:49 [PATCH] mfd: max8997: Enforce mfd_add_devices() return value check Laszlo Papp
@ 2013-12-17 13:23 ` Lee Jones
0 siblings, 0 replies; 3+ messages in thread
From: Lee Jones @ 2013-12-17 13:23 UTC (permalink / raw)
To: Laszlo Papp; +Cc: sameo, linux-kernel
On Tue, 17 Dec 2013, Laszlo Papp wrote:
> The original author provided a random return value check which is
> redundant and seemingly floating. This patch not only relocates
> the check so it is more clearly associated with the invokation of
> mfd_add_devices(), but provides a store for the error value. We
> also print a meaningful message on error before returning.
>
> Signed-off-by: Laszlo Papp <lpapp@kde.org>
> ---
> drivers/mfd/max8997.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
Applied, thanks.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-17 13:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-17 12:49 [PATCH] mfd: max8997: Enforce mfd_add_devices() return value check Laszlo Papp
2013-12-17 13:23 ` Lee Jones
-- strict thread matches above, loose matches on Subject: below --
2013-12-17 12:45 Laszlo Papp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox