Skip to content

Commit

Permalink
mtd: block: use a simple bool to track open for write
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and axboe committed Jun 12, 2023
1 parent 7d9d7d5 commit 658afed
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion drivers/mtd/mtd_blkdevs.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static int blktrans_open(struct gendisk *disk, fmode_t mode)
ret = __get_mtd_device(dev->mtd);
if (ret)
goto error_release;
dev->file_mode = mode;
dev->writable = mode & FMODE_WRITE;

unlock:
dev->open++;
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/mtdblock.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static void mtdblock_release(struct mtd_blktrans_dev *mbd)
* It was the last usage. Free the cache, but only sync if
* opened for writing.
*/
if (mbd->file_mode & FMODE_WRITE)
if (mbd->writable)
mtd_sync(mbd->mtd);
vfree(mtdblk->cache_data);
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/mtd/blktrans.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct mtd_blktrans_dev {
struct blk_mq_tag_set *tag_set;
spinlock_t queue_lock;
void *priv;
fmode_t file_mode;
bool writable;
};

struct mtd_blktrans_ops {
Expand Down

0 comments on commit 658afed

Please sign in to comment.