Re: [PATCH 5/5] iio: gyro: st_gyro_spi: add OF capability to st_gyro_spi

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 20 Jun 2017 21:52:12 +0200
Lorenzo Bianconi <lorenzo.bianconi83@xxxxxxxxx> wrote:

> Add device tree support for L3GD20H gyroscope sensor
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@xxxxxx>
> ---
>  drivers/iio/gyro/st_gyro_spi.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/iio/gyro/st_gyro_spi.c b/drivers/iio/gyro/st_gyro_spi.c
> index fa14d8f2170d..e49dd2c923ab 100644
> --- a/drivers/iio/gyro/st_gyro_spi.c
> +++ b/drivers/iio/gyro/st_gyro_spi.c
> @@ -18,6 +18,19 @@
>  #include <linux/iio/common/st_sensors_spi.h>
>  #include "st_gyro.h"
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id st_gyro_of_match[] = {
> +	{
> +		.compatible = "st,l3gd20h-gyro",
Firstly, I think we need to drop the -gyro from any that
aren't effectively multiple chips in the same package.

Secondly why are we adding only a compatible for one of
the supported parts?  They should all be here I think...
> +		.data = L3GD20H_GYRO_DEV_NAME,
> +	},
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, st_gyro_of_match);
> +#else
> +#define st_gyro_of_match	NULL
> +#endif
> +
>  static int st_gyro_spi_probe(struct spi_device *spi)
>  {
>  	struct iio_dev *indio_dev;
> @@ -30,6 +43,8 @@ static int st_gyro_spi_probe(struct spi_device *spi)
>  
>  	gdata = iio_priv(indio_dev);
>  
> +	st_sensors_of_name_probe(&spi->dev, st_gyro_of_match,
> +				 spi->modalias, sizeof(spi->modalias));
>  	st_sensors_spi_configure(indio_dev, spi, gdata);
>  
>  	err = st_gyro_common_probe(indio_dev);
> @@ -63,6 +78,7 @@ MODULE_DEVICE_TABLE(spi, st_gyro_id_table);
>  static struct spi_driver st_gyro_driver = {
>  	.driver = {
>  		.name = "st-gyro-spi",
> +		.of_match_table = of_match_ptr(st_gyro_of_match),
>  	},
>  	.probe = st_gyro_spi_probe,
>  	.remove = st_gyro_spi_remove,

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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux