From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: [PATCH 07/14] block: make QUEUE_SYSFS_BIT_FNS a little more useful Date: Sun, 26 Jul 2020 17:03:26 +0200 Message-ID: <20200726150333.305527-8-hch@lst.de> References: <20200726150333.305527-1-hch@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20200726150333.305527-1-hch-jcswGhMUV9g@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: drbd-dev-bounces-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org Errors-To: drbd-dev-bounces-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org To: Jens Axboe Cc: linux-raid-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Hans de Goede , Minchan Kim , Richard Weinberger , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Song Liu , dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Johannes Thumshirn , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, drbd-dev-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org List-Id: linux-raid.ids 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, -- 2.27.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0609FC433E4 for ; Sun, 26 Jul 2020 15:04:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D83862070B for ; Sun, 26 Jul 2020 15:04:49 +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="ZlUbIgvz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726952AbgGZPD7 (ORCPT ); Sun, 26 Jul 2020 11:03:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726918AbgGZPDz (ORCPT ); Sun, 26 Jul 2020 11:03:55 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE3BC0619D5; Sun, 26 Jul 2020 08:03:55 -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=ZlUbIgvz5W+wNZyXR6smJAUXas evPOz6Ja3vFXE9UY2uAmviOobnai2PzHbDI+ijvPBexgfsz1flsWVkMK3mMsjPeRfpzTtILWc4olD Hj+/WaWcA6UhlhC80A+lhxePrJn4C44YMiZhGd8QAKQ/i8EthVTqcPNN7UqDnUR30qrdZ4fG1iudN XBDssURerbKMOfZhaB0z0cjf41fJx8gqw/53CntsqtJiJrZfYmDDcMm+ieudAv5pwN/pd9KDuNkal CXpWl6zKdMFN2J37a8Slp+8TFWLMHjB6LAwa0cpEDl/bTu+fjIb9lz5Fe0cBbaueULO6dV+eNfOr8 cPAkBGvw==; Received: from [2001:4bb8:18c:2acc:2375:88ff:9f84:118d] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jziBn-0005h0-2s; Sun, 26 Jul 2020 15:03:47 +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: Sun, 26 Jul 2020 17:03:26 +0200 Message-Id: <20200726150333.305527-8-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200726150333.305527-1-hch@lst.de> References: <20200726150333.305527-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, -- 2.27.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13499C433EC for ; Sun, 26 Jul 2020 15:04:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D3DAD207DA for ; Sun, 26 Jul 2020 15:04:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hNYXj1yI"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZlUbIgvz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3DAD207DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Kr1jqA4+aPhbmNtcBPxXOq3PZ9azj3nn2Cnl09iKEOo=; b=hNYXj1yItIgS+9/FU9XDc3HJB qSgJnHQXW3mwqn+E0wzDrZBLRZgxUUI0ag3GBuC9b9dWzUOq+1dv6K1ufdHKR8h7EeeUPI1cYTSBg 3PmYrtiihPQGYyfyJNwLPSyw0DzyFdy4RLls6qrsEjeVdQjK4P09kU+tHHb4DRab6DhNO6QQublP2 XUt64ZVSs7ercfrBg1nPr1BHpUL/8OW8YnEeRVS4e4dqvo9XcZlWJKcs99ZOuD2LMk4aWZotHgsHR Gj6Nc2Oij7Qm/JwOakGdMBtK/0w/OdDJZusHoxaIa1PVYjJ9og6/B0tczTOKgpPB0G2BpzD4fJcus 9lSGraANw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jziC9-0003EF-Rt; Sun, 26 Jul 2020 15:04:09 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jziBo-00034l-Hq for linux-mtd@merlin.infradead.org; Sun, 26 Jul 2020 15:03:48 +0000 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=ZlUbIgvz5W+wNZyXR6smJAUXas evPOz6Ja3vFXE9UY2uAmviOobnai2PzHbDI+ijvPBexgfsz1flsWVkMK3mMsjPeRfpzTtILWc4olD Hj+/WaWcA6UhlhC80A+lhxePrJn4C44YMiZhGd8QAKQ/i8EthVTqcPNN7UqDnUR30qrdZ4fG1iudN XBDssURerbKMOfZhaB0z0cjf41fJx8gqw/53CntsqtJiJrZfYmDDcMm+ieudAv5pwN/pd9KDuNkal CXpWl6zKdMFN2J37a8Slp+8TFWLMHjB6LAwa0cpEDl/bTu+fjIb9lz5Fe0cBbaueULO6dV+eNfOr8 cPAkBGvw==; Received: from [2001:4bb8:18c:2acc:2375:88ff:9f84:118d] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jziBn-0005h0-2s; Sun, 26 Jul 2020 15:03:47 +0000 From: Christoph Hellwig To: Jens Axboe Subject: [PATCH 07/14] block: make QUEUE_SYSFS_BIT_FNS a little more useful Date: Sun, 26 Jul 2020 17:03:26 +0200 Message-Id: <20200726150333.305527-8-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200726150333.305527-1-hch@lst.de> References: <20200726150333.305527-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 X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-raid@vger.kernel.org, Hans de Goede , Minchan Kim , Richard Weinberger , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Song Liu , dm-devel@redhat.com, linux-mtd@lists.infradead.org, Johannes Thumshirn , linux-fsdevel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, drbd-dev@lists.linbit.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.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, -- 2.27.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/