Message ID | 20220811013106.15947-1-ye.xingchen@zte.com.cn (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [linux-next] nvdimm/namespace:Use the function kobj_to_dev() | expand |
On Thu, Aug 11, 2022 at 01:31:06AM +0000, cgel.zte@gmail.com wrote: > From: ye xingchen <ye.xingchen@zte.com.cn> > > Use kobj_to_dev() instead of open-coding it. I see at least 5 other places where this pattern applies in drivers/nvdimm. Is this some general conversion being done on the entire kernel? If so why not convert entire drivers at a time? Ira > > Reported-by: Zeal Robot <zealci@zte.com.cn> > Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> > --- > drivers/nvdimm/namespace_devs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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) > -- > 2.25.1
Ira Weiny wrote: > On Thu, Aug 11, 2022 at 01:31:06AM +0000, cgel.zte@gmail.com wrote: > > From: ye xingchen <ye.xingchen@zte.com.cn> > > > > Use kobj_to_dev() instead of open-coding it. > > I see at least 5 other places where this pattern applies in drivers/nvdimm. Is > this some general conversion being done on the entire kernel? If so why not > convert entire drivers at a time? Yes, please convert all of these at once: drivers/nvdimm/bus.c:693: struct device *dev = container_of(kobj, typeof(*dev), kobj); drivers/nvdimm/core.c:469: struct device *dev = container_of(kobj, typeof(*dev), kobj); drivers/nvdimm/dimm_devs.c:412: struct device *dev = container_of(kobj, typeof(*dev), kobj); drivers/nvdimm/dimm_devs.c:528: struct device *dev = container_of(kobj, typeof(*dev), kobj); drivers/nvdimm/namespace_devs.c:1383: struct device *dev = container_of(kobj, struct device, kobj); drivers/nvdimm/region_devs.c:610: struct device *dev = container_of(kobj, typeof(*dev), kobj); drivers/nvdimm/region_devs.c:724: struct device *dev = container_of(kobj, struct device, kobj);
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)