Re: [PATCH 4/5] powercap/drivers/dtpm: Use container_of instead of a private data field

Lukasz Luba
2021-03-09T15:18:23Z

On 3/1/21 9:21 PM, Daniel Lezcano wrote:
> The dtpm framework provides an API to allocate a dtpm node. However
> when a backend dtpm driver needs to allocate a dtpm node it must
> define its own structure and store the pointer of this structure in
> the private field of the dtpm structure.
>
> It is more elegant to use the container_of macro and add the dtpm
> structure inside the dtpm backend specific structure. The code will be
> able to deal properly with the dtpm structure as a generic entity,
> making all this even more self-encapsulated.
>
> The dtpm_alloc() function does no longer make sense as the dtpm
> structure will be allocated when allocating the device specific dtpm
> structure. The dtpm_init() is provided instead.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
> drivers/powercap/dtpm.c | 27 ++++++++++------------
> drivers/powercap/dtpm_cpu.c | 46 ++++++++++++++++++-------------------
> include/linux/dtpm.h | 3 +--
> 3 files changed, 35 insertions(+), 41 deletions(-)
>

Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>