* [PATCH] regulator: Check SET[1|2|3] GPIO settings earlier
@ 2012-03-13 2:58 Axel Lin
2012-03-13 23:13 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-03-13 2:58 UTC (permalink / raw)
To: linux-kernel; +Cc: Kyungmin Park, MyungJoo Ham, Liam Girdwood, Mark Brown
Unused GPIO is marked as -1, we need to check if one of the gpio is set to 0
here because gpio_is_valid considers 0 as a valid gpio.
Since we need to check the GPIOs anyway, check them altogether earlier makes
the code cleaner.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/regulator/max8998.c | 32 +++++++-------------------------
1 files changed, 7 insertions(+), 25 deletions(-)
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index 5890265..67140fa 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -695,6 +695,13 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
return -ENODEV;
}
+ /* Unused GPIO is marked as -1 */
+ if (!pdata->buck1_set1 || !pdata->buck1_set2 || !pdata->buck2_set3) {
+ dev_err(&pdev->dev,
+ "MAX8998 SET1/SET2/SET3 GPIO must not be defined as 0 !\n");
+ return -EINVAL;
+ }
+
max8998 = kzalloc(sizeof(struct max8998_data), GFP_KERNEL);
if (!max8998)
return -ENOMEM;
@@ -716,27 +723,9 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
max8998->buck1_idx = pdata->buck1_default_idx;
max8998->buck2_idx = pdata->buck2_default_idx;
- /* NOTE: */
- /* For unused GPIO NOT marked as -1 (thereof equal to 0) WARN_ON */
- /* will be displayed */
-
/* Check if MAX8998 voltage selection GPIOs are defined */
if (gpio_is_valid(pdata->buck1_set1) &&
gpio_is_valid(pdata->buck1_set2)) {
- /* Check if SET1 is not equal to 0 */
- if (!pdata->buck1_set1) {
- printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n");
- WARN_ON(!pdata->buck1_set1);
- ret = -EIO;
- goto err_free_mem;
- }
- /* Check if SET2 is not equal to 0 */
- if (!pdata->buck1_set2) {
- printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n");
- WARN_ON(!pdata->buck1_set2);
- ret = -EIO;
- goto err_free_mem;
- }
gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
gpio_direction_output(pdata->buck1_set1,
@@ -796,13 +785,6 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
}
if (gpio_is_valid(pdata->buck2_set3)) {
- /* Check if SET3 is not equal to 0 */
- if (!pdata->buck2_set3) {
- printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n");
- WARN_ON(!pdata->buck2_set3);
- ret = -EIO;
- goto err_free_mem;
- }
gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
gpio_direction_output(pdata->buck2_set3,
max8998->buck2_idx & 0x1);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: Check SET[1|2|3] GPIO settings earlier
2012-03-13 2:58 [PATCH] regulator: Check SET[1|2|3] GPIO settings earlier Axel Lin
@ 2012-03-13 23:13 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-03-13 23:13 UTC (permalink / raw)
To: Axel Lin; +Cc: linux-kernel, Kyungmin Park, MyungJoo Ham, Liam Girdwood
[-- Attachment #1: Type: text/plain, Size: 411 bytes --]
On Tue, Mar 13, 2012 at 10:58:20AM +0800, Axel Lin wrote:
> Unused GPIO is marked as -1, we need to check if one of the gpio is set to 0
> here because gpio_is_valid considers 0 as a valid gpio.
This will break existing boards, we need to manage the transfer more
gracefully and complain if we're using a GPIO 0. Though I'm not sure
it's worth bothering, I hope no modern gpiolib implementation will do
this.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-13 23:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-13 2:58 [PATCH] regulator: Check SET[1|2|3] GPIO settings earlier Axel Lin
2012-03-13 23:13 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox