linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: light: iqs621: remove usage of iio_priv_to_dev()
@ 2020-05-22  6:54 Alexandru Ardelean
  2020-05-23  1:56 ` Jeff LaBundy
  0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Ardelean @ 2020-05-22  6:54 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: jeff, jic23, Alexandru Ardelean

We may want to get rid of the iio_priv_to_dev() helper. That's a bit
uncertain at this point. The reason is that we will hide some of the
members of the iio_dev structure (to prevent drivers from accessing them
directly), and that will also mean hiding the implementation of the
iio_priv_to_dev() helper inside the IIO core.

Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
may not be fast anymore, so a general idea is to try to get rid of the
iio_priv_to_dev() altogether.

For this driver, removing iio_priv_to_dev() means keeping a reference
on the state struct.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/light/iqs621-als.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/light/iqs621-als.c b/drivers/iio/light/iqs621-als.c
index b2988a782bd0..1a056e2446ab 100644
--- a/drivers/iio/light/iqs621-als.c
+++ b/drivers/iio/light/iqs621-als.c
@@ -36,6 +36,7 @@
 
 struct iqs621_als_private {
 	struct iqs62x_core *iqs62x;
+	struct iio_dev *indio_dev;
 	struct notifier_block notifier;
 	struct mutex lock;
 	bool light_en;
@@ -103,7 +104,7 @@ static int iqs621_als_notifier(struct notifier_block *notifier,
 
 	iqs621_als = container_of(notifier, struct iqs621_als_private,
 				  notifier);
-	indio_dev = iio_priv_to_dev(iqs621_als);
+	indio_dev = iqs621_als->indio_dev;
 	timestamp = iio_get_time_ns(indio_dev);
 
 	mutex_lock(&iqs621_als->lock);
@@ -191,7 +192,7 @@ static int iqs621_als_notifier(struct notifier_block *notifier,
 static void iqs621_als_notifier_unregister(void *context)
 {
 	struct iqs621_als_private *iqs621_als = context;
-	struct iio_dev *indio_dev = iio_priv_to_dev(iqs621_als);
+	struct iio_dev *indio_dev = iqs621_als->indio_dev;
 	int ret;
 
 	ret = blocking_notifier_chain_unregister(&iqs621_als->iqs62x->nh,
@@ -551,6 +552,7 @@ static int iqs621_als_probe(struct platform_device *pdev)
 
 	iqs621_als = iio_priv(indio_dev);
 	iqs621_als->iqs62x = iqs62x;
+	iqs621_als->indio_dev = indio_dev;
 
 	if (iqs62x->dev_desc->prod_num == IQS622_PROD_NUM) {
 		ret = regmap_read(iqs62x->regmap, IQS622_IR_THRESH_TOUCH,
-- 
2.25.1


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

* Re: [PATCH] iio: light: iqs621: remove usage of iio_priv_to_dev()
  2020-05-22  6:54 [PATCH] iio: light: iqs621: remove usage of iio_priv_to_dev() Alexandru Ardelean
@ 2020-05-23  1:56 ` Jeff LaBundy
  2020-05-24 14:40   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff LaBundy @ 2020-05-23  1:56 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-iio, linux-kernel, jic23

Hi Alexandru,

On Fri, May 22, 2020 at 09:54:42AM +0300, Alexandru Ardelean wrote:
> We may want to get rid of the iio_priv_to_dev() helper. That's a bit
> uncertain at this point. The reason is that we will hide some of the
> members of the iio_dev structure (to prevent drivers from accessing them
> directly), and that will also mean hiding the implementation of the
> iio_priv_to_dev() helper inside the IIO core.
> 
> Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
> may not be fast anymore, so a general idea is to try to get rid of the
> iio_priv_to_dev() altogether.
> 
> For this driver, removing iio_priv_to_dev() means keeping a reference
> on the state struct.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> ---
>  drivers/iio/light/iqs621-als.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

As with the iqs624 patch:

Acked-by: Jeff LaBundy <jeff@labundy.com>

