linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: adc: adi-axi-adc: Use kobj_to_dev() instead of container_of()
@ 2020-08-20  3:01 Tian Tao
  2020-08-20  9:09 ` Alexandru Ardelean
  0 siblings, 1 reply; 5+ messages in thread
From: Tian Tao @ 2020-08-20  3:01 UTC (permalink / raw)
  To: lars, Michael.Hennerich, jic23, knaack.h, pmeerw, linux-iio,
	linux-kernel

Use kobj_to_dev() instead of container_of()

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
 drivers/iio/adc/adi-axi-adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
index 86b6b65..9109da2 100644
--- a/drivers/iio/adc/adi-axi-adc.c
+++ b/drivers/iio/adc/adi-axi-adc.c
@@ -276,7 +276,7 @@ static struct attribute *adi_axi_adc_attributes[] = {
 static umode_t axi_adc_attr_is_visible(struct kobject *kobj,
 				       struct attribute *attr, int n)
 {
-	struct device *dev = container_of(kobj, struct device, kobj);
+	struct device *dev = kobj_to_dev(kobj);
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct adi_axi_adc_state *st = iio_priv(indio_dev);
 	struct adi_axi_adc_conv *conv = &st->client->conv;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: adc: adi-axi-adc: Use kobj_to_dev() instead of container_of()
  2020-08-20  3:01 [PATCH] iio: adc: adi-axi-adc: Use kobj_to_dev() instead of container_of() Tian Tao
@ 2020-08-20  9:09 ` Alexandru Ardelean
  2020-08-20 13:05   ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Alexandru Ardelean @ 2020-08-20  9:09 UTC (permalink / raw)
  To: Tian Tao
  Cc: Lars-Peter Clausen, Hennerich, Michael, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler, linux-iio, LKML,
	Alexandru Ardelean

On Thu, Aug 20, 2020 at 6:04 AM Tian Tao <tiantao6@hisilicon.com> wrote:
>
> Use kobj_to_dev() instead of container_of()
>

Good point.

Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

> Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
> ---
>  drivers/iio/adc/adi-axi-adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/adi-axi-adc.c b/drivers/iio/adc/adi-axi-adc.c
> index 86b6b65..9109da2 100644
> --- a/drivers/iio/adc/adi-axi-adc.c
> +++ b/drivers/iio/adc/adi-axi-adc.c
> @@ -276,7 +276,7 @@ static struct attribute *adi_axi_adc_attributes[] = {
>  static umode_t axi_adc_attr_is_visible(struct kobject *kobj,
>                                        struct attribute *attr, int n)
>  {
> -       struct device *dev = container_of(kobj, struct device, kobj);
> +       struct device *dev = kobj_to_dev(kobj);
>         struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>         struct adi_axi_adc_state *st = iio_priv(indio_dev);
>         struct adi_axi_adc_conv *conv = &st->client->conv;
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: adc: adi-axi-adc: Use kobj_to_dev() instead of container_of()
  2020-08-20  9:09 ` Alexandru Ardelean
@ 2020-08-20 13:05   ` Andy Shevchenko
  2020-08-20 13:07     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2020-08-20 13:05 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: Tian Tao, Lars-Peter Clausen, Hennerich, Michael,
	Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	linux-iio, LKML, Alexandru Ardelean

On Thu, Aug 20, 2020 at 12:10 PM Alexandru Ardelean
<ardeleanalex@gmail.com> wrote:
> On Thu, Aug 20, 2020 at 6:04 AM Tian Tao <tiantao6@hisilicon.com> wrote:
> >
> > Use kobj_to_dev() instead of container_of()

> Good point.
>
> Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

...

> > -       struct device *dev = container_of(kobj, struct device, kobj);
> > +       struct device *dev = kobj_to_dev(kobj);
> >         struct iio_dev *indio_dev = dev_to_iio_dev(dev);

And now this can be one line since dev is not used separately.

> >         struct adi_axi_adc_state *st = iio_priv(indio_dev);
> >         struct adi_axi_adc_conv *conv = &st->client->conv;

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: adc: adi-axi-adc: Use kobj_to_dev() instead of container_of()
  2020-08-20 13:05   ` Andy Shevchenko
@ 2020-08-20 13:07     ` Andy Shevchenko
  2020-08-22 10:44       ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2020-08-20 13:07 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: Tian Tao, Lars-Peter Clausen, Hennerich, Michael,
	Jonathan Cameron, Hartmut Knaack, Peter Meerwald-Stadler,
	linux-iio, LKML, Alexandru Ardelean

On Thu, Aug 20, 2020 at 4:05 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, Aug 20, 2020 at 12:10 PM Alexandru Ardelean
> <ardeleanalex@gmail.com> wrote:
> > On Thu, Aug 20, 2020 at 6:04 AM Tian Tao <tiantao6@hisilicon.com> wrote:

> > > -       struct device *dev = container_of(kobj, struct device, kobj);
> > > +       struct device *dev = kobj_to_dev(kobj);

> And now this can be one line since dev is not used separately.

On the other hand perhaps one object per line is better to read.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] iio: adc: adi-axi-adc: Use kobj_to_dev() instead of container_of()
  2020-08-20 13:07     ` Andy Shevchenko
@ 2020-08-22 10:44       ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-08-22 10:44 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alexandru Ardelean, Tian Tao, Lars-Peter Clausen, Hennerich,
	Michael, Hartmut Knaack, Peter Meerwald-Stadler, linux-iio, LKML,
	Alexandru Ardelean

On Thu, 20 Aug 2020 16:07:04 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Thu, Aug 20, 2020 at 4:05 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Thu, Aug 20, 2020 at 12:10 PM Alexandru Ardelean
> > <ardeleanalex@gmail.com> wrote:  
> > > On Thu, Aug 20, 2020 at 6:04 AM Tian Tao <tiantao6@hisilicon.com> wrote:  
> 
> > > > -       struct device *dev = container_of(kobj, struct device, kobj);
> > > > +       struct device *dev = kobj_to_dev(kobj);  
> 
> > And now this can be one line since dev is not used separately.  
> 
> On the other hand perhaps one object per line is better to read.
> 

Indeed, not clear one way or the others, so I'm going with the path of
least resistance.  Applied as is.

Thanks,

Jonathan



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-22 10:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20  3:01 [PATCH] iio: adc: adi-axi-adc: Use kobj_to_dev() instead of container_of() Tian Tao
2020-08-20  9:09 ` Alexandru Ardelean
2020-08-20 13:05   ` Andy Shevchenko
2020-08-20 13:07     ` Andy Shevchenko
2020-08-22 10:44       ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).