diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /drivers/w1/masters/w1-gpio.c | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'drivers/w1/masters/w1-gpio.c')
-rw-r--r-- | drivers/w1/masters/w1-gpio.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c index e36b18b..f54ece2 100644 --- a/drivers/w1/masters/w1-gpio.c +++ b/drivers/w1/masters/w1-gpio.c @@ -56,9 +56,8 @@ MODULE_DEVICE_TABLE(of, w1_gpio_dt_ids); static int w1_gpio_probe_dt(struct platform_device *pdev) { - struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); + 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) @@ -67,11 +66,7 @@ static int w1_gpio_probe_dt(struct platform_device *pdev) if (of_get_property(np, "linux,open-drain", NULL)) pdata->is_open_drain = 1; - gpio = of_get_gpio(np, 0); - if (gpio < 0) - return gpio; - pdata->pin = gpio; - + pdata->pin = of_get_gpio(np, 0); pdata->ext_pullup_enable_pin = of_get_gpio(np, 1); pdev->dev.platform_data = pdata; @@ -92,34 +87,32 @@ static int w1_gpio_probe(struct platform_device *pdev) } } - pdata = dev_get_platdata(&pdev->dev); + pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "No configuration data\n"); return -ENXIO; } - master = devm_kzalloc(&pdev->dev, sizeof(struct w1_bus_master), - GFP_KERNEL); + master = kzalloc(sizeof(struct w1_bus_master), GFP_KERNEL); if (!master) { dev_err(&pdev->dev, "Out of memory\n"); return -ENOMEM; } - err = devm_gpio_request(&pdev->dev, pdata->pin, "w1"); + err = gpio_request(pdata->pin, "w1"); if (err) { dev_err(&pdev->dev, "gpio_request (pin) failed\n"); - return err; + goto free_master; } if (gpio_is_valid(pdata->ext_pullup_enable_pin)) { - err = devm_gpio_request_one(&pdev->dev, - pdata->ext_pullup_enable_pin, GPIOF_INIT_LOW, - "w1 pullup"); + err = gpio_request_one(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"); - return err; + goto free_gpio; } } @@ -137,7 +130,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"); - return err; + goto free_gpio_ext_pu; } if (pdata->enable_external_pullup) @@ -149,12 +142,22 @@ 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) { struct w1_bus_master *master = platform_get_drvdata(pdev); - struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; if (pdata->enable_external_pullup) pdata->enable_external_pullup(0); @@ -163,6 +166,8 @@ 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; } @@ -171,7 +176,7 @@ static int w1_gpio_remove(struct platform_device *pdev) static int w1_gpio_suspend(struct platform_device *pdev, pm_message_t state) { - struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; if (pdata->enable_external_pullup) pdata->enable_external_pullup(0); @@ -181,7 +186,7 @@ static int w1_gpio_suspend(struct platform_device *pdev, pm_message_t state) static int w1_gpio_resume(struct platform_device *pdev) { - struct w1_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct w1_gpio_platform_data *pdata = pdev->dev.platform_data; if (pdata->enable_external_pullup) pdata->enable_external_pullup(1); |