Shrink the goto logic where easily possible. Changing the return type to int allows vmu_flash_read_char() to follow normal Linux style. Signed-off-by: Jörn Engel --- drivers/mtd/maps/vmu_flash.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) --- maple/drivers/mtd/maps/vmu_flash.c~cu3 2008-03-24 14:44:50.000000000 +0100 +++ maple/drivers/mtd/maps/vmu_flash.c 2008-03-24 14:55:22.000000000 +0100 @@ -76,22 +76,19 @@ static struct vmu_block *ofs_to_block(un card = mdev->private_data; if (src_ofs >= ((card->parts)[partition]).numblocks * card->blocklen) - goto failed; + return NULL; num = src_ofs / card->blocklen; if (num > ((card->parts)[partition]).numblocks) - goto failed; + return NULL; vblock = kmalloc(sizeof(struct vmu_block), GFP_KERNEL); if (!vblock) - goto failed; + return NULL; vblock->num = num; vblock->ofs = src_ofs % card->blocklen; return vblock; - -failed: - return NULL; } @@ -264,15 +261,15 @@ fail_nosendbuf: } /* mtd function to simulate reading byte by byte */ -static unsigned char vmu_flash_read_char(unsigned long ofs, int *retval, +static int vmu_flash_read_char(unsigned long ofs, int *retval, struct mtd_info *mtd) { struct vmu_block *vblock; struct memcard *card; struct mdev_part *mpart; struct maple_device *mdev; - unsigned char *buf, ret; - int partition, error; + unsigned char *buf; + int partition, ret; mpart = mtd->priv; mdev = mpart->mdev; @@ -282,33 +279,27 @@ static unsigned char vmu_flash_read_char buf = kmalloc(card->blocklen, GFP_KERNEL); if (!buf) { *retval = 1; - error = -ENOMEM; - goto fail_buffer; + return -ENOMEM; } vblock = ofs_to_block(ofs, mtd, partition); if (!vblock) { *retval = 3; - error = -ENOMEM; + ret = -ENOMEM; goto invalid_block; } - error = maple_vmu_read_block(vblock->num, buf, mtd); - if (error) { + ret = maple_vmu_read_block(vblock->num, buf, mtd); + if (ret) { *retval = 2; goto failed_block; } ret = buf[vblock->ofs]; - kfree(buf); - kfree(vblock); - return ret; - failed_block: kfree(vblock); invalid_block: kfree(buf); -fail_buffer: - return error; + return ret; } /* mtd higher order function to read flash */ @@ -321,7 +312,7 @@ static int vmu_flash_read(struct mtd_inf struct vmu_cache *pcache; struct vmu_block *vblock = NULL; int index = 0, retval, partition, leftover, numblocks; - unsigned char cx; + int cx; mpart = mtd->priv; mdev = mpart->mdev; @@ -364,9 +355,9 @@ static int vmu_flash_read(struct mtd_inf } else { /* Not cached so read from the device */ cx = vmu_flash_read_char(from + index, &retval, mtd); - if (retval) { + if (cx < 0) { *retlen = index; - return -EIO; + return cx; } memset(buf + index, cx, 1); index++;