diff mbox series

[v2,02/11] iio:accel: introduce st_accel_get_settings() function

Message ID 20190718225353.2078-3-denis.ciocca@st.com (mailing list archive)
State New, archived
Headers show
Series iio:st_sensors: make use of regmap API | expand

Commit Message

Denis CIOCCA July 18, 2019, 10:53 p.m. UTC
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>
---
Changes in v2:
 not there in v1. This meant to replace "iio:accel:introduce st_accel_multiread_bit() function"

 drivers/iio/accel/st_accel.h      |  1 +
 drivers/iio/accel/st_accel_core.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

Comments

Jonathan Cameron July 21, 2019, 5:48 p.m. UTC | #1
On Thu, 18 Jul 2019 15:53:44 -0700
Denis Ciocca <denis.ciocca@st.com> wrote:

> 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>
Applied, thanks,

Jonathan

> ---
> Changes in v2:
>  not there in v1. This meant to replace "iio:accel:introduce st_accel_multiread_bit() function"
> 
>  drivers/iio/accel/st_accel.h      |  1 +
>  drivers/iio/accel/st_accel_core.c | 18 ++++++++++++++++++
>  2 files changed, 19 insertions(+)
> 
> 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 @@ static int apply_acpi_orientation(struct iio_dev *indio_dev,
>  #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);
diff mbox series

Patch

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 @@  static int apply_acpi_orientation(struct iio_dev *indio_dev,
 #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);