All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cosmin Tanislav <demonsingur@gmail.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"Rob Herring" <robh+dt@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Cosmin Tanislav" <cosmin.tanislav@analog.com>
Subject: Re: [PATCH 3/3] iio: temperature: ltc2983: support more parts
Date: Mon, 17 Oct 2022 09:59:27 +0300	[thread overview]
Message-ID: <007bd4e6-62ce-5c06-4912-9f782fc29742@gmail.com> (raw)
In-Reply-To: <20221014164435.000016a1@huawei.com>



On 10/14/22 18:44, Jonathan Cameron wrote:
> On Fri, 14 Oct 2022 15:37:24 +0300
> Cosmin Tanislav <demonsingur@gmail.com> wrote:
> 
>> From: Cosmin Tanislav <cosmin.tanislav@analog.com>
>>
>> Add support for the following parts:
>>   * LTC2984
>>   * LTC2986
>>   * LTM2985
>>
>> The LTC2984 is a variant of the LTC2983 with EEPROM.
>> The LTC2986 is a variant of the LTC2983 with only 10 channels,
>> EEPROM and support for active analog temperature sensors.
>> The LTM2985 is software-compatible with the LTC2986.
>>
>> Signed-off-by: Cosmin Tanislav <cosmin.tanislav@analog.com>
> 
> ...
> 
> Hi Cosmin,
> 
> Looks good except, I think we are still in the position that
> regmap for spi doesn't guarantee to bounce buffer the bulk accesses
> (last time I checked it actually did do so, but before that it didn't
> and there are obvious optimizations to take it back to not doing so -
> IRC Mark Brown's answer was we shouldn't rely on it..)
> 
> Anyhow, the existing driver has instances of this so its no worse
> but we should really clean those up.
> 
> Jonathan
> 

I can submit another patch for it. Although I'm pretty sure that
SPI regmap implementation doesn't need DMA safe access for it,
as I checked when I wrote the code.

> 
>>   
>> +static int ltc2983_eeprom_cmd(struct ltc2983_data *st, unsigned int cmd,
>> +			      unsigned int wait_time, unsigned int status_reg,
>> +			      unsigned long status_fail_mask)
>> +{
>> +	__be32 bval = cpu_to_be32(LTC2983_EEPROM_KEY);
>> +	unsigned long time;
>> +	unsigned int val;
>> +	int ret;
>> +
>> +	ret = regmap_bulk_write(st->regmap, LTC2983_EEPROM_KEY_REG, &bval,
>> +				sizeof(bval));
> 
> SPI device and I was clearly dozing on existing driver but normally
> we avoid assuming that regmap will always use a bounce buffer for bulk
> accessors. Hence this should be a DMA safe buffer.
> 
> 
>> +	if (ret)
>> +		return ret;
>> +
>> +	reinit_completion(&st->completion);
>> +
>> +	ret = regmap_write(st->regmap, LTC2983_STATUS_REG,
>> +			   LTC2983_STATUS_START(true) | cmd);
>> +	if (ret)
>> +		return ret;
>> +
>> +	time = wait_for_completion_timeout(&st->completion,
>> +					   msecs_to_jiffies(wait_time));
>> +	if (!time) {
>> +		dev_err(&st->spi->dev, "EEPROM command timed out\n");
>> +		return -ETIMEDOUT;
>> +	}
>> +
>> +	ret = regmap_read(st->regmap, status_reg, &val);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (val & status_fail_mask) {
>> +		dev_err(&st->spi->dev, "EEPROM command failed: 0x%02X\n", val);
>> +		return -EINVAL;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
> 

  reply	other threads:[~2022-10-17  6:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 12:37 [PATCH 0/3] Support more parts in LTC2983 Cosmin Tanislav
2022-10-14 12:37 ` [PATCH 1/3] iio: temperature: ltc2983: allocate iio channels once Cosmin Tanislav
2022-10-14 14:11   ` Jonathan Cameron
2022-10-14 15:18     ` Jonathan Cameron
2022-10-15 16:35       ` Jonathan Cameron
2022-10-14 12:37 ` [PATCH 2/3] dt-bindings: iio: temperature: ltc2983: support more parts Cosmin Tanislav
2022-10-14 15:37   ` Jonathan Cameron
2022-10-17  7:01     ` Cosmin Tanislav
2022-10-17 10:22       ` Jonathan Cameron
2022-10-17  1:59   ` Krzysztof Kozlowski
2022-10-17  6:53     ` Cosmin Tanislav
2022-10-17 10:26       ` Jonathan Cameron
2022-10-17 10:37         ` Jonathan Cameron
2022-10-17 23:26       ` Krzysztof Kozlowski
2022-10-17  9:38     ` Nuno Sá
2022-10-17 10:04       ` Nuno Sá
2022-10-17 23:32       ` Krzysztof Kozlowski
2022-10-18  6:01         ` Nuno Sá
2022-10-14 12:37 ` [PATCH 3/3] " Cosmin Tanislav
2022-10-14 15:44   ` Jonathan Cameron
2022-10-17  6:59     ` Cosmin Tanislav [this message]
2022-10-17 10:29       ` Jonathan Cameron

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=007bd4e6-62ce-5c06-4912-9f782fc29742@gmail.com \
    --to=demonsingur@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=cosmin.tanislav@analog.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=robh+dt@kernel.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.