[PATCH] iio: imu: lsm6dsx: Use i3cdev_to_dev to get device pointer

Guenter Roeck posted 1 patch 2 weeks ago
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] iio: imu: lsm6dsx: Use i3cdev_to_dev to get device pointer
Posted by Guenter Roeck 2 weeks ago
I3C client drivers should not include linux/i3c/master.h. Use
i3cdev_to_dev() to get the device pointer from struct i3c_device
to be able to avoid that include.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
index 3b0c8b19c448..207dcc0ad988 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
@@ -9,7 +9,6 @@
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/i3c/device.h>
-#include <linux/i3c/master.h>
 #include <linux/slab.h>
 #include <linux/regmap.h>
 
@@ -30,15 +29,16 @@ static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
 	};
 	const struct i3c_device_id *id = i3c_device_match_id(i3cdev,
 							    st_lsm6dsx_i3c_ids);
+	struct device *dev = i3cdev_to_dev(i3cdev);
 	struct regmap *regmap;
 
 	regmap = devm_regmap_init_i3c(i3cdev, &st_lsm6dsx_i3c_regmap_config);
 	if (IS_ERR(regmap)) {
-		dev_err(&i3cdev->dev, "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));
+		dev_err(dev, "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));
 		return PTR_ERR(regmap);
 	}
 
-	return st_lsm6dsx_probe(&i3cdev->dev, 0, (uintptr_t)id->data, regmap);
+	return st_lsm6dsx_probe(dev, 0, (uintptr_t)id->data, regmap);
 }
 
 static struct i3c_driver st_lsm6dsx_driver = {
-- 
2.45.2
Re: [PATCH] iio: imu: lsm6dsx: Use i3cdev_to_dev to get device pointer
Posted by Jonathan Cameron 2 weeks ago
On Sat,  9 Nov 2024 06:54:30 -0800
Guenter Roeck <linux@roeck-us.net> wrote:

> I3C client drivers should not include linux/i3c/master.h. Use
> i3cdev_to_dev() to get the device pointer from struct i3c_device
> to be able to avoid that include.
> 
> Suggested-by: Jonathan Cameron <jic23@kernel.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Applied to the testing branch of iio.git. I'll be rebasing that
on 6.13-rc1 once available and then push out as togreg for linux-next
to pick up.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> index 3b0c8b19c448..207dcc0ad988 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> @@ -9,7 +9,6 @@
>  #include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/i3c/device.h>
> -#include <linux/i3c/master.h>
>  #include <linux/slab.h>
>  #include <linux/regmap.h>
>  
> @@ -30,15 +29,16 @@ static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
>  	};
>  	const struct i3c_device_id *id = i3c_device_match_id(i3cdev,
>  							    st_lsm6dsx_i3c_ids);
> +	struct device *dev = i3cdev_to_dev(i3cdev);
>  	struct regmap *regmap;
>  
>  	regmap = devm_regmap_init_i3c(i3cdev, &st_lsm6dsx_i3c_regmap_config);
>  	if (IS_ERR(regmap)) {
> -		dev_err(&i3cdev->dev, "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));
> +		dev_err(dev, "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));
>  		return PTR_ERR(regmap);
>  	}
>  
> -	return st_lsm6dsx_probe(&i3cdev->dev, 0, (uintptr_t)id->data, regmap);
> +	return st_lsm6dsx_probe(dev, 0, (uintptr_t)id->data, regmap);
>  }
>  
>  static struct i3c_driver st_lsm6dsx_driver = {