Re: [PATCH 1/2] iio: drop const typing from iio_mount_matrix rotation

Jonathan Cameron
2019-01-19T16:49:22Z

On Thu, 20 Dec 2018 14:59:32 +0800
Daniel Drake <drake@endlessm.com> wrote:

> In order to conform with orientation data from the firmware, we
> need to dynamically construct the mount matrix in the ST accelerometer
> driver.
>
> Drop the const type from the mount matrix data to make this possible.
>
> Signed-off-by: Daniel Drake <drake@endlessm.com>
Not quite that simple...

drivers/iio/industrialio-core.c:551:21: error: passing argument 3 of ‘of_property_read_string_array’ from incompatible pointer type [-Werror=incompatible-pointer-types]
propname, matrix->rotation,
~~~~~~^~~~~~~~~~
In file included from ./include/linux/iio/iio.h:16,
from drivers/iio/industrialio-core.c:29:
./include/linux/of.h:1107:42: note: expected ‘const char **’ but argument is of type ‘char **’
const char *propname, const char **out_strs,
~~~~~~~~~~~~~^~~~~~~~
cc1: some warnings being treated as errors

Also, I didn't think that much about it until now, but I'm not sure
why you need this change in the first place. It is an array of
pointers to constant characters. Given we allocate said array
before setting this variable to it and don't modify it via this
pointer, I believe we are fine with out this.

Compiler certainly isn't complaining about patch 2 without this
one. Am I missing something?

Jonathan

> ---
> include/linux/iio/iio.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index a74cb177dc6f..d3094ffeb9da 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -125,7 +125,7 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
> * main hardware
> */
> struct iio_mount_matrix {
> - const char *rotation[9];
> + char *rotation[9];
> };
>
> ssize_t iio_show_mount_matrix(struct iio_dev *indio_dev, uintptr_t priv,