Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1741796
| From | Martin Wilck <mwilck@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 2/2] nvme: use device_add_disk_with_groups() |
| Date | 2017-09-28 21:40 +0200 |
| Message-ID | <uuMP8-4CX-25@gated-at.bofh.it> (permalink) |
| References | <uuMP7-4CX-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
By using device_add_disk_with_groups(), we can avoid the race
condition with udev rule processing, because no udev event will
be triggered before all attributes are available.
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
drivers/nvme/host/core.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 5a14cc7f28ee..e7289a727715 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2156,6 +2156,11 @@ static const struct attribute_group nvme_ns_attr_group = {
.is_visible = nvme_ns_attrs_are_visible,
};
+static const struct attribute_group *nvme_ns_attr_groups[] = {
+ &nvme_ns_attr_group,
+ NULL,
+};
+
#define nvme_show_str_function(field) \
static ssize_t field##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
@@ -2405,11 +2410,8 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
kfree(id);
- device_add_disk(ctrl->device, ns->disk);
- if (sysfs_create_group(&disk_to_dev(ns->disk)->kobj,
- &nvme_ns_attr_group))
- pr_warn("%s: failed to create sysfs group for identification\n",
- ns->disk->disk_name);
+ device_add_disk_with_groups(ctrl->device, ns->disk,
+ nvme_ns_attr_groups);
if (ns->ndev && nvme_nvm_register_sysfs(ns))
pr_warn("%s: failed to register lightnvm sysfs group for identification\n",
ns->disk->disk_name);
--
2.14.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/2] block: genhd: add device_add_disk_with_groups Martin Wilck <mwilck@suse.com> - 2017-09-28 21:40 +0200
[PATCH 2/2] nvme: use device_add_disk_with_groups() Martin Wilck <mwilck@suse.com> - 2017-09-28 21:40 +0200
RE: [PATCH 2/2] nvme: use device_add_disk_with_groups() "Schremmer, Steven" <Steve.Schremmer@netapp.com> - 2017-09-29 21:30 +0200
Re: [PATCH 2/2] nvme: use device_add_disk_with_groups() Keith Busch <keith.busch@intel.com> - 2017-09-30 01:10 +0200
RE: [PATCH 1/2] block: genhd: add device_add_disk_with_groups "Schremmer, Steven" <Steve.Schremmer@netapp.com> - 2017-09-29 21:30 +0200
Re: [PATCH 1/2] block: genhd: add device_add_disk_with_groups Keith Busch <keith.busch@intel.com> - 2017-09-30 01:10 +0200
Re: [PATCH 1/2] block: genhd: add device_add_disk_with_groups Christoph Hellwig <hch@lst.de> - 2017-10-01 10:10 +0200
csiph-web