dm writecache: add cond_resched to loop in persistent_memory_claim()
[linux/fpc-iii.git] / drivers / iio / light / st_uvis25_spi.c
bloba9ceae4f58b3da30b575c45f248b8c8b4bc232b2
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * STMicroelectronics uvis25 spi driver
5 * Copyright 2017 STMicroelectronics Inc.
7 * Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
8 */
10 #include <linux/kernel.h>
11 #include <linux/module.h>
12 #include <linux/spi/spi.h>
13 #include <linux/slab.h>
14 #include <linux/regmap.h>
16 #include "st_uvis25.h"
18 #define UVIS25_SENSORS_SPI_READ BIT(7)
19 #define UVIS25_SPI_AUTO_INCREMENT BIT(6)
21 static const struct regmap_config st_uvis25_spi_regmap_config = {
22 .reg_bits = 8,
23 .val_bits = 8,
24 .read_flag_mask = UVIS25_SENSORS_SPI_READ | UVIS25_SPI_AUTO_INCREMENT,
25 .write_flag_mask = UVIS25_SPI_AUTO_INCREMENT,
28 static int st_uvis25_spi_probe(struct spi_device *spi)
30 struct regmap *regmap;
32 regmap = devm_regmap_init_spi(spi, &st_uvis25_spi_regmap_config);
33 if (IS_ERR(regmap)) {
34 dev_err(&spi->dev, "Failed to register spi regmap %d\n",
35 (int)PTR_ERR(regmap));
36 return PTR_ERR(regmap);
39 return st_uvis25_probe(&spi->dev, spi->irq, regmap);
42 static const struct of_device_id st_uvis25_spi_of_match[] = {
43 { .compatible = "st,uvis25", },
44 {},
46 MODULE_DEVICE_TABLE(of, st_uvis25_spi_of_match);
48 static const struct spi_device_id st_uvis25_spi_id_table[] = {
49 { ST_UVIS25_DEV_NAME },
50 {},
52 MODULE_DEVICE_TABLE(spi, st_uvis25_spi_id_table);
54 static struct spi_driver st_uvis25_driver = {
55 .driver = {
56 .name = "st_uvis25_spi",
57 .pm = &st_uvis25_pm_ops,
58 .of_match_table = of_match_ptr(st_uvis25_spi_of_match),
60 .probe = st_uvis25_spi_probe,
61 .id_table = st_uvis25_spi_id_table,
63 module_spi_driver(st_uvis25_driver);
65 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>");
66 MODULE_DESCRIPTION("STMicroelectronics uvis25 spi driver");
67 MODULE_LICENSE("GPL v2");