All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Jishnu Prakash <jprakash@codeaurora.org>
Cc: agross@kernel.org, bjorn.andersson@linaro.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	mka@chromium.org, linus.walleij@linaro.org, sboyd@codeaurora.org,
	Jonathan.Cameron@huawei.com, smohanad@codeaurora.org,
	kgunda@codeaurora.org, aghayal@codeaurora.org,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	linux-arm-msm@vger.kernel.org, linux-iio@vger.kernel.org,
	linux-arm-msm-owner@vger.kernel.org
Subject: Re: [PATCH 3/3] iio: adc: Add support for PMIC7 ADC
Date: Sat, 28 Mar 2020 17:04:07 +0000	[thread overview]
Message-ID: <20200328170407.41d8ed68@archlinux> (raw)
In-Reply-To: <1585064650-16235-4-git-send-email-jprakash@codeaurora.org>

On Tue, 24 Mar 2020 21:14:10 +0530
Jishnu Prakash <jprakash@codeaurora.org> wrote:

> The ADC architecture on PMIC7 is changed as compared to PMIC5. The
> major change from PMIC5 is that all SW communication to ADC goes through
> PMK8350, which communicates with other PMICs through PBS when the ADC
> on PMK8350 works in master mode. The SID register is used to identify the
> PMICs with which the PBS needs to communicate. Add support for the same.
> 
> In addition, add definitions for ADC channels and virtual channel
> definitions per PMIC, to be used by ADC clients for PMIC7.
> 
> Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>

A few additions from me.

> ---

...

>  
> +static int adc5_exit(struct platform_device *pdev)
> +{
> +	struct adc5_chip *adc = platform_get_drvdata(pdev);
> +
> +	mutex_destroy(&adc->lock);

Andy raised potential races.  You definitely have some as this
will destroy the mutex before you've removed the userspace interfaces.

> +	return 0;
> +}
> +
>  static struct platform_driver adc5_driver = {
>  	.driver = {
>  		.name = "qcom-spmi-adc5.c",
>  		.of_match_table = adc5_match_table,
>  	},
>  	.probe = adc5_probe,
> +	.remove = adc5_exit,
>  };
>  module_platform_driver(adc5_driver);
>  

...

>  
> +static int qcom_vadc7_scale_hw_calib_die_temp(
> +				const struct vadc_prescale_ratio *prescale,
> +				const struct adc5_data *data,
> +				u16 adc_code, int *result_mdec)
> +{
> +
> +	int voltage, vtemp0, temp, i = 0;
> +
> +	voltage = qcom_vadc_scale_code_voltage_factor(adc_code,
> +				prescale, data, 1);
> +
> +	while (i < ARRAY_SIZE(adcmap7_die_temp)) {
> +		if (adcmap7_die_temp[i].x > voltage)
> +			break;
> +		i++;
> +	}

For loop (I think Andy also raised this one).

> +
> +	if (i == 0) {
> +		*result_mdec = DIE_TEMP_ADC7_SCALE_1;
> +	} else if (i == ARRAY_SIZE(adcmap7_die_temp)) {
> +		*result_mdec = DIE_TEMP_ADC7_MAX;
> +	} else {
> +		vtemp0 = adcmap7_die_temp[i-1].x;

Spaces around the - 
Same elsewhere.

> +		voltage = voltage - vtemp0;
> +		temp = div64_s64(voltage * DIE_TEMP_ADC7_SCALE_FACTOR,
> +			adcmap7_die_temp[i-1].y);
> +		temp += DIE_TEMP_ADC7_SCALE_1 + (DIE_TEMP_ADC7_SCALE_2 * (i-1));
> +		*result_mdec = temp;
> +	}
> +
> +	return 0;
> +}
> +
>  static int qcom_vadc_scale_hw_smb_temp(
>  				const struct vadc_prescale_ratio *prescale,
>  				const struct adc5_data *data,
...


  parent reply	other threads:[~2020-03-28 17:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 15:44 [PATCH 0/3] iio: adc: Add support for QCOM SPMI PMIC7 ADC Jishnu Prakash
2020-03-24 15:44 ` [PATCH 1/3] iio: adc: Convert the QCOM SPMI ADC bindings to .yaml format Jishnu Prakash
2020-03-28 16:51   ` Jonathan Cameron
2020-04-06 11:41     ` Jishnu Prakash
2020-03-30 15:38   ` Rob Herring
2020-04-06 11:43     ` Jishnu Prakash
2020-04-03 12:04   ` Amit Kucheria
2020-04-06 11:44     ` Jishnu Prakash
2020-04-14  9:09       ` Amit Kucheria
2020-03-24 15:44 ` [PATCH 2/3] iio: adc: Add PMIC7 ADC bindings Jishnu Prakash
2020-03-28 16:54   ` Jonathan Cameron
2020-04-06 11:45     ` Jishnu Prakash
2020-04-06 16:05       ` Jonathan Cameron
2020-04-03 12:11   ` Amit Kucheria
2020-04-06 11:45     ` Jishnu Prakash
2020-03-24 15:44 ` [PATCH 3/3] iio: adc: Add support for PMIC7 ADC Jishnu Prakash
2020-03-24 16:33   ` Andy Shevchenko
2020-04-06 11:46     ` Jishnu Prakash
2020-03-28 17:04   ` Jonathan Cameron [this message]
2020-04-06 11:46     ` Jishnu Prakash
2020-03-31 20:06   ` Rob Herring
2020-04-06 11:47     ` Jishnu Prakash

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200328170407.41d8ed68@archlinux \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=aghayal@codeaurora.org \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jprakash@codeaurora.org \
    --cc=kgunda@codeaurora.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-msm-owner@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mka@chromium.org \
    --cc=pmeerw@pmeerw.net \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=smohanad@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.