2020-08-13 02:56:56

by 王擎

[permalink] [raw]
Subject: [PATCH] acpi/nfit: Use kobj_to_dev() instead

Use kobj_to_dev() instead of container_of()

Signed-off-by: Wang Qing <[email protected]>
---
drivers/acpi/nfit/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
index fa4500f..3bb350b
--- a/drivers/acpi/nfit/core.c
+++ b/drivers/acpi/nfit/core.c
@@ -1382,7 +1382,7 @@ static bool ars_supported(struct nvdimm_bus *nvdimm_bus)

static umode_t nfit_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 nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);

if (a == &dev_attr_scrub.attr && !ars_supported(nvdimm_bus))
@@ -1667,7 +1667,7 @@ static struct attribute *acpi_nfit_dimm_attributes[] = {
static umode_t acpi_nfit_dimm_attr_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 nvdimm *nvdimm = to_nvdimm(dev);
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);

--
2.7.4


2020-08-14 15:30:02

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] acpi/nfit: Use kobj_to_dev() instead

On Thu, Aug 13, 2020 at 4:54 AM Wang Qing <[email protected]> wrote:
>
> Use kobj_to_dev() instead of container_of()
>
> Signed-off-by: Wang Qing <[email protected]>

LGTM

Dan, any objections?

> ---
> drivers/acpi/nfit/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> index fa4500f..3bb350b
> --- a/drivers/acpi/nfit/core.c
> +++ b/drivers/acpi/nfit/core.c
> @@ -1382,7 +1382,7 @@ static bool ars_supported(struct nvdimm_bus *nvdimm_bus)
>
> static umode_t nfit_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 nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
>
> if (a == &dev_attr_scrub.attr && !ars_supported(nvdimm_bus))
> @@ -1667,7 +1667,7 @@ static struct attribute *acpi_nfit_dimm_attributes[] = {
> static umode_t acpi_nfit_dimm_attr_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 nvdimm *nvdimm = to_nvdimm(dev);
> struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
>
> --
> 2.7.4
>

2020-08-14 23:06:23

by Verma, Vishal L

[permalink] [raw]
Subject: Re: [PATCH] acpi/nfit: Use kobj_to_dev() instead

On Fri, 2020-08-14 at 17:28 +0200, Rafael J. Wysocki wrote:
> On Thu, Aug 13, 2020 at 4:54 AM Wang Qing <[email protected]> wrote:
> > Use kobj_to_dev() instead of container_of()
> >
> > Signed-off-by: Wang Qing <[email protected]>
>
> LGTM
>
> Dan, any objections?

Looks good to me - you can add:
Acked-by: Vishal Verma <[email protected]>
>
> > ---
> > drivers/acpi/nfit/core.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> > index fa4500f..3bb350b
> > --- a/drivers/acpi/nfit/core.c
> > +++ b/drivers/acpi/nfit/core.c
> > @@ -1382,7 +1382,7 @@ static bool ars_supported(struct nvdimm_bus *nvdimm_bus)
> >
> > static umode_t nfit_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 nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
> >
> > if (a == &dev_attr_scrub.attr && !ars_supported(nvdimm_bus))
> > @@ -1667,7 +1667,7 @@ static struct attribute *acpi_nfit_dimm_attributes[] = {
> > static umode_t acpi_nfit_dimm_attr_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 nvdimm *nvdimm = to_nvdimm(dev);
> > struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> >
> > --
> > 2.7.4
> >

2020-09-15 17:57:15

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] acpi/nfit: Use kobj_to_dev() instead

On Sat, Aug 15, 2020 at 12:52 AM Verma, Vishal L
<[email protected]> wrote:
>
> On Fri, 2020-08-14 at 17:28 +0200, Rafael J. Wysocki wrote:
> > On Thu, Aug 13, 2020 at 4:54 AM Wang Qing <[email protected]> wrote:
> > > Use kobj_to_dev() instead of container_of()
> > >
> > > Signed-off-by: Wang Qing <[email protected]>
> >
> > LGTM
> >
> > Dan, any objections?
>
> Looks good to me - you can add:
> Acked-by: Vishal Verma <[email protected]>

Applied as 5.10 material, thanks!

> > > ---
> > > drivers/acpi/nfit/core.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c
> > > index fa4500f..3bb350b
> > > --- a/drivers/acpi/nfit/core.c
> > > +++ b/drivers/acpi/nfit/core.c
> > > @@ -1382,7 +1382,7 @@ static bool ars_supported(struct nvdimm_bus *nvdimm_bus)
> > >
> > > static umode_t nfit_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 nvdimm_bus *nvdimm_bus = to_nvdimm_bus(dev);
> > >
> > > if (a == &dev_attr_scrub.attr && !ars_supported(nvdimm_bus))
> > > @@ -1667,7 +1667,7 @@ static struct attribute *acpi_nfit_dimm_attributes[] = {
> > > static umode_t acpi_nfit_dimm_attr_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 nvdimm *nvdimm = to_nvdimm(dev);
> > > struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
> > >
> > > --
> > > 2.7.4
> > >