block: cleanup queue_wc_store
authorChristoph Hellwig <hch@lst.de>
Fri, 7 Jul 2023 09:42:38 +0000 (11:42 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 17 Jul 2023 14:18:17 +0000 (08:18 -0600)
Get rid of the local queue_wc_store variable and handling setting and
clearing the QUEUE_FLAG_WC flag diretly instead the if / else if.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230707094239.107968-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-sysfs.c

index afc797fb0dfc4883b6335c69e4cb6949dcc46ceb..0cde6598fb2f4dcb8e16f2a75b3ffb4c84929a05 100644 (file)
@@ -449,21 +449,13 @@ static ssize_t queue_wc_show(struct request_queue *q, char *page)
 static ssize_t queue_wc_store(struct request_queue *q, const char *page,
                              size_t count)
 {
-       int set = -1;
-
        if (!strncmp(page, "write back", 10))
-               set = 1;
+               blk_queue_flag_set(QUEUE_FLAG_WC, q);
        else if (!strncmp(page, "write through", 13) ||
                 !strncmp(page, "none", 4))
-               set = 0;
-
-       if (set == -1)
-               return -EINVAL;
-
-       if (set)
-               blk_queue_flag_set(QUEUE_FLAG_WC, q);
-       else
                blk_queue_flag_clear(QUEUE_FLAG_WC, q);
+       else
+               return -EINVAL;
 
        return count;
 }