Re: [PATCH v2 06/14] mfd: zl3073x: Add macros for device registers access
From: Ivan Vecera
Date: Sun Apr 13 2025 - 06:18:33 EST
On 10. 04. 25 7:53 odp., Andy Shevchenko wrote:
On Thu, Apr 10, 2025 at 11:21 AM Ivan Vecera <ivecera@xxxxxxxxxx> wrote:
On 10. 04. 25 9:17 dop., Krzysztof Kozlowski wrote:
On 09/04/2025 16:42, Ivan Vecera wrote:
...
+ WARN_ON(idx >= (_num)); \
No need to cause panic reboots. Either review your code so this does not
happen or properly handle.
Ack, will replace by
if (idx >= (_num))
return -EINVAL
If these functions are called under regmap_read() / regmap_write() the
above is a dead code. Otherwise you need to configure regmap correctly
(in accordance with the HW registers layout and their abilities to be
written or read or reserved or special combinations).
Hi Andy,
these functions are not called under regmap_{read,write} but above. Some
(non-mailboxed) registers are indexed.
E.g. register ref_freq is defined as 4-bytes for 10 input references:
ref0: address 0x144-0x147
ref1: address 0x148-0x14b
...
So the caller (this mfd driver or dpll driver) will access it as:
zl3073x_read_ref_freq(zldev, idx, &value);
and this helper then computes the addr value according base (0x144) and
provided index with ref number and then calls regmap_*read().
And the 'if' check is just for a sanity check that the caller does not
provide wrong index and if so return -EINVAL.
I.