summaryrefslogtreecommitdiff
path: root/block/disk-events.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-06-24 09:38:43 +0200
committerJens Axboe <axboe@kernel.dk>2021-06-24 12:00:22 -0600
commit2bc8cda5ea4b42ff78be1b11011092d57b424d37 (patch)
tree538072bbb7ef09753ad66de333655a608a676069 /block/disk-events.c
parentd5870edfa3afc4608231267ea3b8e4beb3eab1ee (diff)
block: add the events* attributes to disk_attrs
Add the events attributes to the disk_attrs array, which ensures they are added by the driver core when the device is created rather than adding them after the device has been added, which is racy versus uevents and requires more boilerplate code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20210624073843.251178-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/disk-events.c')
-rw-r--r--block/disk-events.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/block/disk-events.c b/block/disk-events.c
index 1bc5dcb75e4e..a75931ff5da4 100644
--- a/block/disk-events.c
+++ b/block/disk-events.c
@@ -368,18 +368,10 @@ static ssize_t disk_events_poll_msecs_store(struct device *dev,
return count;
}
-static const DEVICE_ATTR(events, 0444, disk_events_show, NULL);
-static const DEVICE_ATTR(events_async, 0444, disk_events_async_show, NULL);
-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[] = {
- &dev_attr_events.attr,
- &dev_attr_events_async.attr,
- &dev_attr_events_poll_msecs.attr,
- NULL,
-};
+DEVICE_ATTR(events, 0444, disk_events_show, NULL);
+DEVICE_ATTR(events_async, 0444, disk_events_async_show, NULL);
+DEVICE_ATTR(events_poll_msecs, 0644, disk_events_poll_msecs_show,
+ disk_events_poll_msecs_store);
/*
* The default polling interval can be specified by the kernel
@@ -444,11 +436,6 @@ void disk_alloc_events(struct gendisk *disk)
void disk_add_events(struct gendisk *disk)
{
- /* FIXME: error handling */
- if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0)
- pr_warn("%s: failed to create sysfs files for events\n",
- disk->disk_name);
-
if (!disk->ev)
return;
@@ -472,8 +459,6 @@ void disk_del_events(struct gendisk *disk)
list_del_init(&disk->ev->node);
mutex_unlock(&disk_events_mutex);
}
-
- sysfs_remove_files(&disk_to_dev(disk)->kobj, disk_events_attrs);
}
void disk_release_events(struct gendisk *disk)