[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220921092646.230274-1-ye.xingchen@zte.com.cn>
Date: Wed, 21 Sep 2022 09:26:46 +0000
From: cgel.zte@...il.com
To: dan.j.williams@...el.com
Cc: vishal.l.verma@...el.com, dave.jiang@...el.com,
ira.weiny@...el.com, nvdimm@...ts.linux.dev,
linux-kernel@...r.kernel.org, Zeal Robot <zealci@....com.cn>,
ye xingchen <ye.xingchen@....com.cn>
Subject:
m 1561c1c9285eaa8638406280b53bb9e0b5a67d93 Mon Sep 17 00:00:00 2001
From: ye xingchen <ye.xingchen@....com.cn>
Date: Wed, 21 Sep 2022 09:21:30 +0800
Subject: [PATCH linux-next] nvdimm: Use the function kobj_to_dev()
Use kobj_to_dev() instead of open-coding it.
Reported-by: Zeal Robot <zealci@....com.cn>
Signed-off-by: ye xingchen <ye.xingchen@....com.cn>
---
drivers/nvdimm/bus.c | 2 +-
drivers/nvdimm/core.c | 2 +-
drivers/nvdimm/dimm_devs.c | 4 ++--
drivers/nvdimm/namespace_devs.c | 2 +-
drivers/nvdimm/region_devs.c | 4 ++--
5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index b38d0355b0ac..6bd53d3a3eeb 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -690,7 +690,7 @@ static struct attribute *nd_numa_attributes[] = {
static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a,
int n)
{
- struct device *dev = container_of(kobj, typeof(*dev), kobj);
+ struct device *dev = kobj_to_dev(kobj);
if (!IS_ENABLED(CONFIG_NUMA))
return 0;
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c
index d91799b71d23..8ee7eddce0b2 100644
--- a/drivers/nvdimm/core.c
+++ b/drivers/nvdimm/core.c
@@ -466,7 +466,7 @@ static DEVICE_ATTR_ADMIN_RW(activate);
static umode_t nvdimm_bus_firmware_visible(struct kobject *kobj, struct attribute *a, int n)
{
- struct device *dev = container_of(kobj, typeof(*dev), kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
enum nvdimm_fwa_capability cap;
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index c7c980577491..5f9487e40111 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -409,7 +409,7 @@ static struct attribute *nvdimm_attributes[] = {
static umode_t nvdimm_visible(struct kobject *kobj, struct attribute *a, int n)
{
- struct device *dev = container_of(kobj, typeof(*dev), kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct nvdimm *nvdimm = to_nvdimm(dev);
if (a != &dev_attr_security.attr && a != &dev_attr_frozen.attr)
@@ -525,7 +525,7 @@ static struct attribute *nvdimm_firmware_attributes[] = {
static umode_t nvdimm_firmware_visible(struct kobject *kobj, struct attribute *a, int n)
{
- struct device *dev = container_of(kobj, typeof(*dev), kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(dev);
struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc;
struct nvdimm *nvdimm = to_nvdimm(dev);
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index dfade66bab73..fd2e8ca67001 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1372,7 +1372,7 @@ static struct attribute *nd_namespace_attributes[] = {
static umode_t namespace_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);
if (is_namespace_pmem(dev)) {
if (a == &dev_attr_size.attr)
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 473a71bbd9c9..886740e2c94f 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -607,7 +607,7 @@ static struct attribute *nd_region_attributes[] = {
static umode_t region_visible(struct kobject *kobj, struct attribute *a, int n)
{
- struct device *dev = container_of(kobj, typeof(*dev), kobj);
+ struct device *dev = kobj_to_dev(kobj);
struct nd_region *nd_region = to_nd_region(dev);
struct nd_interleave_set *nd_set = nd_region->nd_set;
int type = nd_region_to_nstype(nd_region);
@@ -721,7 +721,7 @@ REGION_MAPPING(31);
static umode_t mapping_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 nd_region *nd_region = to_nd_region(dev);
if (n < nd_region->ndr_mappings)
--
2.25.1
Powered by blists - more mailing lists