All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: st-sensors: Use dev_to_iio_dev() in sysfs callbacks
@ 2021-10-20  8:53 Lars-Peter Clausen
  2021-10-28 14:29 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Lars-Peter Clausen @ 2021-10-20  8:53 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Denis Ciocca, linux-iio, Lars-Peter Clausen

Using `dev_get_drvdata()` in IIO sysfs callbacks to get a pointer to the
IIO device is a relic from the very early days of IIO. The IIO core as well
as most other drivers have switched over to using `dev_to_iio_dev()`
instead.

This driver is one of the last few drivers remaining that uses the outdated
idiom, update it. This will allow to eventually update the IIO core to no
longer set the drvdata for the IIO device and free it up for driver usage.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/common/st_sensors/st_sensors_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 1de395bda03e..eb452d0c423c 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -638,7 +638,7 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	int i, len = 0;
-	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
 
 	mutex_lock(&indio_dev->mlock);
@@ -660,7 +660,7 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
 				struct device_attribute *attr, char *buf)
 {
 	int i, len = 0, q, r;
-	struct iio_dev *indio_dev = dev_get_drvdata(dev);
+	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct st_sensor_data *sdata = iio_priv(indio_dev);
 
 	mutex_lock(&indio_dev->mlock);
-- 
2.20.1


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

* Re: [PATCH] iio: st-sensors: Use dev_to_iio_dev() in sysfs callbacks
  2021-10-20  8:53 [PATCH] iio: st-sensors: Use dev_to_iio_dev() in sysfs callbacks Lars-Peter Clausen
@ 2021-10-28 14:29 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2021-10-28 14:29 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Denis Ciocca, linux-iio

On Wed, 20 Oct 2021 10:53:49 +0200
Lars-Peter Clausen <lars@metafoo.de> wrote:

> Using `dev_get_drvdata()` in IIO sysfs callbacks to get a pointer to the
> IIO device is a relic from the very early days of IIO. The IIO core as well
> as most other drivers have switched over to using `dev_to_iio_dev()`
> instead.
> 
> This driver is one of the last few drivers remaining that uses the outdated
> idiom, update it. This will allow to eventually update the IIO core to no
> longer set the drvdata for the IIO device and free it up for driver usage.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Applied to the togreg branch of iio.git and pushed out as testing to keep 0-day
burning cycles.   Plenty of time for any additional reviews as I won't be pushing
this out properly until the merge window closes and I rebase the tree.

Thanks,

Jonathan

> ---
>  drivers/iio/common/st_sensors/st_sensors_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 1de395bda03e..eb452d0c423c 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -638,7 +638,7 @@ ssize_t st_sensors_sysfs_sampling_frequency_avail(struct device *dev,
>  				struct device_attribute *attr, char *buf)
>  {
>  	int i, len = 0;
> -	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct st_sensor_data *sdata = iio_priv(indio_dev);
>  
>  	mutex_lock(&indio_dev->mlock);
> @@ -660,7 +660,7 @@ ssize_t st_sensors_sysfs_scale_avail(struct device *dev,
>  				struct device_attribute *attr, char *buf)
>  {
>  	int i, len = 0, q, r;
> -	struct iio_dev *indio_dev = dev_get_drvdata(dev);
> +	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>  	struct st_sensor_data *sdata = iio_priv(indio_dev);
>  
>  	mutex_lock(&indio_dev->mlock);


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

end of thread, other threads:[~2021-10-28 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20  8:53 [PATCH] iio: st-sensors: Use dev_to_iio_dev() in sysfs callbacks Lars-Peter Clausen
2021-10-28 14:29 ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.