public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: jic23@kernel.org, lars@metafoo.de, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, matthias.bgg@gmail.com,
	lee@kernel.org, andy@kernel.org, nuno.sa@analog.com,
	bigunclemax@gmail.com, dlechner@baylibre.com,
	marius.cristea@microchip.com, marcelo.schmitt@analog.com,
	fr0st61te@gmail.com, mitrutzceclan@gmail.com,
	mike.looijmans@topic.nl, marcus.folkesson@gmail.com,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, kernel@collabora.com
Subject: Re: [PATCH v1 2/4] iio: adc: Add support for MediaTek MT6357/8/9 Auxiliary ADC
Date: Tue, 4 Jun 2024 13:56:15 +0200	[thread overview]
Message-ID: <3e741571-9086-4f26-a158-d86a4cdcc349@collabora.com> (raw)
In-Reply-To: <CAHp75VcwnjrsAY1qF68MpBWV-NLFSxTP_PDL+ER==KNdBAFFTA@mail.gmail.com>

Il 04/06/24 13:05, Andy Shevchenko ha scritto:
> On Tue, Jun 4, 2024 at 1:38 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com> wrote:
>> Il 30/05/24 15:34, Andy Shevchenko ha scritto:
>>> On Thu, May 30, 2024 at 12:34 PM AngeloGioacchino Del Regno
>>> <angelogioacchino.delregno@collabora.com> wrote:
> 
> ...
> 
>>>> +#define PMIC_RG_RESET_VAL              (BIT(0) | BIT(3))
>>>
>>> In this form it requires a comment explaining each mentioned bit.
>>
>> I don't have an explanation for this, I know it's two different bits from some
>> reveng, but the downstream driver declares that simply as 0x9.
>>
>> Should I just "mask" this as 0x9 instead?
> 
> In this case for all of the questionable forms, please add a oneline
> comment suggesting that "these are different bits without known
> purpose of each." or something like that.
> 

Perfect. Comment added.

> ...
> 
>>>> +#define MT6358_IMP0_CLEAR              (BIT(14) | BIT(7))
>>>
>>> As per above.
>>>
>>
>> Same, I don't have any explanation for that.
>>
>> If you prefer, I can define this as 0x4080, but honestly I prefer keeping
>> it as-is since I am sure it's not a magic number but really two bits to flip
>> in a register.
> 
> As per above.
> 
> ...
> 
>>>> +       u8 r_numerator;
>>>> +       u8 r_denominator;
>>>
>>> Can you add struct u8_fract to the math.h and use it? I will Ack/R the
>>> respective patch.
>>
>> Yeah, I did that exactly because u8_fract wasn't there and I didn't want
>> to waste more bits, but since you just asked for it... well, I'm happier :-)
> 
> Note, it's enough to have my Rb tag and route that change via IIO
> tree. We have done similar way for other changes in math.h (or aline)
> in the past.
> 

Sure.

> ...
> 
>>>> +       /* Assert ADC reset */
>>>> +       regmap_set_bits(regmap, pdata->regs[PMIC_HK_TOP_RST_CON0], PMIC_RG_RESET_VAL);
>>>
>>> No required delay in between?
>>
>> No, as strange as it may look, there is no delay required in between: this is
>> because the register R/W is behind the PMIC Wrapper as much as all of the other
>> MediaTek PMIC (sub)devices, so, missing delays was intentional here, yes.
> 
> Maybe a comment?
> 

Done :-)

/* De-assert ADC reset. No wait required, as pwrap takes care of that for us. */

> ...
> 
>>>> +       mutex_lock(&adc_dev->lock);
>>>
>>> Why not use cleanup.h?
>>
>> I want to unlock the mutex immediately right after executing read_imp() or
>> mt6359_auxadc_read_adc(), and I don't want the reset to be done while a mutex
>> is being held, as that makes no sense for this driver.
> 
> That's why we have scoped_guard(). Exactly for such cases.
> 

Thanks for the hint, looking at other usages that was straightforward.

>> Besides, I find the macros in cleanup.h to be cryptic - in my opinion, they
>> require better documentation as, for example, I don't understand when the
>> guard(mutex)(my_mutex) is supposed to acquire the lock and when it's supposed
>> to release it.
> 
> They are cryptic due to limitations in C language. But for the end
> user it doesn't matter. The behaviour is well understandable and makes
> code cleaner and less prone for errors such as missing unlocks. So,
> please use cleanup.h.
> 

Indeed, but my point was that the documentation can (and probably should)
be improved.


Cheers,
Angelo

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2024-06-04 11:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-30  9:34 [PATCH v1 0/4] MediaTek MT6357/8/9 PMIC Auxiliary ADC support AngeloGioacchino Del Regno
2024-05-30  9:34 ` [PATCH v1 1/4] dt-bindings: iio: adc: Add MediaTek MT6359 PMIC AUXADC AngeloGioacchino Del Regno
2024-06-01 15:32   ` Krzysztof Kozlowski
2024-06-04  8:55     ` AngeloGioacchino Del Regno
2024-06-04  9:38       ` Krzysztof Kozlowski
2024-06-04 12:24         ` AngeloGioacchino Del Regno
2024-06-02  9:40   ` Jonathan Cameron
2024-06-04  9:04     ` AngeloGioacchino Del Regno
2024-06-06 19:40       ` Jonathan Cameron
2024-05-30  9:34 ` [PATCH v1 2/4] iio: adc: Add support for MediaTek MT6357/8/9 Auxiliary ADC AngeloGioacchino Del Regno
2024-05-30 13:34   ` Andy Shevchenko
2024-06-04 10:38     ` AngeloGioacchino Del Regno
2024-06-04 11:05       ` Andy Shevchenko
2024-06-04 11:56         ` AngeloGioacchino Del Regno [this message]
2024-06-02 10:11   ` Jonathan Cameron
2024-06-04  9:42     ` AngeloGioacchino Del Regno
2024-06-04 10:55       ` Andy Shevchenko
2024-06-04 11:20         ` Andy Shevchenko
2024-06-04 11:57         ` AngeloGioacchino Del Regno
2024-06-06 19:51       ` Jonathan Cameron
2024-05-30  9:34 ` [PATCH v1 3/4] mfd: mt6397-core: Add support for AUXADCs on MT6357/58/59 PMICs AngeloGioacchino Del Regno
2024-05-31 17:05   ` (subset) " Lee Jones
2024-05-30  9:34 ` [PATCH v1 4/4] arm64: dts: mediatek: Add ADC node on MT6357, MT6358, MT6359 PMICs AngeloGioacchino Del Regno

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=3e741571-9086-4f26-a158-d86a4cdcc349@collabora.com \
    --to=angelogioacchino.delregno@collabora.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=bigunclemax@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=fr0st61te@gmail.com \
    --cc=jic23@kernel.org \
    --cc=kernel@collabora.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=marcus.folkesson@gmail.com \
    --cc=marius.cristea@microchip.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mike.looijmans@topic.nl \
    --cc=mitrutzceclan@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox