x86/speculation/mds: Fix documentation typo
[linux/fpc-iii.git] / drivers / iio / accel / st_accel_spi.c
blob915fa49085f7076b74de72e717e1a6858e504240
1 /*
2 * STMicroelectronics accelerometers driver
4 * Copyright 2012-2013 STMicroelectronics Inc.
6 * Denis Ciocca <denis.ciocca@st.com>
8 * Licensed under the GPL-2.
9 */
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/slab.h>
14 #include <linux/spi/spi.h>
15 #include <linux/iio/iio.h>
17 #include <linux/iio/common/st_sensors.h>
18 #include <linux/iio/common/st_sensors_spi.h>
19 #include "st_accel.h"
21 #ifdef CONFIG_OF
23 * For new single-chip sensors use <device_name> as compatible string.
24 * For old single-chip devices keep <device_name>-accel to maintain
25 * compatibility
27 static const struct of_device_id st_accel_of_match[] = {
29 /* An older compatible */
30 .compatible = "st,lis302dl-spi",
31 .data = LIS3LV02DL_ACCEL_DEV_NAME,
34 .compatible = "st,lis3lv02dl-accel",
35 .data = LIS3LV02DL_ACCEL_DEV_NAME,
38 .compatible = "st,lis3dh-accel",
39 .data = LIS3DH_ACCEL_DEV_NAME,
42 .compatible = "st,lsm330d-accel",
43 .data = LSM330D_ACCEL_DEV_NAME,
46 .compatible = "st,lsm330dl-accel",
47 .data = LSM330DL_ACCEL_DEV_NAME,
50 .compatible = "st,lsm330dlc-accel",
51 .data = LSM330DLC_ACCEL_DEV_NAME,
54 .compatible = "st,lis331dlh-accel",
55 .data = LIS331DLH_ACCEL_DEV_NAME,
58 .compatible = "st,lsm330-accel",
59 .data = LSM330_ACCEL_DEV_NAME,
62 .compatible = "st,lsm303agr-accel",
63 .data = LSM303AGR_ACCEL_DEV_NAME,
66 .compatible = "st,lis2dh12-accel",
67 .data = LIS2DH12_ACCEL_DEV_NAME,
70 .compatible = "st,lis3l02dq",
71 .data = LIS3L02DQ_ACCEL_DEV_NAME,
74 .compatible = "st,lng2dm-accel",
75 .data = LNG2DM_ACCEL_DEV_NAME,
78 .compatible = "st,h3lis331dl-accel",
79 .data = H3LIS331DL_ACCEL_DEV_NAME,
82 .compatible = "st,lis331dl-accel",
83 .data = LIS331DL_ACCEL_DEV_NAME,
87 MODULE_DEVICE_TABLE(of, st_accel_of_match);
88 #else
89 #define st_accel_of_match NULL
90 #endif
92 static int st_accel_spi_probe(struct spi_device *spi)
94 struct iio_dev *indio_dev;
95 struct st_sensor_data *adata;
96 int err;
98 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adata));
99 if (!indio_dev)
100 return -ENOMEM;
102 adata = iio_priv(indio_dev);
104 st_sensors_of_name_probe(&spi->dev, st_accel_of_match,
105 spi->modalias, sizeof(spi->modalias));
106 st_sensors_spi_configure(indio_dev, spi, adata);
108 err = st_accel_common_probe(indio_dev);
109 if (err < 0)
110 return err;
112 return 0;
115 static int st_accel_spi_remove(struct spi_device *spi)
117 st_accel_common_remove(spi_get_drvdata(spi));
119 return 0;
122 static const struct spi_device_id st_accel_id_table[] = {
123 { LIS3DH_ACCEL_DEV_NAME },
124 { LSM330D_ACCEL_DEV_NAME },
125 { LSM330DL_ACCEL_DEV_NAME },
126 { LSM330DLC_ACCEL_DEV_NAME },
127 { LIS331DLH_ACCEL_DEV_NAME },
128 { LSM330_ACCEL_DEV_NAME },
129 { LSM303AGR_ACCEL_DEV_NAME },
130 { LIS2DH12_ACCEL_DEV_NAME },
131 { LIS3L02DQ_ACCEL_DEV_NAME },
132 { LNG2DM_ACCEL_DEV_NAME },
133 { H3LIS331DL_ACCEL_DEV_NAME },
134 { LIS331DL_ACCEL_DEV_NAME },
135 { LIS3LV02DL_ACCEL_DEV_NAME },
138 MODULE_DEVICE_TABLE(spi, st_accel_id_table);
140 static struct spi_driver st_accel_driver = {
141 .driver = {
142 .name = "st-accel-spi",
143 .of_match_table = of_match_ptr(st_accel_of_match),
145 .probe = st_accel_spi_probe,
146 .remove = st_accel_spi_remove,
147 .id_table = st_accel_id_table,
149 module_spi_driver(st_accel_driver);
151 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
152 MODULE_DESCRIPTION("STMicroelectronics accelerometers spi driver");
153 MODULE_LICENSE("GPL v2");