All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>,
	linux-block@vger.kernel.org, linux-xfs@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 11/13] block: convert the elevator_queue attrs to use ->seq_show
Date: Mon, 13 Sep 2021 07:41:19 +0200	[thread overview]
Message-ID: <20210913054121.616001-12-hch@lst.de> (raw)
In-Reply-To: <20210913054121.616001-1-hch@lst.de>

Trivial conversion to the seq_file based sysfs attributes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bfq-iosched.c      | 12 ++++++------
 block/elevator.c         | 21 ++++++++++++---------
 block/kyber-iosched.c    |  7 ++++---
 block/mq-deadline.c      |  5 +++--
 include/linux/elevator.h |  2 +-
 5 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index dd13c2bbc29c1..a72b4f90f3ba2 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -7092,9 +7092,9 @@ static int __init bfq_slab_setup(void)
 	return 0;
 }
 
-static ssize_t bfq_var_show(unsigned int var, char *page)
+static void bfq_var_show(unsigned int var, struct seq_file *sf)
 {
-	return sprintf(page, "%u\n", var);
+	seq_printf(sf, "%u\n", var);
 }
 
 static int bfq_var_store(unsigned long *var, const char *page)
@@ -7109,7 +7109,7 @@ static int bfq_var_store(unsigned long *var, const char *page)
 }
 
 #define SHOW_FUNCTION(__FUNC, __VAR, __CONV)				\
-static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
+static void  __FUNC(struct elevator_queue *e, struct seq_file *sf)	\
 {									\
 	struct bfq_data *bfqd = e->elevator_data;			\
 	u64 __data = __VAR;						\
@@ -7117,7 +7117,7 @@ static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
 		__data = jiffies_to_msecs(__data);			\
 	else if (__CONV == 2)						\
 		__data = div_u64(__data, NSEC_PER_MSEC);		\
-	return bfq_var_show(__data, (page));				\
+	bfq_var_show(__data, (sf));					\
 }
 SHOW_FUNCTION(bfq_fifo_expire_sync_show, bfqd->bfq_fifo_expire[1], 2);
 SHOW_FUNCTION(bfq_fifo_expire_async_show, bfqd->bfq_fifo_expire[0], 2);
@@ -7131,12 +7131,12 @@ SHOW_FUNCTION(bfq_low_latency_show, bfqd->low_latency, 0);
 #undef SHOW_FUNCTION
 
 #define USEC_SHOW_FUNCTION(__FUNC, __VAR)				\
-static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
+static void __FUNC(struct elevator_queue *e, struct seq_file *sf)	\
 {									\
 	struct bfq_data *bfqd = e->elevator_data;			\
 	u64 __data = __VAR;						\
 	__data = div_u64(__data, NSEC_PER_USEC);			\
-	return bfq_var_show(__data, (page));				\
+	bfq_var_show(__data, (sf));					\
 }
 USEC_SHOW_FUNCTION(bfq_slice_idle_us_show, bfqd->bfq_slice_idle);
 #undef USEC_SHOW_FUNCTION
diff --git a/block/elevator.c b/block/elevator.c
index f068585f2f9b8..951bae559e5cb 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -442,21 +442,24 @@ struct request *elv_former_request(struct request_queue *q, struct request *rq)
 
 #define to_elv(atr) container_of((atr), struct elv_fs_entry, attr)
 
-static ssize_t
-elv_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
+static int elv_attr_seq_show(struct kobject *kobj, struct attribute *attr,
+		struct seq_file *sf)
 {
 	struct elv_fs_entry *entry = to_elv(attr);
-	struct elevator_queue *e;
-	ssize_t error;
+	struct elevator_queue *e =
+		container_of(kobj, struct elevator_queue, kobj);
 
 	if (!entry->show)
 		return -EIO;
 
-	e = container_of(kobj, struct elevator_queue, kobj);
 	mutex_lock(&e->sysfs_lock);
-	error = e->type ? entry->show(e, page) : -ENOENT;
+	if (!e->type) {
+		mutex_unlock(&e->sysfs_lock);
+		return -ENOENT;
+	}
+	entry->show(e, sf);
 	mutex_unlock(&e->sysfs_lock);
-	return error;
+	return 0;
 }
 
 static ssize_t
@@ -478,8 +481,8 @@ elv_attr_store(struct kobject *kobj, struct attribute *attr,
 }
 
 static const struct sysfs_ops elv_sysfs_ops = {
-	.show	= elv_attr_show,
-	.store	= elv_attr_store,
+	.seq_show	= elv_attr_seq_show,
+	.store		= elv_attr_store,
 };
 
 static struct kobj_type elv_ktype = {
diff --git a/block/kyber-iosched.c b/block/kyber-iosched.c
index 15a8be57203d6..633f9654b99b9 100644
--- a/block/kyber-iosched.c
+++ b/block/kyber-iosched.c
@@ -12,6 +12,7 @@
 #include <linux/elevator.h>
 #include <linux/module.h>
 #include <linux/sbitmap.h>
+#include <linux/seq_file.h>
 
 #include <trace/events/block.h>
 
@@ -857,12 +858,12 @@ static bool kyber_has_work(struct blk_mq_hw_ctx *hctx)
 }
 
 #define KYBER_LAT_SHOW_STORE(domain, name)				\
