summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Ciocca <denis.ciocca@st.com>2019-07-19 01:53:44 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-07-28 00:52:04 +0300
commit823a7adac4f1bde2828d18f3bd8fa75285d00f4d (patch)
tree25e611470e4133291b8b3e61444016902e36f2e3
parenta090965b882333500d8780e2c1762e17782f413f (diff)
downloadlinux-823a7adac4f1bde2828d18f3bd8fa75285d00f4d.tar.xz
iio:accel: introduce st_accel_get_settings() function
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>
-rw-r--r--drivers/iio/accel/st_accel.h1
-rw-r--r--drivers/iio/accel/st_accel_core.c18
2 files changed, 19 insertions, 0 deletions
diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 979ab9679b99..af09943f38c9 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -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);
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index e02b79931979..6fc490ffef7e 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -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);