diff options
author | abdoulaye berthe <berthe.ab@gmail.com> | 2014-05-13 12:42:12 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-05-16 11:52:37 -0400 |
commit | ae28193e01c8467f448e77234a074bae05b7a66f (patch) | |
tree | 914d38f42061a36176ffc577a631f9d589a3a0fe /drivers/gpio | |
parent | 0ed3398ed8086597ff53d119fa48fa466f2f2754 (diff) |
gpio: janzttl: use devm function
This uses dem function for mem allocation
Signed-off-by: abdoulaye berthe <berthe.ab@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-janz-ttl.c | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/drivers/gpio/gpio-janz-ttl.c b/drivers/gpio/gpio-janz-ttl.c index 255806bcbfe5..42852eaaf020 100644 --- a/drivers/gpio/gpio-janz-ttl.c +++ b/drivers/gpio/gpio-janz-ttl.c | |||
@@ -152,33 +152,21 @@ static int ttl_probe(struct platform_device *pdev) | |||
152 | pdata = dev_get_platdata(&pdev->dev); | 152 | pdata = dev_get_platdata(&pdev->dev); |
153 | if (!pdata) { | 153 | if (!pdata) { |
154 | dev_err(dev, "no platform data\n"); | 154 | dev_err(dev, "no platform data\n"); |
155 | ret = -ENXIO; | 155 | return -ENXIO; |
156 | goto out_return; | ||
157 | } | 156 | } |
158 | 157 | ||
159 | mod = kzalloc(sizeof(*mod), GFP_KERNEL); | 158 | mod = devm_kzalloc(dev, sizeof(*mod), GFP_KERNEL); |
160 | if (!mod) { | 159 | if (!mod) |
161 | ret = -ENOMEM; | 160 | return -ENOMEM; |
162 | goto out_return; | ||
163 | } | ||
164 | 161 | ||
165 | platform_set_drvdata(pdev, mod); | 162 | platform_set_drvdata(pdev, mod); |
166 | spin_lock_init(&mod->lock); | 163 | spin_lock_init(&mod->lock); |
167 | 164 | ||
168 | /* get access to the MODULbus registers for this module */ | 165 | /* get access to the MODULbus registers for this module */ |
169 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 166 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
170 | if (!res) { | 167 | mod->regs = devm_ioremap_resource(dev, res); |
171 | dev_err(dev, "MODULbus registers not found\n"); | 168 | if (IS_ERR(mod->regs)) |
172 | ret = -ENODEV; | 169 | return PTR_ERR(mod->regs); |
173 | goto out_free_mod; | ||
174 | } | ||
175 | |||
176 | mod->regs = ioremap(res->start, resource_size(res)); | ||
177 | if (!mod->regs) { | ||
178 | dev_err(dev, "MODULbus registers not ioremap\n"); | ||
179 | ret = -ENOMEM; | ||
180 | goto out_free_mod; | ||
181 | } | ||
182 | 170 | ||
183 | ttl_setup_device(mod); | 171 | ttl_setup_device(mod); |
184 | 172 | ||
@@ -197,17 +185,10 @@ static int ttl_probe(struct platform_device *pdev) | |||
197 | ret = gpiochip_add(gpio); | 185 | ret = gpiochip_add(gpio); |
198 | if (ret) { | 186 | if (ret) { |
199 | dev_err(dev, "unable to add GPIO chip\n"); | 187 | dev_err(dev, "unable to add GPIO chip\n"); |
200 | goto out_iounmap_regs; | 188 | return ret; |
201 | } | 189 | } |
202 | 190 | ||
203 | return 0; | 191 | return 0; |
204 | |||
205 | out_iounmap_regs: | ||
206 | iounmap(mod->regs); | ||
207 | out_free_mod: | ||
208 | kfree(mod); | ||
209 | out_return: | ||
210 | return ret; | ||
211 | } | 192 | } |
212 | 193 | ||
213 | static int ttl_remove(struct platform_device *pdev) | 194 | static int ttl_remove(struct platform_device *pdev) |
@@ -222,8 +203,6 @@ static int ttl_remove(struct platform_device *pdev) | |||
222 | return ret; | 203 | return ret; |
223 | } | 204 | } |
224 | 205 | ||
225 | iounmap(mod->regs); | ||
226 | kfree(mod); | ||
227 | return 0; | 206 | return 0; |
228 | } | 207 | } |
229 | 208 | ||