* [RESEND PATCH 1/2] w1-gpio: Detect of_gpio_error for first gpio
@ 2013-10-29 8:19 Markus Pargmann
2013-10-29 8:19 ` [RESEND PATCH 2/2] w1-gpio: Use devm_* functions Markus Pargmann
0 siblings, 1 reply; 2+ messages in thread
From: Markus Pargmann @ 2013-10-29 8:19 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Evgeniy Polyakov, linux-kernel, linux-arm-kernel, kernel,
Markus Pargmann
The first DT gpio is necessary for this driver, but errors returned for
of_get_gpio are ignored.
This patch adds a return value check for the first of_get_gpio.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
---
drivers/w1/masters/w1-gpio.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index f54ece2..ae53e88 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -58,6 +58,7 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
{
struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
struct device_node *np = pdev->dev.of_node;
+ int gpio;
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
@@ -66,7 +67,11 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
if (of_get_property(np, "linux,open-drain", NULL))
pdata->is_open_drain = 1;
- pdata->pin = of_get_gpio(np, 0);
+ gpio = of_get_gpio(np, 0);
+ if (gpio < 0)
+ return gpio;
+ pdata->pin = gpio;
+
pdata->ext_pullup_enable_pin = of_get_gpio(np, 1);
pdev->dev.platform_data = pdata;
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [RESEND PATCH 2/2] w1-gpio: Use devm_* functions
2013-10-29 8:19 [RESEND PATCH 1/2] w1-gpio: Detect of_gpio_error for first gpio Markus Pargmann
@ 2013-10-29 8:19 ` Markus Pargmann
0 siblings, 0 replies; 2+ messages in thread
From: Markus Pargmann @ 2013-10-29 8:19 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Evgeniy Polyakov, linux-kernel, linux-arm-kernel, kernel,
Markus Pargmann
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
---
drivers/w1/masters/w1-gpio.c | 28 +++++++++-------------------
1 file changed, 9 insertions(+), 19 deletions(-)
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c
index ae53e88..264ad1c 100644
--- a/drivers/w1/masters/w1-gpio.c
+++ b/drivers/w1/masters/w1-gpio.c
@@ -99,25 +99,27 @@ static int w1_gpio_probe(struct platform_device *pdev)
return -ENXIO;
}
- master = kzalloc(sizeof(struct w1_bus_master), GFP_KERNEL);
+ master = devm_kzalloc(&pdev->dev, sizeof(struct w1_bus_master),
+ GFP_KERNEL);
if (!master) {
dev_err(&pdev->dev, "Out of memory\n");
return -ENOMEM;
}
- err = gpio_request(pdata->pin, "w1");
+ err = devm_gpio_request(&pdev->dev, pdata->pin, "w1");
if (err) {
dev_err(&pdev->dev, "gpio_request (pin) failed\n");
- goto free_master;
+ return err;
}
if (gpio_is_valid(pdata->ext_pullup_enable_pin)) {
- err = gpio_request_one(pdata->ext_pullup_enable_pin,
- GPIOF_INIT_LOW, "w1 pullup");
+ err = devm_gpio_request_one(&pdev->dev,
+ pdata->ext_pullup_enable_pin, GPIOF_INIT_LOW,
+ "w1 pullup");
if (err < 0) {
dev_err(&pdev->dev, "gpio_request_one "
"(ext_pullup_enable_pin) failed\n");
- goto free_gpio;
+ return err;
}
}
@@ -135,7 +137,7 @@ static int w1_gpio_probe(struct platform_device *pdev)
err = w1_add_master_device(master);
if (err) {
dev_err(&pdev->dev, "w1_add_master device failed\n");
- goto free_gpio_ext_pu;
+ return err;
}
if (pdata->enable_external_pullup)
@@ -147,16 +149,6 @@ static int w1_gpio_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, master);
return 0;
-
- free_gpio_ext_pu:
- if (gpio_is_valid(pdata->ext_pullup_enable_pin))
- gpio_free(pdata->ext_pullup_enable_pin);
- free_gpio:
- gpio_free(pdata->pin);
- free_master:
- kfree(master);
-
- return err;
}
static int w1_gpio_remove(struct platform_device *pdev)
@@ -171,8 +163,6 @@ static int w1_gpio_remove(struct platform_device *pdev)
gpio_set_value(pdata->ext_pullup_enable_pin, 0);
w1_remove_master_device(master);
- gpio_free(pdata->pin);
- kfree(master);
return 0;
}
--
1.8.4.rc3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-29 8:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-29 8:19 [RESEND PATCH 1/2] w1-gpio: Detect of_gpio_error for first gpio Markus Pargmann
2013-10-29 8:19 ` [RESEND PATCH 2/2] w1-gpio: Use devm_* functions Markus Pargmann
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).