Re: [PATCH v4 1/2] dt-bindings: cpufreq: Introduce QCOM CPUFREQ FW bindings

From: Viresh Kumar
Date: Tue Jun 19 2018 - 05:21:33 EST


On 19-06-18, 13:23, Taniya Das wrote:
> Driver code (The below representation is just for example).
> =============
>
> V1
> #define ENABLE 0x0
> #define LUT_V1 0x110
> #define PERF_V1 0x920
>
> V2
> #define LUT_V2 0x150
> #define PERF_V2 0x980
>
> V3
> #define LUT_V3 0x120
> ....
>
> Do you want me to use "compatible" flag to
>
> if (compatible == v1)
> enable = readl_relaxed(X + LUT_V1);
> else if (compatible == v2)
> enable = readl_relaxed(X + LUT_V2);
> else if (compatible == v3)
> enable = readl_relaxed(X + LUT_V2);

You can have fields in a struct somewhere like enable_offset, which you can fill
based on compatible string only once during probe and then the rest of the code
would just do:

enable = readl_relaxed(X + struct->enable_offset);

--
viresh