diff mbox series

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

Message ID 20181220065933.25964-1-drake@endlessm.com (mailing list archive)
State New, archived
Headers show
Series [1/2] iio: drop const typing from iio_mount_matrix rotation | expand

Commit Message

Daniel Drake Dec. 20, 2018, 6:59 a.m. UTC
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>
---
 include/linux/iio/iio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jonathan Cameron Jan. 19, 2019, 4:49 p.m. UTC | #1
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,
Daniel Drake Jan. 21, 2019, 8:42 a.m. UTC | #2
On Sun, Jan 20, 2019 at 12:49 AM Jonathan Cameron <jic23@kernel.org> wrote:
> 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?

Hmm, I definitely had a need for it, but I can't reproduce any
compiler errors without it now, as you say.

I think I changed approach somewhere along the way, and this patch is
no longer necessary.

Thanks
Daniel
diff mbox series

Patch

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,