mtd: maps: Remove print after allocation failure
Subsystems (4)
PATCH v2 1/2 mtd: maps: Remove print after allocation failure
The prints after [k|v][m|z|c]alloc() functions are not needed, because in case of failure, allocator will print their internal error prints anyway.
Signed-off-by Arushi Singhal <[email protected]>
---
changes in v2
* Prefered
if (!map) {
map = kmalloc();
if (!map)
err;
}than
if (!map)
map = kmalloc();
if (!map)
err
drivers/mtd/maps/amd76xrom.c | 6 ++---- drivers/mtd/maps/ck804xrom.c | 8 +++----- drivers/mtd/maps/esb2rom.c | 7 +++---- drivers/mtd/maps/ichxrom.c | 6 ++---- drivers/mtd/maps/sun_uflash.c | 4 +--- drivers/mtd/maps/vmu-flash.c | 3 --- 6 files changed, 11 insertions(+), 23 deletions(-)
drivers/mtd/maps/amd76xrom.c +2 -4
@@ -188,10 +188,8 @@ static int amd76xrom_init_one(struct pci_dev *pdev,if (!map) { map =kmalloc (sizeof (*map),GFP_KERNEL ); - } -if (!map) { - printk(KERN_ERR MOD_NAME ": kmalloc failed"); - goto out; +if (!map) + goto out; }memset (map,0 ,sizeof (*map));INIT_LIST_HEAD (&map->list);
drivers/mtd/maps/ck804xrom.c +3 -5
@@ -216,12 +216,10 @@ static int __init ck804xrom_init_one(struct pci_dev *pdev,unsigned long offset;int i; -if (!map) - map =kmalloc (sizeof (*map),GFP_KERNEL ); -if (!map) { - printk(KERN_ERR MOD_NAME ": kmalloc failed"); - goto out; + map =kmalloc (sizeof (*map),GFP_KERNEL ); +if (!map) + goto out; }memset (map,0 ,sizeof (*map));INIT_LIST_HEAD (&map->list);
drivers/mtd/maps/esb2rom.c +3 -4
@@ -276,11 +276,10 @@ static int __init esb2rom_init_one(struct pci_dev *pdev,unsigned long offset;int i; -if (!map) - map =kmalloc (sizeof (*map),GFP_KERNEL );if (!map) { - printk(KERN_ERR MOD_NAME ": kmalloc failed"); - goto out; + map =kmalloc (sizeof (*map),GFP_KERNEL ); +if (!map) + goto out; }memset (map,0 ,sizeof (*map));INIT_LIST_HEAD (&map->list);
drivers/mtd/maps/ichxrom.c +2 -4
@@ -212,10 +212,8 @@ static int __init ichxrom_init_one(struct pci_dev *pdev,if (!map) { map =kmalloc (sizeof (*map),GFP_KERNEL ); - } -if (!map) { - printk(KERN_ERR MOD_NAME ": kmalloc failed"); - goto out; +if (!map) + goto out; }memset (map,0 ,sizeof (*map));INIT_LIST_HEAD (&map->list);
drivers/mtd/maps/sun_uflash.c +1 -3
@@ -62,10 +62,8 @@ int uflash_devinit(struct platform_device *op, struct device_node *dp) } up =kzalloc (sizeof (struct uflash_dev ),GFP_KERNEL ); -if (!up) { - printk(KERN_ERR PFX "Cannot allocate struct uflash_dev\n"); +if (!up)return -ENOMEM ; - }/* copy defaults and tweak parameters */ memcpy (&up->map, &uflash_map_templ,sizeof (uflash_map_templ));
drivers/mtd/maps/vmu-flash.c +0 -3
@@ -130,9 +130,6 @@ static int maple_vmu_read_block(unsigned int num, unsigned char *buf,if (!pcache->buffer) { pcache->buffer =kmalloc (card->blocklen,GFP_KERNEL );if (!pcache->buffer) { -dev_err (&mdev->dev,"VMU at (%d, %d) - read fails due" -" to lack of memory\n" , mdev->port, - mdev->unit); error = -ENOMEM ; goto outB; }
Signature · 1 line
2.7.4
PATCH v2 2/2 mtd: nand: Remove print after allocation failure
The prints after [k|v][m|z|c]alloc() etc. functions are not needed, because in case of failure, allocator will print their internal error prints anyway.
Signed-off-by Arushi Singhal <[email protected]>
Reviewed-by Miquel Raynal <[email protected]>
--- drivers/mtd/nand/ams-delta.c | 1 - drivers/mtd/nand/atmel/nand-controller.c | 13 +++--------- drivers/mtd/nand/marvell_nand.c | 8 ++------ drivers/mtd/nand/nandsim.c | 35 ++++++++------------------------ drivers/mtd/nand/ndfc.c | 4 +--- drivers/mtd/nand/sunxi_nand.c | 4 +--- 6 files changed, 15 insertions(+), 50 deletions(-)
drivers/mtd/nand/ams-delta.c +0 -1
@@ -185,7 +185,6 @@ static int ams_delta_init(struct platform_device *pdev)/* Allocate memory for MTD device structure and private data */ this =kzalloc (sizeof (struct nand_chip ),GFP_KERNEL );if (!this) { -printk (KERN_WARNING "Unable to allocate E3 NAND MTD device structure.\n" ); err = -ENOMEM ; goto out; }
drivers/mtd/nand/atmel/nand-controller.c +3 -10
@@ -1615,10 +1615,8 @@ static int atmel_nand_register(struct atmel_nand *nand) mtd->name =devm_kasprintf (nc->dev,GFP_KERNEL ,"%s:nand.%d" ,dev_name (nc->dev), nand->cs[0 ].id); -if (!mtd->name) { -dev_err (nc->dev,"Failed to allocate mtd->name\n" ); +if (!mtd->name)return -ENOMEM ; - } } ret =nand_scan_tail (mtd);
@@ -1657,10 +1655,8 @@ static struct atmel_nand *atmel_nand_create(struct atmel_nand_controller *nc, nand =devm_kzalloc (nc->dev,sizeof (*nand) + (numcs *sizeof (*nand->cs)),GFP_KERNEL ); -if (!nand) { -dev_err (nc->dev,"Failed to allocate NAND object\n" ); +if (!nand)return ERR_PTR (-ENOMEM ); - } nand->numcs = numcs;
@@ -2217,11 +2213,8 @@ atmel_hsmc_nand_controller_init(struct atmel_hsmc_nand_controller *nc) nc->sram.virt =gen_pool_dma_alloc (nc->sram.pool,ATMEL_NFC_SRAM_SIZE , &nc->sram.dma); -if (!nc->sram.virt) { -dev_err (nc->base.dev, -"Could not allocate memory from the NFC SRAM pool\n" ); +if (!nc->sram.virt)return -ENOMEM ; - }return 0 ; }
drivers/mtd/nand/marvell_nand.c +2 -6
@@ -2307,10 +2307,8 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc, (nsels *sizeof (struct marvell_nand_chip_sel )), GFP_KERNEL); -if (!marvell_nand) { -dev_err (dev,"could not allocate chip structure\n" ); +if (!marvell_nand)return -ENOMEM ; - } marvell_nand->nsels = nsels; marvell_nand->selected_die =-1 ;
@@ -2506,10 +2504,8 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc, mtd->name =devm_kasprintf (nfc->dev,GFP_KERNEL ,"%s:nand.%d" ,dev_name (nfc->dev), marvell_nand->sels[0 ].cs); -if (!mtd->name) { -dev_err (nfc->dev,"Failed to allocate mtd->name\n" ); +if (!mtd->name)return -ENOMEM ; - } } ret =nand_scan_tail (mtd);
drivers/mtd/nand/nandsim.c +8 -27
@@ -569,13 +569,11 @@ static int __init alloc_device(struct nandsim *ns) ns->pages_written =vzalloc (BITS_TO_LONGS (ns->geom.pgnum) *sizeof (unsigned long ));if (!ns->pages_written) { -NS_ERR ("alloc_device: unable to allocate pages written array\n" ); err = -ENOMEM ; goto err_close; } ns->file_buf =kmalloc (ns->geom.pgszoob,GFP_KERNEL );if (!ns->file_buf) { -NS_ERR ("alloc_device: unable to allocate file buf\n" ); err = -ENOMEM ; goto err_free; }
@@ -584,10 +582,8 @@ static int __init alloc_device(struct nandsim *ns) } ns->pages =vmalloc (ns->geom.pgnum *sizeof (union ns_mem )); -if (!ns->pages) { -NS_ERR ("alloc_device: unable to allocate page array\n" ); +if (!ns->pages)return -ENOMEM ; - }for (i =0 ; i < ns->geom.pgnum; i++) { ns->pages[i].byte =NULL ; }
@@ -769,11 +765,8 @@ static int __init init_nandsim(struct mtd_info *mtd)/* Allocate / initialize the internal buffer */ ns->buf.byte =kmalloc (ns->geom.pgszoob,GFP_KERNEL ); -if (!ns->buf.byte) { -NS_ERR ("init_nandsim: unable to allocate %u bytes for the internal buffer\n" , - ns->geom.pgszoob); +if (!ns->buf.byte)return -ENOMEM ; - }memset (ns->buf.byte,0xFF , ns->geom.pgszoob);return 0 ;
@@ -844,10 +837,8 @@ static int parse_weakblocks(void)if (*w ==',' ) w +=1 ; wb =kzalloc (sizeof (*wb),GFP_KERNEL ); -if (!wb) { -NS_ERR ("unable to allocate memory.\n" ); +if (!wb)return -ENOMEM ; - } wb->erase_block_no = erase_block_no; wb->max_erases = max_erases;list_add (&wb->list, &weak_blocks);
@@ -895,10 +886,8 @@ static int parse_weakpages(void)if (*w ==',' ) w +=1 ; wp =kzalloc (sizeof (*wp),GFP_KERNEL ); -if (!wp) { -NS_ERR ("unable to allocate memory.\n" ); +if (!wp)return -ENOMEM ; - } wp->page_no = page_no; wp->max_writes = max_writes;list_add (&wp->list, &weak_pages);
@@ -946,10 +935,8 @@ static int parse_gravepages(void)if (*g ==',' ) g +=1 ; gp =kzalloc (sizeof (*gp),GFP_KERNEL ); -if (!gp) { -NS_ERR ("unable to allocate memory.\n" ); +if (!gp)return -ENOMEM ; - } gp->page_no = page_no; gp->max_reads = max_reads;list_add (&gp->list, &grave_pages);
@@ -1000,10 +987,8 @@ static int setup_wear_reporting(struct mtd_info *mtd)return -ENOMEM ; } erase_block_wear =kzalloc (mem,GFP_KERNEL ); -if (!erase_block_wear) { -NS_ERR ("Too many erase blocks for wear reporting\n" ); +if (!erase_block_wear)return -ENOMEM ; - }return 0 ; }
@@ -1558,10 +1543,8 @@ static int prog_page(struct nandsim *ns, int num)* again and deadlocks. This was seen in practice. */ mypage->byte =kmem_cache_alloc (ns->nand_pages_slab,GFP_NOFS ); -if (mypage->byte ==NULL ) { -NS_ERR ("prog_page: error allocating memory for page %d\n" , ns->regs.row); +if (!mypage->byte)return -1 ; - }memset (mypage->byte,0xFF , ns->geom.pgszoob); }
@@ -2209,10 +2192,8 @@ static int __init ns_init_module(void)/* Allocate and initialize mtd_info, nand_chip and nandsim structures */ chip =kzalloc (sizeof (struct nand_chip ) +sizeof (struct nandsim ),GFP_KERNEL ); -if (!chip) { -NS_ERR ("unable to allocate core structures.\n" ); +if (!chip)return -ENOMEM ; - } nsmtd =nand_to_mtd (chip); nand = (struct nandsim *)(chip +1 );nand_set_controller_data (chip, (void *)nand);
drivers/mtd/nand/ndfc.c +1 -3
@@ -223,10 +223,8 @@ static int ndfc_probe(struct platform_device *ofdev)dev_set_drvdata (&ofdev->dev, ndfc); ndfc->ndfcbase =of_iomap (ofdev->dev.of_node,0 ); -if (!ndfc->ndfcbase) { -dev_err (&ofdev->dev,"failed to get memory\n" ); +if (!ndfc->ndfcbase)return -EIO ; - } ccr =NDFC_CCR_BS (ndfc->chip_select);
drivers/mtd/nand/sunxi_nand.c +1 -3
@@ -2030,10 +2030,8 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,sizeof (*chip) + (nsels *sizeof (struct sunxi_nand_chip_sel )), GFP_KERNEL); -if (!chip) { -dev_err (dev,"could not allocate chip\n" ); +if (!chip)return -ENOMEM ; - } chip->nsels = nsels; chip->selected =-1 ;
Signature · 1 line
2.7.4
Re: [PATCH v2 2/2] mtd: nand: Remove print after allocation failure
Quoted 9 lines · Arushi Singhal
The prints after [k|v][m|z|c]alloc() etc. functions are not needed, because in case of failure, allocator will print their internal error prints anyway.
Signed-off-by Arushi Singhal <[email protected]>Reviewed-by Miquel Raynal <[email protected]>--- drivers/mtd/nand/ams-delta.c | 1 - drivers/mtd/nand/atmel/nand-controller.c | 13 +++---------
For Atmel NAND driver:
Acked-by Nicolas Ferre <[email protected]>
Quoted 235 lines
drivers/mtd/nand/marvell_nand.c | 8 ++------ drivers/mtd/nand/nandsim.c | 35 ++++++++------------------------ drivers/mtd/nand/ndfc.c | 4 +--- drivers/mtd/nand/sunxi_nand.c | 4 +--- 6 files changed, 15 insertions(+), 50 deletions(-)drivers/mtd/nand/ams-delta.c +0
-1@@ -185,7 +185,6 @@ static int ams_delta_init(struct platform_device *pdev)/* Allocate memory for MTD device structure and private data */ this =kzalloc (sizeof (struct nand_chip ),GFP_KERNEL );if (!this) { -printk (KERN_WARNING "Unable to allocate E3 NAND MTD device structure.\n" ); err = -ENOMEM ; goto out; }drivers/mtd/nand/atmel/nand-controller.c +3
-10@@ -1615,10 +1615,8 @@ static int atmel_nand_register(struct atmel_nand *nand) mtd->name =devm_kasprintf (nc->dev,GFP_KERNEL ,"%s:nand.%d" ,dev_name (nc->dev), nand->cs[0 ].id); -if (!mtd->name) { -dev_err (nc->dev,"Failed to allocate mtd->name\n" ); +if (!mtd->name)return -ENOMEM ; - } } ret =nand_scan_tail (mtd);@@ -1657,10 +1655,8 @@ static struct atmel_nand *atmel_nand_create(struct atmel_nand_controller *nc, nand =devm_kzalloc (nc->dev,sizeof (*nand) + (numcs *sizeof (*nand->cs)),GFP_KERNEL ); -if (!nand) { -dev_err (nc->dev,"Failed to allocate NAND object\n" ); +if (!nand)return ERR_PTR (-ENOMEM ); - } nand->numcs = numcs;@@ -2217,11 +2213,8 @@ atmel_hsmc_nand_controller_init(struct atmel_hsmc_nand_controller *nc) nc->sram.virt =gen_pool_dma_alloc (nc->sram.pool,ATMEL_NFC_SRAM_SIZE , &nc->sram.dma); -if (!nc->sram.virt) { -dev_err (nc->base.dev, -"Could not allocate memory from the NFC SRAM pool\n" ); +if (!nc->sram.virt)return -ENOMEM ; - }return 0 ; }drivers/mtd/nand/marvell_nand.c +2
-6@@ -2307,10 +2307,8 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc, (nsels *sizeof (struct marvell_nand_chip_sel )), GFP_KERNEL); -if (!marvell_nand) { -dev_err (dev,"could not allocate chip structure\n" ); +if (!marvell_nand)return -ENOMEM ; - } marvell_nand->nsels = nsels; marvell_nand->selected_die =-1 ;@@ -2506,10 +2504,8 @@ static int marvell_nand_chip_init(struct device *dev, struct marvell_nfc *nfc, mtd->name =devm_kasprintf (nfc->dev,GFP_KERNEL ,"%s:nand.%d" ,dev_name (nfc->dev), marvell_nand->sels[0 ].cs); -if (!mtd->name) { -dev_err (nfc->dev,"Failed to allocate mtd->name\n" ); +if (!mtd->name)return -ENOMEM ; - } } ret =nand_scan_tail (mtd);drivers/mtd/nand/nandsim.c +8
-27@@ -569,13 +569,11 @@ static int __init alloc_device(struct nandsim *ns) ns->pages_written =vzalloc (BITS_TO_LONGS (ns->geom.pgnum) *sizeof (unsigned long ));if (!ns->pages_written) { -NS_ERR ("alloc_device: unable to allocate pages written array\n" ); err = -ENOMEM ; goto err_close; } ns->file_buf =kmalloc (ns->geom.pgszoob,GFP_KERNEL );if (!ns->file_buf) { -NS_ERR ("alloc_device: unable to allocate file buf\n" ); err = -ENOMEM ; goto err_free; }@@ -584,10 +582,8 @@ static int __init alloc_device(struct nandsim *ns) } ns->pages =vmalloc (ns->geom.pgnum *sizeof (union ns_mem )); -if (!ns->pages) { -NS_ERR ("alloc_device: unable to allocate page array\n" ); +if (!ns->pages)return -ENOMEM ; - }for (i =0 ; i < ns->geom.pgnum; i++) { ns->pages[i].byte =NULL ; }@@ -769,11 +765,8 @@ static int __init init_nandsim(struct mtd_info *mtd)/* Allocate / initialize the internal buffer */ ns->buf.byte =kmalloc (ns->geom.pgszoob,GFP_KERNEL ); -if (!ns->buf.byte) { -NS_ERR ("init_nandsim: unable to allocate %u bytes for the internal buffer\n" , - ns->geom.pgszoob); +if (!ns->buf.byte)return -ENOMEM ; - }memset (ns->buf.byte,0xFF , ns->geom.pgszoob);return 0 ;@@ -844,10 +837,8 @@ static int parse_weakblocks(void)if (*w ==',' ) w +=1 ; wb =kzalloc (sizeof (*wb),GFP_KERNEL ); -if (!wb) { -NS_ERR ("unable to allocate memory.\n" ); +if (!wb)return -ENOMEM ; - } wb->erase_block_no = erase_block_no; wb->max_erases = max_erases;list_add (&wb->list, &weak_blocks);@@ -895,10 +886,8 @@ static int parse_weakpages(void)if (*w ==',' ) w +=1 ; wp =kzalloc (sizeof (*wp),GFP_KERNEL ); -if (!wp) { -NS_ERR ("unable to allocate memory.\n" ); +if (!wp)return -ENOMEM ; - } wp->page_no = page_no; wp->max_writes = max_writes;list_add (&wp->list, &weak_pages);@@ -946,10 +935,8 @@ static int parse_gravepages(void)if (*g ==',' ) g +=1 ; gp =kzalloc (sizeof (*gp),GFP_KERNEL ); -if (!gp) { -NS_ERR ("unable to allocate memory.\n" ); +if (!gp)return -ENOMEM ; - } gp->page_no = page_no; gp->max_reads = max_reads;list_add (&gp->list, &grave_pages);@@ -1000,10 +987,8 @@ static int setup_wear_reporting(struct mtd_info *mtd)return -ENOMEM ; } erase_block_wear =kzalloc (mem,GFP_KERNEL ); -if (!erase_block_wear) { -NS_ERR ("Too many erase blocks for wear reporting\n" ); +if (!erase_block_wear)return -ENOMEM ; - }return 0 ; }@@ -1558,10 +1543,8 @@ static int prog_page(struct nandsim *ns, int num)* again and deadlocks. This was seen in practice. */ mypage->byte =kmem_cache_alloc (ns->nand_pages_slab,GFP_NOFS ); -if (mypage->byte ==NULL ) { -NS_ERR ("prog_page: error allocating memory for page %d\n" , ns->regs.row); +if (!mypage->byte)return -1 ; - }memset (mypage->byte,0xFF , ns->geom.pgszoob); }@@ -2209,10 +2192,8 @@ static int __init ns_init_module(void)/* Allocate and initialize mtd_info, nand_chip and nandsim structures */ chip =kzalloc (sizeof (struct nand_chip ) +sizeof (struct nandsim ),GFP_KERNEL ); -if (!chip) { -NS_ERR ("unable to allocate core structures.\n" ); +if (!chip)return -ENOMEM ; - } nsmtd =nand_to_mtd (chip); nand = (struct nandsim *)(chip +1 );nand_set_controller_data (chip, (void *)nand);drivers/mtd/nand/ndfc.c +1
-3@@ -223,10 +223,8 @@ static int ndfc_probe(struct platform_device *ofdev)dev_set_drvdata (&ofdev->dev, ndfc); ndfc->ndfcbase =of_iomap (ofdev->dev.of_node,0 ); -if (!ndfc->ndfcbase) { -dev_err (&ofdev->dev,"failed to get memory\n" ); +if (!ndfc->ndfcbase)return -EIO ; - } ccr =NDFC_CCR_BS (ndfc->chip_select);drivers/mtd/nand/sunxi_nand.c +1
-3@@ -2030,10 +2030,8 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,sizeof (*chip) + (nsels *sizeof (struct sunxi_nand_chip_sel )), GFP_KERNEL); -if (!chip) { -dev_err (dev,"could not allocate chip\n" ); +if (!chip)return -ENOMEM ; - } chip->nsels = nsels; chip->selected =-1 ;
Signature · 1 line
Nicolas Ferre