Commit 49d3d50b authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

nvme: simplify nvme_dev_attrs_are_visible

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 180de007
...@@ -2191,23 +2191,16 @@ static struct attribute *nvme_dev_attrs[] = { ...@@ -2191,23 +2191,16 @@ static struct attribute *nvme_dev_attrs[] = {
NULL NULL
}; };
#define CHECK_ATTR(ctrl, a, name) \
if ((a) == &dev_attr_##name.attr && \
!(ctrl)->ops->get_##name) \
return 0
static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj, static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n) struct attribute *a, int n)
{ {
struct device *dev = container_of(kobj, struct device, kobj); struct device *dev = container_of(kobj, struct device, kobj);
struct nvme_ctrl *ctrl = dev_get_drvdata(dev); struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
if (a == &dev_attr_delete_controller.attr) { if (a == &dev_attr_delete_controller.attr && !ctrl->ops->delete_ctrl)
if (!ctrl->ops->delete_ctrl) return 0;
if (a == &dev_attr_address.attr && !ctrl->ops->get_address)
return 0; return 0;
}
CHECK_ATTR(ctrl, a, address);
return a->mode; return a->mode;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment