Re: [PATCH 1/3] iio: imu: bmi270: move private struct declaration to source file
From: Alex Lanzano
Date: Sat Feb 22 2025 - 11:25:33 EST
On Wed, Feb 19, 2025 at 08:54:45PM -0300, Gustavo Silva wrote:
> The device's private data struct is currently declared in the header
> file, but it does not need to be exposed there. Move it to the driver's
> core source file to avoid unnecessary #include directives or forward
> declarations in the header.
>
> Signed-off-by: Gustavo Silva <gustavograzs@xxxxxxxxx>
Acked-by: Alex Lanzano <lanzano.alex@xxxxxxxxx>
> ---
> drivers/iio/imu/bmi270/bmi270.h | 17 +----------------
> drivers/iio/imu/bmi270/bmi270_core.c | 15 +++++++++++++++
> 2 files changed, 16 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iio/imu/bmi270/bmi270.h b/drivers/iio/imu/bmi270/bmi270.h
> index fdfad5784cc52043475b6816286619fac5824684..d94525f6aee85f21cc9e9ae1bc9c1db0dc00b927 100644
> --- a/drivers/iio/imu/bmi270/bmi270.h
> +++ b/drivers/iio/imu/bmi270/bmi270.h
> @@ -6,22 +6,6 @@
> #include <linux/regmap.h>
> #include <linux/iio/iio.h>
>
> -struct device;
> -struct bmi270_data {
> - struct device *dev;
> - struct regmap *regmap;
> - const struct bmi270_chip_info *chip_info;
> -
> - /*
> - * Where IIO_DMA_MINALIGN may be larger than 8 bytes, align to
> - * that to ensure a DMA safe buffer.
> - */
> - struct {
> - __le16 channels[6];
> - aligned_s64 timestamp;
> - } data __aligned(IIO_DMA_MINALIGN);
> -};
> -
> struct bmi270_chip_info {
> const char *name;
> int chip_id;
> @@ -32,6 +16,7 @@ extern const struct regmap_config bmi270_regmap_config;
> extern const struct bmi270_chip_info bmi260_chip_info;
> extern const struct bmi270_chip_info bmi270_chip_info;
>
> +struct device;
> int bmi270_core_probe(struct device *dev, struct regmap *regmap,
> const struct bmi270_chip_info *chip_info);
>
> diff --git a/drivers/iio/imu/bmi270/bmi270_core.c b/drivers/iio/imu/bmi270/bmi270_core.c
> index 464dcdd657c4ba27fdb7620c80e9f05e2a831910..9f24d4044ed6f00f67fd3a8f5adda821c3140a18 100644
> --- a/drivers/iio/imu/bmi270/bmi270_core.c
> +++ b/drivers/iio/imu/bmi270/bmi270_core.c
> @@ -78,6 +78,21 @@
> #define BMI260_INIT_DATA_FILE "bmi260-init-data.fw"
> #define BMI270_INIT_DATA_FILE "bmi270-init-data.fw"
>
> +struct bmi270_data {
> + struct device *dev;
> + struct regmap *regmap;
> + const struct bmi270_chip_info *chip_info;
> +
> + /*
> + * Where IIO_DMA_MINALIGN may be larger than 8 bytes, align to
> + * that to ensure a DMA safe buffer.
> + */
> + struct {
> + __le16 channels[6];
> + aligned_s64 timestamp;
> + } data __aligned(IIO_DMA_MINALIGN);
> +};
> +
> enum bmi270_scan {
> BMI270_SCAN_ACCEL_X,
> BMI270_SCAN_ACCEL_Y,
>
> --
> 2.48.1
>