aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Ciocca <denis.ciocca@st.com>2019-07-18 18:53:45 -0400
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-07-27 17:52:05 -0400
commit2acca26bba3a7487e941e234e8ee33a998eecf53 (patch)
treece033ea50f9ce30b7f246d292dadf560a1eeb2c3
parent823a7adac4f1bde2828d18f3bd8fa75285d00f4d (diff)
iio:gyro: introduce st_gyro_get_settings() function
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>
-rw-r--r--drivers/iio/gyro/st_gyro.h1
-rw-r--r--drivers/iio/gyro/st_gyro_core.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/iio/gyro/st_gyro.h b/drivers/iio/gyro/st_gyro.h
index 460d190be4a4..592f6b34e987 100644
--- a/drivers/iio/gyro/st_gyro.h
+++ b/drivers/iio/gyro/st_gyro.h
@@ -32,6 +32,7 @@ static const struct st_sensors_platform_data gyro_pdata = {
32 .drdy_int_pin = 2, 32 .drdy_int_pin = 2,
33}; 33};
34 34
35const struct st_sensor_settings *st_gyro_get_settings(const char *name);
35int st_gyro_common_probe(struct iio_dev *indio_dev); 36int st_gyro_common_probe(struct iio_dev *indio_dev);
36void st_gyro_common_remove(struct iio_dev *indio_dev); 37void st_gyro_common_remove(struct iio_dev *indio_dev);
37 38
diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c
index e995dc77e30e..5cc63d41d855 100644
--- a/drivers/iio/gyro/st_gyro_core.c
+++ b/drivers/iio/gyro/st_gyro_core.c
@@ -368,6 +368,24 @@ static const struct iio_trigger_ops st_gyro_trigger_ops = {
368#define ST_GYRO_TRIGGER_OPS NULL 368#define ST_GYRO_TRIGGER_OPS NULL
369#endif 369#endif
370 370
371/*
372 * st_gyro_get_settings() - get sensor settings from device name
373 * @name: device name buffer reference.
374 *
375 * Return: valid reference on success, NULL otherwise.
376 */
377const struct st_sensor_settings *st_gyro_get_settings(const char *name)
378{
379 int index = st_sensors_get_settings_index(name,
380 st_gyro_sensors_settings,
381 ARRAY_SIZE(st_gyro_sensors_settings));
382 if (index < 0)
383 return NULL;
384
385 return &st_gyro_sensors_settings[index];
386}
387EXPORT_SYMBOL(st_gyro_get_settings);
388
371int st_gyro_common_probe(struct iio_dev *indio_dev) 389int st_gyro_common_probe(struct iio_dev *indio_dev)
372{ 390{
373 struct st_sensor_data *gdata = iio_priv(indio_dev); 391 struct st_sensor_data *gdata = iio_priv(indio_dev);