[PATCH] NVMe: use kobj_to_dev()

From: cgel . zte
Date: Tue May 10 2022 - 06:55:32 EST


From: Minghao Chi <chi.minghao@xxxxxxxxxx>

Use kobj_to_dev() instead of open-coding it.

Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Signed-off-by: Minghao Chi <chi.minghao@xxxxxxxxxx>
---
drivers/nvme/host/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 510e3860358b..48d2bb0a4fad 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3267,7 +3267,7 @@ static struct attribute *nvme_ns_id_attrs[] = {
static umode_t nvme_ns_id_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
- struct device *dev = container_of(kobj, struct device, kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct nvme_ns_ids *ids = &dev_to_ns_head(dev)->ids;

if (a == &dev_attr_uuid.attr) {
@@ -3572,7 +3572,7 @@ static struct attribute *nvme_dev_attrs[] = {
static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
struct attribute *a, int n)
{
- struct device *dev = container_of(kobj, struct device, kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);

if (a == &dev_attr_delete_controller.attr && !ctrl->ops->delete_ctrl)
--
2.25.1