From patchwork Fri Jul 24 07:33:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11682243 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A8CA722 for ; Fri, 24 Jul 2020 07:33:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C7322076A for ; Fri, 24 Jul 2020 07:33:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="A0XjcXi6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbgGXHdm (ORCPT ); Fri, 24 Jul 2020 03:33:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbgGXHdl (ORCPT ); Fri, 24 Jul 2020 03:33:41 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 029B1C0619E5; Fri, 24 Jul 2020 00:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=kdnG/8uKQIMddLsDA/8BZYPUgnH5s1kSDlqsFlCYesw=; b=A0XjcXi6AWg4BAiiYrfb5u7VKs 19+wnBIlBjZAXX4zKVPektF6PWyu+DNmyLaFolk1xBy7MloHa+kvlgrss7ifjhgU6GtD3krmGSe1q Qob4cZHyHGbZ1xL4z4hnUo3T7euA310hpE9Ju6GccfeAQv3NRTZqqerGjyhiyAU3i2gT01UWU2wdk ef4MdFc2ShAPldJJulTxd0016duvA41I7W2q+KZQElydQzCvey2c4dL7RaLeWwRyoYVGgnF3CgjJb 5Vy6ngR2mAoOWKEr+n3p/wzNiPYLuZzlS390YSpz8bv1zWAiHagpWZWbNX/eQY9fB0oM0ifalMldz ts0NHyKA==; Received: from [2001:4bb8:18c:2acc:8dfe:be3c:592c:efc5] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jysCy-0006Cs-5e; Fri, 24 Jul 2020 07:33:33 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Song Liu , Hans de Goede , Richard Weinberger , Minchan Kim , linux-mtd@lists.infradead.org, dm-devel@redhat.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org, Johannes Thumshirn Subject: [PATCH 07/14] block: make QUEUE_SYSFS_BIT_FNS a little more useful Date: Fri, 24 Jul 2020 09:33:06 +0200 Message-Id: <20200724073313.138789-8-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200724073313.138789-1-hch@lst.de> References: <20200724073313.138789-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Generate the queue_sysfs_entry given that we have all the required information for it, and rename the generated show and store methods to match the other ones in the file. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- block/blk-sysfs.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index ce418d9128a0b2..cfbb039da8751f 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -257,16 +257,16 @@ static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page) return queue_var_show(max_hw_sectors_kb, (page)); } -#define QUEUE_SYSFS_BIT_FNS(name, flag, neg) \ +#define QUEUE_SYSFS_BIT_FNS(_name, flag, neg) \ static ssize_t \ -queue_show_##name(struct request_queue *q, char *page) \ +queue_##_name##_show(struct request_queue *q, char *page) \ { \ int bit; \ bit = test_bit(QUEUE_FLAG_##flag, &q->queue_flags); \ return queue_var_show(neg ? !bit : bit, page); \ } \ static ssize_t \ -queue_store_##name(struct request_queue *q, const char *page, size_t count) \ +queue_##_name##_store(struct request_queue *q, const char *page, size_t count) \ { \ unsigned long val; \ ssize_t ret; \ @@ -281,7 +281,12 @@ queue_store_##name(struct request_queue *q, const char *page, size_t count) \ else \ blk_queue_flag_clear(QUEUE_FLAG_##flag, q); \ return ret; \ -} +} \ +static struct queue_sysfs_entry queue_##_name##_entry = { \ + .attr = { .name = __stringify(_name), .mode = 0644 }, \ + .show = queue_##_name##_show, \ + .store = queue_##_name##_store, \ +}; QUEUE_SYSFS_BIT_FNS(nonrot, NONROT, 1); QUEUE_SYSFS_BIT_FNS(random, ADD_RANDOM, 0); @@ -661,12 +666,6 @@ static struct queue_sysfs_entry queue_zone_append_max_entry = { .show = queue_zone_append_max_show, }; -static struct queue_sysfs_entry queue_nonrot_entry = { - .attr = {.name = "rotational", .mode = 0644 }, - .show = queue_show_nonrot, - .store = queue_store_nonrot, -}; - static struct queue_sysfs_entry queue_zoned_entry = { .attr = {.name = "zoned", .mode = 0444 }, .show = queue_zoned_show, @@ -699,18 +698,6 @@ static struct queue_sysfs_entry queue_rq_affinity_entry = { .store = queue_rq_affinity_store, }; -static struct queue_sysfs_entry queue_iostats_entry = { - .attr = {.name = "iostats", .mode = 0644 }, - .show = queue_show_iostats, - .store = queue_store_iostats, -}; - -static struct queue_sysfs_entry queue_random_entry = { - .attr = {.name = "add_random", .mode = 0644 }, - .show = queue_show_random, - .store = queue_store_random, -}; - static struct queue_sysfs_entry queue_poll_entry = { .attr = {.name = "io_poll", .mode = 0644 }, .show = queue_poll_show,