module: Convert symbol namespace to string literal
[linux.git] / drivers / iio / common / st_sensors / st_sensors_i2c.c
blob7156302fe99772e98992fdb8023d77a3b460bcaa
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * STMicroelectronics sensors i2c library driver
5 * Copyright 2012-2013 STMicroelectronics Inc.
7 * Denis Ciocca <denis.ciocca@st.com>
8 */
10 #include <linux/i2c.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/iio/iio.h>
14 #include <linux/regmap.h>
16 #include <linux/iio/common/st_sensors_i2c.h>
18 #define ST_SENSORS_I2C_MULTIREAD 0x80
20 static const struct regmap_config st_sensors_i2c_regmap_config = {
21 .reg_bits = 8,
22 .val_bits = 8,
25 static const struct regmap_config st_sensors_i2c_regmap_multiread_bit_config = {
26 .reg_bits = 8,
27 .val_bits = 8,
28 .read_flag_mask = ST_SENSORS_I2C_MULTIREAD,
32 * st_sensors_i2c_configure() - configure I2C interface
33 * @indio_dev: IIO device reference.
34 * @client: i2c client reference.
36 * Return: 0 on success, else a negative error code.
38 int st_sensors_i2c_configure(struct iio_dev *indio_dev,
39 struct i2c_client *client)
41 struct st_sensor_data *sdata = iio_priv(indio_dev);
42 const struct regmap_config *config;
44 if (sdata->sensor_settings->multi_read_bit)
45 config = &st_sensors_i2c_regmap_multiread_bit_config;
46 else
47 config = &st_sensors_i2c_regmap_config;
49 sdata->regmap = devm_regmap_init_i2c(client, config);
50 if (IS_ERR(sdata->regmap)) {
51 dev_err(&client->dev, "Failed to register i2c regmap (%ld)\n",
52 PTR_ERR(sdata->regmap));
53 return PTR_ERR(sdata->regmap);
56 i2c_set_clientdata(client, indio_dev);
58 indio_dev->name = client->name;
60 sdata->irq = client->irq;
62 return 0;
64 EXPORT_SYMBOL_NS(st_sensors_i2c_configure, "IIO_ST_SENSORS");
66 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
67 MODULE_DESCRIPTION("STMicroelectronics ST-sensors i2c driver");
68 MODULE_LICENSE("GPL v2");