]> www.infradead.org Git - users/hch/block.git/commitdiff
mtd: block: use a simple bool to track open for write
authorChristoph Hellwig <hch@lst.de>
Wed, 17 May 2023 10:14:14 +0000 (12:14 +0200)
committerChristoph Hellwig <hch@lst.de>
Thu, 8 Jun 2023 11:00:50 +0000 (13:00 +0200)
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>
drivers/mtd/mtd_blkdevs.c
drivers/mtd/mtdblock.c
include/linux/mtd/blktrans.h

index f0bb09fde95e3a287c4202d7ade6de4431814015..bd0b7545364349392f6becd6b69d19b27633b77a 100644 (file)
@@ -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++;
index a0a1194dc1d902579f79b7befdad1d61b4a671a4..fa476fb4dffb6c9289f8b5678ff4f49c06a2a4a9 100644 (file)
@@ -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);
        }
index 15cc9b95e32b526f7f914e9ed9016bca5d96574d..6e471436bba5564c040e26b131e8a01f028e8759 100644 (file)
@@ -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 {