diff options
Diffstat (limited to 'drivers/w1/masters/w1-gpio.c')
-rw-r--r-- | drivers/w1/masters/w1-gpio.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/w1/masters/w1-gpio.c b/drivers/w1/masters/w1-gpio.c index ae53e8832845..264ad1c583ab 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) | |||
99 | return -ENXIO; | 99 | return -ENXIO; |
100 | } | 100 | } |
101 | 101 | ||
102 | master = kzalloc(sizeof(struct w1_bus_master), GFP_KERNEL); | 102 | master = devm_kzalloc(&pdev->dev, sizeof(struct w1_bus_master), |
103 | GFP_KERNEL); | ||
103 | if (!master) { | 104 | if (!master) { |
104 | dev_err(&pdev->dev, "Out of memory\n"); | 105 | dev_err(&pdev->dev, "Out of memory\n"); |
105 | return -ENOMEM; | 106 | return -ENOMEM; |
106 | } | 107 | } |
107 | 108 | ||
108 | err = gpio_request(pdata->pin, "w1"); | 109 | err = devm_gpio_request(&pdev->dev, pdata->pin, "w1"); |
109 | if (err) { | 110 | if (err) { |
110 | dev_err(&pdev->dev, "gpio_request (pin) failed\n"); | 111 | dev_err(&pdev->dev, "gpio_request (pin) failed\n"); |
111 | goto free_master; | 112 | return err; |
112 | } | 113 | } |
113 | 114 | ||
114 | if (gpio_is_valid(pdata->ext_pullup_enable_pin)) { | 115 | if (gpio_is_valid(pdata->ext_pullup_enable_pin)) { |
115 | err = gpio_request_one(pdata->ext_pullup_enable_pin, | 116 | err = devm_gpio_request_one(&pdev->dev, |
116 | GPIOF_INIT_LOW, "w1 pullup"); | 117 | pdata->ext_pullup_enable_pin, GPIOF_INIT_LOW, |
118 | "w1 pullup"); | ||
117 | if (err < 0) { | 119 | if (err < 0) { |
118 | dev_err(&pdev->dev, "gpio_request_one " | 120 | dev_err(&pdev->dev, "gpio_request_one " |
119 | "(ext_pullup_enable_pin) failed\n"); | 121 | "(ext_pullup_enable_pin) failed\n"); |
120 | goto free_gpio; | 122 | return err; |
121 | } | 123 | } |
122 | } | 124 | } |
123 | 125 | ||
@@ -135,7 +137,7 @@ static int w1_gpio_probe(struct platform_device *pdev) | |||
135 | err = w1_add_master_device(master); | 137 | err = w1_add_master_device(master); |
136 | if (err) { | 138 | if (err) { |
137 | dev_err(&pdev->dev, "w1_add_master device failed\n"); | 139 | dev_err(&pdev->dev, "w1_add_master device failed\n"); |
138 | goto free_gpio_ext_pu; | 140 | return err; |
139 | } | 141 | } |
140 | 142 | ||
141 | if (pdata->enable_external_pullup) | 143 | if (pdata->enable_external_pullup) |
@@ -147,16 +149,6 @@ static int w1_gpio_probe(struct platform_device *pdev) | |||
147 | platform_set_drvdata(pdev, master); | 149 | platform_set_drvdata(pdev, master); |
148 | 150 | ||
149 | return 0; | 151 | return 0; |
150 | |||
151 | free_gpio_ext_pu: | ||
152 | if (gpio_is_valid(pdata->ext_pullup_enable_pin)) | ||
153 | gpio_free(pdata->ext_pullup_enable_pin); | ||
154 | free_gpio: | ||
155 | gpio_free(pdata->pin); | ||
156 | free_master: | ||
157 | kfree(master); | ||
158 | |||
159 | return err; | ||
160 | } | 152 | } |
161 | 153 | ||
162 | static int w1_gpio_remove(struct platform_device *pdev) | 154 | static int w1_gpio_remove(struct platform_device *pdev) |
@@ -171,8 +163,6 @@ static int w1_gpio_remove(struct platform_device *pdev) | |||
171 | gpio_set_value(pdata->ext_pullup_enable_pin, 0); | 163 | gpio_set_value(pdata->ext_pullup_enable_pin, 0); |
172 | 164 | ||
173 | w1_remove_master_device(master); | 165 | w1_remove_master_device(master); |
174 | gpio_free(pdata->pin); | ||
175 | kfree(master); | ||
176 | 166 | ||
177 | return 0; | 167 | return 0; |
178 | } | 168 | } |