-static ssize_t kyber_##name##_lat_show(struct elevator_queue *e,	\
-				       char *page)			\
+static void kyber_##name##_lat_show(struct elevator_queue *e,		\
+		struct seq_file *sf)					\
 {									\
 	struct kyber_queue_data *kqd = e->elevator_data;		\
 									\
-	return sprintf(page, "%llu\n", kqd->latency_targets[domain]);	\
+	seq_printf(sf, "%llu\n", kqd->latency_targets[domain]);		\
 }									\
 									\
 static ssize_t kyber_##name##_lat_store(struct elevator_queue *e,	\
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index 7f3c3932b723e..0e1fc6d3e5d64 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -17,6 +17,7 @@
 #include <linux/compiler.h>
 #include <linux/rbtree.h>
 #include <linux/sbitmap.h>
+#include <linux/seq_file.h>
 
 #include <trace/events/block.h>
 
@@ -800,11 +801,11 @@ static bool dd_has_work(struct blk_mq_hw_ctx *hctx)
  * sysfs parts below
  */
 #define SHOW_INT(__FUNC, __VAR)						\
-static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
+static void __FUNC(struct elevator_queue *e, struct seq_file *sf)	\
 {									\
 	struct deadline_data *dd = e->elevator_data;			\
 									\
-	return sysfs_emit(page, "%d\n", __VAR);				\
+	seq_printf(sf, "%d\n", __VAR);					\
 }
 #define SHOW_JIFFIES(__FUNC, __VAR) SHOW_INT(__FUNC, jiffies_to_msecs(__VAR))
 SHOW_JIFFIES(deadline_read_expire_show, dd->fifo_expire[DD_READ]);
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index deecf7f9ff21a..ad5e4cb653a30 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -56,7 +56,7 @@ struct elevator_mq_ops {
 
 struct elv_fs_entry {
 	struct attribute attr;
-	ssize_t (*show)(struct elevator_queue *, char *);
+	void (*show)(struct elevator_queue *eq, struct seq_file *sf);
 	ssize_t (*store)(struct elevator_queue *, const char *, size_t);
 };
 
-- 
2.30.2


  parent reply	other threads:[~2021-09-13  5:56 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13  5:41 start switching sysfs attributes to expose the seq_file Christoph Hellwig
2021-09-13  5:41 ` [PATCH 01/13] seq_file: mark seq_get_buf as deprecated Christoph Hellwig
2021-09-13 13:19   ` Christian Brauner
2021-09-13 16:22   ` Daniel Wagner
2021-09-13 16:29   ` Tejun Heo
2021-09-13  5:41 ` [PATCH 02/13] kernfs: remove kernfs_create_file and kernfs_create_file_ns Christoph Hellwig
2021-09-13 13:20   ` Christian Brauner
2021-09-13  5:41 ` [PATCH 03/13] kernfs: remove the unused lockdep_key field in struct kernfs_ops Christoph Hellwig
2021-09-13 13:21   ` Christian Brauner
2021-09-13 16:30   ` Tejun Heo
2021-09-13  5:41 ` [PATCH 04/13] sysfs: split out binary attribute handling from sysfs_add_file_mode_ns Christoph Hellwig
2021-09-13 13:26   ` Christian Brauner
2021-09-13  5:41 ` [PATCH 05/13] sysfs: refactor sysfs_add_file_mode_ns Christoph Hellwig
2021-09-13 13:27   ` Christian Brauner
2021-09-13  5:41 ` [PATCH 06/13] sysfs: simplify sysfs_kf_seq_show Christoph Hellwig
2021-09-13  5:41 ` [PATCH 07/13] sysfs: add ->seq_show support to sysfs_ops Christoph Hellwig
2021-09-13 13:30   ` Christian Brauner
2021-09-13  5:41 ` [PATCH 08/13] block: convert the blk_mq_hw_ctx attrs to use ->seq_show Christoph Hellwig
2021-09-13  5:41 ` [PATCH 09/13] block: convert the blk_integrity " Christoph Hellwig
2021-09-13  5:41 ` [PATCH 10/13] block: convert the request_queue " Christoph Hellwig
2021-09-13  5:41 ` Christoph Hellwig [this message]
2021-09-13  5:41 ` [PATCH 12/13] xfs: convert xfs_errortag " Christoph Hellwig
2021-09-13  5:41 ` [PATCH 13/13] xfs: convert xfs_sysfs " Christoph Hellwig
2021-09-13  6:27   ` Greg Kroah-Hartman
2021-09-14  1:20     ` Dave Chinner
2021-09-14  5:12       ` Greg Kroah-Hartman
2021-09-14 10:56         ` Dave Chinner
2021-09-14  7:30     ` Christoph Hellwig
2021-09-14 15:28       ` Greg Kroah-Hartman
2021-09-14 15:30         ` Christoph Hellwig
2021-09-14 15:41           ` Greg Kroah-Hartman
2021-09-15  7:04             ` Christoph Hellwig
2021-09-15  7:07               ` Greg Kroah-Hartman
2021-09-13 16:39 ` start switching sysfs attributes to expose the seq_file Bart Van Assche
2021-09-13 16:46   ` Greg Kroah-Hartman
2021-09-14  2:53     ` Bart Van Assche
2021-09-13 16:46 ` Tejun Heo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210913054121.616001-12-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.