x86/speculation/mds: Fix documentation typo
[linux/fpc-iii.git] / drivers / iio / pressure / st_pressure_spi.c
blobf5ebd36bb4bf9cabfe0320175056e866e54b7dc4
1 /*
2 * STMicroelectronics pressures driver
4 * Copyright 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_pressure.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>-press to maintain
25 * compatibility
27 static const struct of_device_id st_press_of_match[] = {
29 .compatible = "st,lps001wp-press",
30 .data = LPS001WP_PRESS_DEV_NAME,
33 .compatible = "st,lps25h-press",
34 .data = LPS25H_PRESS_DEV_NAME,
37 .compatible = "st,lps331ap-press",
38 .data = LPS331AP_PRESS_DEV_NAME,
41 .compatible = "st,lps22hb-press",
42 .data = LPS22HB_PRESS_DEV_NAME,
44 {},
46 MODULE_DEVICE_TABLE(of, st_press_of_match);
47 #else
48 #define st_press_of_match NULL
49 #endif
51 static int st_press_spi_probe(struct spi_device *spi)
53 struct iio_dev *indio_dev;
54 struct st_sensor_data *press_data;
55 int err;
57 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*press_data));
58 if (indio_dev == NULL)
59 return -ENOMEM;
61 press_data = iio_priv(indio_dev);
63 st_sensors_of_name_probe(&spi->dev, st_press_of_match,
64 spi->modalias, sizeof(spi->modalias));
65 st_sensors_spi_configure(indio_dev, spi, press_data);
67 err = st_press_common_probe(indio_dev);
68 if (err < 0)
69 return err;
71 return 0;
74 static int st_press_spi_remove(struct spi_device *spi)
76 st_press_common_remove(spi_get_drvdata(spi));
78 return 0;
81 static const struct spi_device_id st_press_id_table[] = {
82 { LPS001WP_PRESS_DEV_NAME },
83 { LPS25H_PRESS_DEV_NAME },
84 { LPS331AP_PRESS_DEV_NAME },
85 { LPS22HB_PRESS_DEV_NAME },
86 {},
88 MODULE_DEVICE_TABLE(spi, st_press_id_table);
90 static struct spi_driver st_press_driver = {
91 .driver = {
92 .name = "st-press-spi",
93 .of_match_table = of_match_ptr(st_press_of_match),
95 .probe = st_press_spi_probe,
96 .remove = st_press_spi_remove,
97 .id_table = st_press_id_table,
99 module_spi_driver(st_press_driver);
101 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
102 MODULE_DESCRIPTION("STMicroelectronics pressures spi driver");
103 MODULE_LICENSE("GPL v2");