Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp398092ybg; Sun, 26 Jul 2020 08:06:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwP1EHQgUEjDyKl2Hum4RLNMonkYETzsCRHnAO9zm40i7+F30FvhtMwN1f8vs7vRXqG+Cb9 X-Received: by 2002:a05:6402:1250:: with SMTP id l16mr18019675edw.362.1595775974239; Sun, 26 Jul 2020 08:06:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595775974; cv=none; d=google.com; s=arc-20160816; b=jtUPknLMXKc0lWmHRKITQlus/mIUJIYNqJvJX526z+wuadJo5iirUQX91sQUfR1rQw WKlXdJAV6zBupQvqZqObX7/t7/ibXpaSF2gM79mZwa+7Dpb4gg2ZtKYc7DY87h2hSagm 7dxNKq56EKWwKcipOmQak8R0NyoptbYD5xv3u/DDGle9cIee7UYW3BaodbFGTgz6xwxB JiizXQBdJl0wH+sINlfSmrQvE2M2GyMEY16W06Lr13NpUzSmQ6/8Ds4ZcGeTB/1Q+Qfr /B7S92oVvFruQVHIt8lJmEuyKbKSbPA50hG6118wbcN/oV3pme3WTNFtIzNJXYj+WSz2 j+tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kdnG/8uKQIMddLsDA/8BZYPUgnH5s1kSDlqsFlCYesw=; b=ERRU2MNFomdGw3U31plcIq7+AloCIC8pFHhzi8G2sUuQ9g+dtA3rDRmgRXpuHH3EG6 0ILywuX0q1e4qB2TZEW4h7a0tJav2arpt1VFlkb9MfUK/xr67ZqSvQTTp32uQDEz471W 2VJ8NtEElGEtCnVGaZSyhtGkR5SvkH0sEIM08N4bq5dua6l3gJmrUjie2IqAdas17Iv4 xU8n7xJOReeFF0EYqFVylH+pWbPU2mEX0ZNQObxzzX+Aouo8BFKXuY5KhlROUeu351vk JzMzTKHZ8LGWRtWRy2zBypxJeIzjusm3zDfgMTU9fTpkDok0v11MICNGhp41dPa9XH3U g4/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=ZlUbIgvz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y9si1223211ejc.644.2020.07.26.08.05.52; Sun, 26 Jul 2020 08:06:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=ZlUbIgvz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726981AbgGZPEA (ORCPT + 99 others); Sun, 26 Jul 2020 11:04:00 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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