Re: [PATCH] iio: declare struct to fix warning

From: Lars-Peter Clausen
Date: Sun Aug 02 2015 - 05:47:49 EST


On 07/30/2015 11:18 AM, Pengyu Ma wrote:
> When compile iio related driver the following warning shown:
>
> include/linux/iio/trigger.h:35:34: warning: 'struct iio_trigger'
> declared inside parameter list
> int (*set_trigger_state)(struct iio_trigger *trig, bool state);
>
> include/linux/iio/trigger.h:38:18: warning: 'struct iio_dev'
> declared inside parameter list
> struct iio_dev *indio_dev);
>
> 1st warning: 'struct iio_trigger' was used before declaration;
> 2nd warning: 'struct iio_dev' was used without including head file.
>
> Signed-off-by: Pengyu Ma <pengyu.ma@xxxxxxxxxxxxx>
> ---
> include/linux/iio/trigger.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
> index 68f46cd..cbe4286 100644
> --- a/include/linux/iio/trigger.h
> +++ b/include/linux/iio/trigger.h
> @@ -9,6 +9,7 @@
> #include <linux/irq.h>
> #include <linux/module.h>
> #include <linux/atomic.h>
> +#include <linux/iio/iio.h>
>

Instead of including iio.h just add a forward declaration for struct
iio_dev. We dont need to dereference the struct so that will be fine.

> #ifndef _IIO_TRIGGER_H_
> #define _IIO_TRIGGER_H_
> @@ -18,6 +19,8 @@ struct iio_subirq {
> bool enabled;
> };
>
> +struct iio_trigger; /* forward declaration */
> +
> /**
> * struct iio_trigger_ops - operations structure for an iio_trigger.
> * @owner: used to monitor usage count of the trigger.
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/