diff options
author | abdoulaye berthe <berthe.ab@gmail.com> | 2014-05-12 11:40:42 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2014-05-16 11:52:36 -0400 |
commit | a435e1802b3620c830ee27a3f5cdbf936dac469d (patch) | |
tree | 01c6e25aca98de515c3f17ec1f640a2c61ca8d97 | |
parent | cdf86cd233207ed992a647f0b9d42c60735756e7 (diff) |
gpio: bt8xx: use devm function for memory allocation
Signed-off-by: abdoulaye berthe <berthe.ab@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-bt8xx.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/gpio/gpio-bt8xx.c b/drivers/gpio/gpio-bt8xx.c index ecb3ca2d1d10..6557147d9331 100644 --- a/drivers/gpio/gpio-bt8xx.c +++ b/drivers/gpio/gpio-bt8xx.c | |||
@@ -178,7 +178,7 @@ static int bt8xxgpio_probe(struct pci_dev *dev, | |||
178 | struct bt8xxgpio *bg; | 178 | struct bt8xxgpio *bg; |
179 | int err; | 179 | int err; |
180 | 180 | ||
181 | bg = kzalloc(sizeof(*bg), GFP_KERNEL); | 181 | bg = devm_kzalloc(&dev->dev, sizeof(struct bt8xxgpio), GFP_KERNEL); |
182 | if (!bg) | 182 | if (!bg) |
183 | return -ENOMEM; | 183 | return -ENOMEM; |
184 | 184 | ||
@@ -188,9 +188,9 @@ static int bt8xxgpio_probe(struct pci_dev *dev, | |||
188 | err = pci_enable_device(dev); | 188 | err = pci_enable_device(dev); |
189 | if (err) { | 189 | if (err) { |
190 | printk(KERN_ERR "bt8xxgpio: Can't enable device.\n"); | 190 | printk(KERN_ERR "bt8xxgpio: Can't enable device.\n"); |
191 | goto err_freebg; | 191 | return err; |
192 | } | 192 | } |
193 | if (!request_mem_region(pci_resource_start(dev, 0), | 193 | if (!devm_request_mem_region(&dev->dev, pci_resource_start(dev, 0), |
194 | pci_resource_len(dev, 0), | 194 | pci_resource_len(dev, 0), |
195 | "bt8xxgpio")) { | 195 | "bt8xxgpio")) { |
196 | printk(KERN_WARNING "bt8xxgpio: Can't request iomem (0x%llx).\n", | 196 | printk(KERN_WARNING "bt8xxgpio: Can't request iomem (0x%llx).\n", |
@@ -201,11 +201,11 @@ static int bt8xxgpio_probe(struct pci_dev *dev, | |||
201 | pci_set_master(dev); | 201 | pci_set_master(dev); |
202 | pci_set_drvdata(dev, bg); | 202 | pci_set_drvdata(dev, bg); |
203 | 203 | ||
204 | bg->mmio = ioremap(pci_resource_start(dev, 0), 0x1000); | 204 | bg->mmio = devm_ioremap(&dev->dev, pci_resource_start(dev, 0), 0x1000); |
205 | if (!bg->mmio) { | 205 | if (!bg->mmio) { |
206 | printk(KERN_ERR "bt8xxgpio: ioremap() failed\n"); | 206 | printk(KERN_ERR "bt8xxgpio: ioremap() failed\n"); |
207 | err = -EIO; | 207 | err = -EIO; |
208 | goto err_release_mem; | 208 | goto err_disable; |
209 | } | 209 | } |
210 | 210 | ||
211 | /* Disable interrupts */ | 211 | /* Disable interrupts */ |
@@ -220,18 +220,13 @@ static int bt8xxgpio_probe(struct pci_dev *dev, | |||
220 | err = gpiochip_add(&bg->gpio); | 220 | err = gpiochip_add(&bg->gpio); |
221 | if (err) { | 221 | if (err) { |
222 | printk(KERN_ERR "bt8xxgpio: Failed to register GPIOs\n"); | 222 | printk(KERN_ERR "bt8xxgpio: Failed to register GPIOs\n"); |
223 | goto err_release_mem; | 223 | goto err_disable; |
224 | } | 224 | } |
225 | 225 | ||
226 | return 0; | 226 | return 0; |
227 | 227 | ||
228 | err_release_mem: | ||
229 | release_mem_region(pci_resource_start(dev, 0), | ||
230 | pci_resource_len(dev, 0)); | ||
231 | err_disable: | 228 | err_disable: |
232 | pci_disable_device(dev); | 229 | pci_disable_device(dev); |
233 | err_freebg: | ||
234 | kfree(bg); | ||
235 | 230 | ||
236 | return err; | 231 | return err; |
237 | } | 232 | } |
@@ -250,8 +245,6 @@ static void bt8xxgpio_remove(struct pci_dev *pdev) | |||
250 | release_mem_region(pci_resource_start(pdev, 0), | 245 | release_mem_region(pci_resource_start(pdev, 0), |
251 | pci_resource_len(pdev, 0)); | 246 | pci_resource_len(pdev, 0)); |
252 | pci_disable_device(pdev); | 247 | pci_disable_device(pdev); |
253 | |||
254 | kfree(bg); | ||
255 | } | 248 | } |
256 | 249 | ||
257 | #ifdef CONFIG_PM | 250 | #ifdef CONFIG_PM |