> 
> diff --git a/drivers/iio/light/iqs621-als.c b/drivers/iio/light/iqs621-als.c
> index b2988a782bd0..1a056e2446ab 100644
> --- a/drivers/iio/light/iqs621-als.c
> +++ b/drivers/iio/light/iqs621-als.c
> @@ -36,6 +36,7 @@
>  
>  struct iqs621_als_private {
>  	struct iqs62x_core *iqs62x;
> +	struct iio_dev *indio_dev;
>  	struct notifier_block notifier;
>  	struct mutex lock;
>  	bool light_en;
> @@ -103,7 +104,7 @@ static int iqs621_als_notifier(struct notifier_block *notifier,
>  
>  	iqs621_als = container_of(notifier, struct iqs621_als_private,
>  				  notifier);
> -	indio_dev = iio_priv_to_dev(iqs621_als);
> +	indio_dev = iqs621_als->indio_dev;
>  	timestamp = iio_get_time_ns(indio_dev);
>  
>  	mutex_lock(&iqs621_als->lock);
> @@ -191,7 +192,7 @@ static int iqs621_als_notifier(struct notifier_block *notifier,
>  static void iqs621_als_notifier_unregister(void *context)
>  {
>  	struct iqs621_als_private *iqs621_als = context;
> -	struct iio_dev *indio_dev = iio_priv_to_dev(iqs621_als);
> +	struct iio_dev *indio_dev = iqs621_als->indio_dev;
>  	int ret;
>  
>  	ret = blocking_notifier_chain_unregister(&iqs621_als->iqs62x->nh,
> @@ -551,6 +552,7 @@ static int iqs621_als_probe(struct platform_device *pdev)
>  
>  	iqs621_als = iio_priv(indio_dev);
>  	iqs621_als->iqs62x = iqs62x;
> +	iqs621_als->indio_dev = indio_dev;
>  
>  	if (iqs62x->dev_desc->prod_num == IQS622_PROD_NUM) {
>  		ret = regmap_read(iqs62x->regmap, IQS622_IR_THRESH_TOUCH,
> -- 
> 2.25.1
> 

Kind regards,
Jeff LaBundy

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

* Re: [PATCH] iio: light: iqs621: remove usage of iio_priv_to_dev()
  2020-05-23  1:56 ` Jeff LaBundy
@ 2020-05-24 14:40   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2020-05-24 14:40 UTC (permalink / raw)
  To: Jeff LaBundy; +Cc: Alexandru Ardelean, linux-iio, linux-kernel

On Fri, 22 May 2020 20:56:35 -0500
Jeff LaBundy <jeff@labundy.com> wrote:

> Hi Alexandru,
> 
> On Fri, May 22, 2020 at 09:54:42AM +0300, Alexandru Ardelean wrote:
> > We may want to get rid of the iio_priv_to_dev() helper. That's a bit
> > uncertain at this point. The reason is that we will hide some of the
> > members of the iio_dev structure (to prevent drivers from accessing them
> > directly), and that will also mean hiding the implementation of the
> > iio_priv_to_dev() helper inside the IIO core.
> > 
> > Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
> > may not be fast anymore, so a general idea is to try to get rid of the
> > iio_priv_to_dev() altogether.
> > 
> > For this driver, removing iio_priv_to_dev() means keeping a reference
> > on the state struct.
> > 
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
> > ---
> >  drivers/iio/light/iqs621-als.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)  
> 
> As with the iqs624 patch:
> 
> Acked-by: Jeff LaBundy <jeff@labundy.com>

Applied. thanks,

J
> 
> > 
> > diff --git a/drivers/iio/light/iqs621-als.c b/drivers/iio/light/iqs621-als.c
> > index b2988a782bd0..1a056e2446ab 100644
> > --- a/drivers/iio/light/iqs621-als.c
> > +++ b/drivers/iio/light/iqs621-als.c
> > @@ -36,6 +36,7 @@
> >  
> >  struct iqs621_als_private {
> >  	struct iqs62x_core *iqs62x;
> > +	struct iio_dev *indio_dev;
> >  	struct notifier_block notifier;
> >  	struct mutex lock;
> >  	bool light_en;
> > @@ -103,7 +104,7 @@ static int iqs621_als_notifier(struct notifier_block *notifier,
> >  
> >  	iqs621_als = container_of(notifier, struct iqs621_als_private,
> >  				  notifier);
> > -	indio_dev = iio_priv_to_dev(iqs621_als);
> > +	indio_dev = iqs621_als->indio_dev;
> >  	timestamp = iio_get_time_ns(indio_dev);
> >  
> >  	mutex_lock(&iqs621_als->lock);
> > @@ -191,7 +192,7 @@ static int iqs621_als_notifier(struct notifier_block *notifier,
> >  static void iqs621_als_notifier_unregister(void *context)
> >  {
> >  	struct iqs621_als_private *iqs621_als = context;
> > -	struct iio_dev *indio_dev = iio_priv_to_dev(iqs621_als);
> > +	struct iio_dev *indio_dev = iqs621_als->indio_dev;
> >  	int ret;
> >  
> >  	ret = blocking_notifier_chain_unregister(&iqs621_als->iqs62x->nh,
> > @@ -551,6 +552,7 @@ static int iqs621_als_probe(struct platform_device *pdev)
> >  
> >  	iqs621_als = iio_priv(indio_dev);
> >  	iqs621_als->iqs62x = iqs62x;
> > +	iqs621_als->indio_dev = indio_dev;
> >  
> >  	if (iqs62x->dev_desc->prod_num == IQS622_PROD_NUM) {
> >  		ret = regmap_read(iqs62x->regmap, IQS622_IR_THRESH_TOUCH,
> > -- 
> > 2.25.1
> >   
> 
> Kind regards,
> Jeff LaBundy


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

end of thread, other threads:[~2020-05-24 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22  6:54 [PATCH] iio: light: iqs621: remove usage of iio_priv_to_dev() Alexandru Ardelean
2020-05-23  1:56 ` Jeff LaBundy
2020-05-24 14:40   ` 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).