diff mbox series

[v2,05/11] iio:pressure: introduce st_press_get_settings() function

Message ID 20190718225353.2078-6-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 press 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:pressure:introduce st_press_multiread_bit() function"

 drivers/iio/pressure/st_pressure.h      |  1 +
 drivers/iio/pressure/st_pressure_core.c | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

Comments

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

> The function is introduced to retrieve press 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:pressure:introduce st_press_multiread_bit() function"
> 
>  drivers/iio/pressure/st_pressure.h      |  1 +
>  drivers/iio/pressure/st_pressure_core.c | 18 ++++++++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
> index 6a720cfb5686..c2e47a6c3118 100644
> --- a/drivers/iio/pressure/st_pressure.h
> +++ b/drivers/iio/pressure/st_pressure.h
> @@ -41,6 +41,7 @@ static const struct st_sensors_platform_data default_press_pdata = {
>  	.drdy_int_pin = 1,
>  };
>  
> +const struct st_sensor_settings *st_press_get_settings(const char *name);
>  int st_press_common_probe(struct iio_dev *indio_dev);
>  void st_press_common_remove(struct iio_dev *indio_dev);
>  
> diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
> index b960e76f7dfd..35d80ff27464 100644
> --- a/drivers/iio/pressure/st_pressure_core.c
> +++ b/drivers/iio/pressure/st_pressure_core.c
> @@ -664,6 +664,24 @@ static const struct iio_trigger_ops st_press_trigger_ops = {
>  #define ST_PRESS_TRIGGER_OPS NULL
>  #endif
>  
> +/*
> + * st_press_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_press_get_settings(const char *name)
> +{
> +	int index = st_sensors_get_settings_index(name,
> +					st_press_sensors_settings,
> +					ARRAY_SIZE(st_press_sensors_settings));
> +	if (index < 0)
> +		return NULL;
> +
> +	return &st_press_sensors_settings[index];
> +}
> +EXPORT_SYMBOL(st_press_get_settings);
> +
>  int st_press_common_probe(struct iio_dev *indio_dev)
>  {
>  	struct st_sensor_data *press_data = iio_priv(indio_dev);
diff mbox series

Patch

diff --git a/drivers/iio/pressure/st_pressure.h b/drivers/iio/pressure/st_pressure.h
index 6a720cfb5686..c2e47a6c3118 100644
--- a/drivers/iio/pressure/st_pressure.h
+++ b/drivers/iio/pressure/st_pressure.h
@@ -41,6 +41,7 @@  static const struct st_sensors_platform_data default_press_pdata = {
 	.drdy_int_pin = 1,
 };
 
+const struct st_sensor_settings *st_press_get_settings(const char *name);
 int st_press_common_probe(struct iio_dev *indio_dev);
 void st_press_common_remove(struct iio_dev *indio_dev);
 
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index b960e76f7dfd..35d80ff27464 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -664,6 +664,24 @@  static const struct iio_trigger_ops st_press_trigger_ops = {
 #define ST_PRESS_TRIGGER_OPS NULL
 #endif
 
+/*
+ * st_press_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_press_get_settings(const char *name)
+{
+	int index = st_sensors_get_settings_index(name,
+					st_press_sensors_settings,
+					ARRAY_SIZE(st_press_sensors_settings));
+	if (index < 0)
+		return NULL;
+
+	return &st_press_sensors_settings[index];
+}
+EXPORT_SYMBOL(st_press_get_settings);
+
 int st_press_common_probe(struct iio_dev *indio_dev)
 {
 	struct st_sensor_data *press_data = iio_priv(indio_dev);