lkml.org 
[lkml]   [2021]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 4/5] powercap/drivers/dtpm: Use container_of instead of a private data field
From
Date


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>

\
 
 \ /
  Last update: 2021-03-09 16:19    [W:0.238 / U:0.868 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site