Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: ixp4xx: Use devm_*() functions

Use devm_*() functions to make cleanup paths simpler.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Jingoo Han and committed by
Brian Norris
ed0b272e bb13bec7

+6 -22
+6 -22
drivers/mtd/maps/ixp4xx.c
··· 13 13 * 14 14 */ 15 15 16 + #include <linux/err.h> 16 17 #include <linux/module.h> 17 18 #include <linux/types.h> 18 19 #include <linux/init.h> ··· 163 162 mtd_device_unregister(info->mtd); 164 163 map_destroy(info->mtd); 165 164 } 166 - if (info->map.virt) 167 - iounmap(info->map.virt); 168 - 169 - if (info->res) { 170 - release_resource(info->res); 171 - kfree(info->res); 172 - } 173 165 174 166 if (plat->exit) 175 167 plat->exit(); ··· 188 194 return err; 189 195 } 190 196 191 - info = kzalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL); 197 + info = devm_kzalloc(&dev->dev, sizeof(struct ixp4xx_flash_info), 198 + GFP_KERNEL); 192 199 if(!info) { 193 200 err = -ENOMEM; 194 201 goto Error; ··· 215 220 info->map.write = ixp4xx_probe_write16; 216 221 info->map.copy_from = ixp4xx_copy_from; 217 222 218 - info->res = request_mem_region(dev->resource->start, 219 - resource_size(dev->resource), 220 - "IXP4XXFlash"); 221 - if (!info->res) { 222 - printk(KERN_ERR "IXP4XXFlash: Could not reserve memory region\n"); 223 - err = -ENOMEM; 224 - goto Error; 225 - } 226 - 227 - info->map.virt = ioremap(dev->resource->start, 228 - resource_size(dev->resource)); 229 - if (!info->map.virt) { 230 - printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n"); 231 - err = -EIO; 223 + info->map.virt = devm_ioremap_resource(&dev->dev, dev->resource); 224 + if (IS_ERR(info->map.virt)) { 225 + err = PTR_ERR(info->map.virt); 232 226 goto Error; 233 227 } 234 228