[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210520135622.44625-4-mcroce@linux.microsoft.com>
Date: Thu, 20 May 2021 15:56:19 +0200
From: Matteo Croce <mcroce@...ux.microsoft.com>
To: linux-block@...r.kernel.org, linux-fsdevel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Lennart Poettering <lennart@...ttering.net>,
Luca Boccassi <bluca@...ian.org>, Jens Axboe <axboe@...nel.dk>,
Alexander Viro <viro@...iv.linux.org.uk>,
Damien Le Moal <damien.lemoal@....com>,
Tejun Heo <tj@...nel.org>,
Javier González <javier@...igon.com>,
Niklas Cassel <niklas.cassel@....com>,
Johannes Thumshirn <johannes.thumshirn@....com>,
Hannes Reinecke <hare@...e.de>,
Matthew Wilcox <willy@...radead.org>,
Christoph Hellwig <hch@...radead.org>,
JeffleXu <jefflexu@...ux.alibaba.com>
Subject: [PATCH v2 3/6] block: refactor sysfs code
From: Matteo Croce <mcroce@...rosoft.com>
Move the sysfs register code from a function named disk_add_events() to
a new function named disk_add_sysfs(). Also, rename the attribute list
with a more generic name than disk_events_attrs.
This is a prerequisite patch to export diskseq in sysfs later.
Signed-off-by: Matteo Croce <mcroce@...rosoft.com>
---
block/genhd.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/block/genhd.c b/block/genhd.c
index 2c7e148fa944..417dd5666be5 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -41,6 +41,7 @@ static void disk_alloc_events(struct gendisk *disk);
static void disk_add_events(struct gendisk *disk);
static void disk_del_events(struct gendisk *disk);
static void disk_release_events(struct gendisk *disk);
+static void disk_add_sysfs(struct gendisk *disk);
void set_capacity(struct gendisk *disk, sector_t sectors)
{
@@ -562,6 +563,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
*/
WARN_ON_ONCE(!blk_get_queue(disk->queue));
+ disk_add_sysfs(disk);
disk_add_events(disk);
blk_integrity_add(disk);
}
@@ -1763,7 +1765,7 @@ static const DEVICE_ATTR(events_poll_msecs, 0644,
disk_events_poll_msecs_show,
disk_events_poll_msecs_store);
-static const struct attribute *disk_events_attrs[] = {
+static const struct attribute *disk_sysfs_attrs[] = {
&dev_attr_events.attr,
&dev_attr_events_async.attr,
&dev_attr_events_poll_msecs.attr,
@@ -1834,13 +1836,16 @@ static void disk_alloc_events(struct gendisk *disk)
disk->ev = ev;
}
-static void disk_add_events(struct gendisk *disk)
+static void disk_add_sysfs(struct gendisk *disk)
{
/* FIXME: error handling */
- if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0)
+ if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_sysfs_attrs) < 0)
pr_warn("%s: failed to create sysfs files for events\n",
disk->disk_name);
+}
+static void disk_add_events(struct gendisk *disk)
+{
if (!disk->ev)
return;
@@ -1865,7 +1870,7 @@ static void disk_del_events(struct gendisk *disk)
mutex_unlock(&disk_events_mutex);
}
- sysfs_remove_files(&disk_to_dev(disk)->kobj, disk_events_attrs);
+ sysfs_remove_files(&disk_to_dev(disk)->kobj, disk_sysfs_attrs);
}
static void disk_release_events(struct gendisk *disk)
--
2.31.1
Powered by blists - more mailing lists