mbox series

[v3,00/10] qcom: pm8150: add support for thermal monitoring

Message ID 20200909144248.54327-1-dmitry.baryshkov@linaro.org
Headers show
Series qcom: pm8150: add support for thermal monitoring | expand

Message

Dmitry Baryshkov Sept. 9, 2020, 2:42 p.m. UTC
This patch serie adds support for thermal monitoring block on Qualcomm's
PMIC5 chips. PM8150{,b,l} and sm8250-mtp board device trees are extended
to support thermal zones provided by this thermal monitoring block.
Unlike the rest of PMIC thermal senses, these thermal zones describe
particular thermistors, which differ between from board to board.

Changes since v2:
 - IIO: export of_iio_channel_get_by_name() function
 - dt-bindings: move individual io-channels to each thermal monitoring
   channel rather than listing them all in device node
 - added fallback defaults to of_device_get_match_data calls in
   qcom-spmi-adc5 and qcom-spmi-adc-tm5 drivers
 - minor typo fixes

Changes since v1:
 - Introduce fixp_linear_interpolate() by Craig Tatlor
 - Lots of syntax/whitespace changes
 - Cleaned up register definitions per Jonathan's suggestion
 - Implemented most of the suggestions from Bjorn's and Jonathan's
   review

Comments

Jonathan Cameron Sept. 9, 2020, 6:05 p.m. UTC | #1
On Wed,  9 Sep 2020 17:42:44 +0300
Dmitry Baryshkov <dmitry.baryshkov@linaro.org> wrote:

> Use of_device_get_match_data() instead of hand-coding it manually.

> 

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>


> ---

>  drivers/iio/adc/qcom-spmi-adc5.c | 18 +++++++-----------

>  1 file changed, 7 insertions(+), 11 deletions(-)

> 

> diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c

> index c2da8f068b87..ae27ed7a26ff 100644

> --- a/drivers/iio/adc/qcom-spmi-adc5.c

> +++ b/drivers/iio/adc/qcom-spmi-adc5.c

> @@ -14,6 +14,7 @@

>  #include <linux/math64.h>

>  #include <linux/module.h>

>  #include <linux/of.h>

> +#include <linux/of_device.h>

>  #include <linux/platform_device.h>

>  #include <linux/regmap.h>

>  #include <linux/slab.h>

> @@ -807,8 +808,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)

>  	struct adc5_channel_prop prop, *chan_props;

>  	struct device_node *child;

>  	unsigned int index = 0;

> -	const struct of_device_id *id;

> -	const struct adc5_data *data;

>  	int ret;

>  

>  	adc->nchannels = of_get_available_child_count(node);

> @@ -827,24 +826,21 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)

>  

>  	chan_props = adc->chan_props;

>  	iio_chan = adc->iio_chans;

> -	id = of_match_node(adc5_match_table, node);

> -	if (id)

> -		data = id->data;

> -	else

> -		data = &adc5_data_pmic;

> -	adc->data = data;

> +	adc->data = of_device_get_match_data(adc->dev);

> +	if (!adc->data)

> +		adc->data = &adc5_data_pmic;

>  

>  	for_each_available_child_of_node(node, child) {

> -		ret = adc5_get_dt_channel_data(adc, &prop, child, data);

> +		ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data);

>  		if (ret) {

>  			of_node_put(child);

>  			return ret;

>  		}

>  

>  		prop.scale_fn_type =

> -			data->adc_chans[prop.channel].scale_fn_type;

> +			adc->data->adc_chans[prop.channel].scale_fn_type;

>  		*chan_props = prop;

> -		adc_chan = &data->adc_chans[prop.channel];

> +		adc_chan = &adc->data->adc_chans[prop.channel];

>  

>  		iio_chan->channel = prop.channel;

>  		iio_chan->datasheet_name = prop.datasheet_name;