Re: [PATCH v4 2/6] iio: accel: mma8452: Optimize struct mm8452_data member orders

Jonathan Cameron <[email protected]>
Newsgroups org.kernel.vger.linux-devicetree,org.kernel.vger.linux-iio,org.kernel.vger.linux-kernel
Message-ID <20260815051356.4dac350e@jic23-huawei>
On Wed, 12 Aug 2026 16:30:33 +0200
Esben Haabendal <[email protected]> wrote:

> Reorder struct mma8452_data members to avoid holes.
Trivial but sashiko pointed out mm[a]_8452 in the title.
I'll tidy that up if nothing significant comes up.

Interestingly Sashiko also thinks it found a deadlock.
Given you are working with this driver if you have time could
you take a look at that. 

https://sashiko.dev/#/patchset/20260812-mma8452-open-drain-v4-0-bfca15d02b59%40geanix.com

I'm rather surprised to see the lock taken in the runtime
pm suspend callback. It is probably there to close a race
where the device is being suspended and the sampling
frequency is being written.  I'm not immediately sure what
the best way to fix it is. One thing that would work is to
do pm_runtime_get* to raise the reference counter and stop
there being any chance of an autosuspend. 

Jonathan

> 
> Reviewed-by: Joshua Crofts <[email protected]>
> Reviewed-by: Andy Shevchenko <[email protected]>
> Signed-off-by: Esben Haabendal <[email protected]>
> ---
>  drivers/iio/accel/mma8452.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 7d683686dd9d..f645a5c6fd1c 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -106,10 +106,7 @@ struct mma8452_data {
>  	struct i2c_client *client;
>  	struct mutex lock;
>  	struct iio_mount_matrix orientation;
> -	u8 ctrl_reg1;
> -	u8 data_cfg;
>  	const struct mma_chip_info *chip_info;
> -	int sleep_val;
>  	struct regulator *vdd_reg;
>  	struct regulator *vddio_reg;
>  
> @@ -118,6 +115,10 @@ struct mma8452_data {
>  		__be16 channels[3];
>  		aligned_s64 ts;
>  	} buffer;
> +
> +	int sleep_val;
> +	u8 ctrl_reg1;
> +	u8 data_cfg;
>  };
>  
>   /**
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.