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

mtd: block: use a simple bool to track open for write

Instead of propagating the fmode_t, just use a bool to track if a mtd
block device was opened for writing.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Acked-by: Christian Brauner <brauner@kernel.org>
Acked-by: Richard Weinberger <richard@nod.at>
Link: https://lore.kernel.org/r/20230608110258.189493-23-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
658afed1 7d9d7d59

+3 -3
+1 -1
drivers/mtd/mtd_blkdevs.c
··· 208 208 ret = __get_mtd_device(dev->mtd); 209 209 if (ret) 210 210 goto error_release; 211 - dev->file_mode = mode; 211 + dev->writable = mode & FMODE_WRITE; 212 212 213 213 unlock: 214 214 dev->open++;
+1 -1
drivers/mtd/mtdblock.c
··· 294 294 * It was the last usage. Free the cache, but only sync if 295 295 * opened for writing. 296 296 */ 297 - if (mbd->file_mode & FMODE_WRITE) 297 + if (mbd->writable) 298 298 mtd_sync(mbd->mtd); 299 299 vfree(mtdblk->cache_data); 300 300 }
+1 -1
include/linux/mtd/blktrans.h
··· 34 34 struct blk_mq_tag_set *tag_set; 35 35 spinlock_t queue_lock; 36 36 void *priv; 37 - fmode_t file_mode; 37 + bool writable; 38 38 }; 39 39 40 40 struct mtd_blktrans_ops {