Re: [patch] bkl2mtd: cleanup

From: Al Viro
Date: Wed Mar 26 2008 - 06:48:42 EST


On Wed, Mar 26, 2008 at 11:14:52AM +0100, Ingo Molnar wrote:
> /* Info for the block device */
> struct block2mtd_dev {
> - struct list_head list;
> - struct block_device *blkdev;
> - struct mtd_info mtd;
> - struct mutex write_mutex;
> + struct list_head list;
> + struct block_device *blkdev;
> + struct mtd_info mtd;
> + /* serializes writes with each other and also with erase: */
> + struct mutex write_mutex;
> };

Why the hell?

> -static int _block2mtd_write(struct block2mtd_dev *dev, const u_char *buf,
> - loff_t to, size_t len, size_t *retlen)
> +static int
> +_block2mtd_write(struct block2mtd_dev *dev, const u_char *buf, loff_t to,
> + size_t len, size_t *retlen)

That's actually worse... BTW, single-underscore-... for identifiers? Odd.

> -static int block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
> +static int
> +block2mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
> size_t *retlen, const u_char *buf)

Again, why split it that way?

> - dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
> - dev->mtd.erasesize = erase_size;
> - dev->mtd.writesize = 1;
> - dev->mtd.type = MTD_RAM;
> - dev->mtd.flags = MTD_CAP_RAM;
> - dev->mtd.erase = block2mtd_erase;
> - dev->mtd.write = block2mtd_write;
> - dev->mtd.writev = default_mtd_writev;
> - dev->mtd.sync = block2mtd_sync;
> - dev->mtd.read = block2mtd_read;
> - dev->mtd.priv = dev;
> - dev->mtd.owner = THIS_MODULE;
> + dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
> + dev->mtd.erasesize = erase_size;
> + dev->mtd.writesize = 1;
> + dev->mtd.type = MTD_RAM;
> + dev->mtd.flags = MTD_CAP_RAM;
> + dev->mtd.erase = block2mtd_erase;
> + dev->mtd.write = block2mtd_write;
> + dev->mtd.writev = default_mtd_writev;
> + dev->mtd.sync = block2mtd_sync;
> + dev->mtd.read = block2mtd_read;
> + dev->mtd.priv = dev;
> + dev->mtd.owner = THIS_MODULE;

Bogus.

> - if (ret) {
> + if (ret)
> parse_err("illegal erase size");
> - }
> }

BTW, I certainly wouldn't inflict that on patches; at some point in
series the body of if may shrink to one line only to get longer in
the next patch. Removing and restoring {} would only add noise.

OTOH, you've missed quite a few of my pet peeves, starting with
u_char in the quoted part...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/