iio:accel: introduce st_accel_get_settings() function
authorDenis Ciocca <denis.ciocca@st.com>
Thu, 18 Jul 2019 22:53:44 +0000 (15:53 -0700)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 27 Jul 2019 21:52:04 +0000 (22:52 +0100)
The function is introduced to retrieve accel device settings. It will be
used by probe in order to configure regmap.

Signed-off-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/st_accel.h
drivers/iio/accel/st_accel_core.c

index 979ab9679b996439ec8280fe06a7e85ebc5ebc83..af09943f38c9b39d38846c003989fe5111c62ccb 100644 (file)
@@ -68,6 +68,7 @@ static const struct st_sensors_platform_data default_accel_pdata = {
        .drdy_int_pin = 1,
 };
 
+const struct st_sensor_settings *st_accel_get_settings(const char *name);
 int st_accel_common_probe(struct iio_dev *indio_dev);
 void st_accel_common_remove(struct iio_dev *indio_dev);
 
index e02b799319790a682fe6d58fc0fcd38d0f365bbe..6fc490ffef7ed5e7333059ca59044173a0ede3df 100644 (file)
@@ -1147,6 +1147,24 @@ out:
 #endif
 }
 
+/*
+ * st_accel_get_settings() - get sensor settings from device name
+ * @name: device name buffer reference.
+ *
+ * Return: valid reference on success, NULL otherwise.
+ */
+const struct st_sensor_settings *st_accel_get_settings(const char *name)
+{
+       int index = st_sensors_get_settings_index(name,
+                                       st_accel_sensors_settings,
+                                       ARRAY_SIZE(st_accel_sensors_settings));
+       if (index < 0)
+               return NULL;
+
+       return &st_accel_sensors_settings[index];
+}
+EXPORT_SYMBOL(st_accel_get_settings);
+
 int st_accel_common_probe(struct iio_dev *indio_dev)
 {
        struct st_sensor_data *adata = iio_priv(indio_dev);