iio:gyro: introduce st_gyro_get_settings() function
authorDenis Ciocca <denis.ciocca@st.com>
Thu, 18 Jul 2019 22:53:45 +0000 (15:53 -0700)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 27 Jul 2019 21:52:05 +0000 (22:52 +0100)
The function is introduced to retrieve gyro 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/gyro/st_gyro.h
drivers/iio/gyro/st_gyro_core.c

index 460d190be4a4e9393ab3ae83e818d43455abc3be..592f6b34e987eecc827e53de64ed7dc79e550b6c 100644 (file)
@@ -32,6 +32,7 @@ static const struct st_sensors_platform_data gyro_pdata = {
        .drdy_int_pin = 2,
 };
 
+const struct st_sensor_settings *st_gyro_get_settings(const char *name);
 int st_gyro_common_probe(struct iio_dev *indio_dev);
 void st_gyro_common_remove(struct iio_dev *indio_dev);
 
index e995dc77e30eefbb4f6759b91079a5c76bc49a35..5cc63d41d8553d107a014d8d9201e7bf9bd863d7 100644 (file)
@@ -368,6 +368,24 @@ static const struct iio_trigger_ops st_gyro_trigger_ops = {
 #define ST_GYRO_TRIGGER_OPS NULL
 #endif
 
+/*
+ * st_gyro_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_gyro_get_settings(const char *name)
+{
+       int index = st_sensors_get_settings_index(name,
+                                       st_gyro_sensors_settings,
+                                       ARRAY_SIZE(st_gyro_sensors_settings));
+       if (index < 0)
+               return NULL;
+
+       return &st_gyro_sensors_settings[index];
+}
+EXPORT_SYMBOL(st_gyro_get_settings);
+
 int st_gyro_common_probe(struct iio_dev *indio_dev)
 {
        struct st_sensor_data *gdata = iio_priv(indio_dev);