From patchwork Mon Mar 1 21:21:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 388756 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3708012jap; Mon, 1 Mar 2021 13:30:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsuri+H8XmgeoHRDS8n9u39CEN/bfQYFb5l/I7k+Q8dNdzdObcxiRnywFvYrzyRG7hvBC5 X-Received: by 2002:a17:906:d153:: with SMTP id br19mr10103744ejb.360.1614634222789; Mon, 01 Mar 2021 13:30:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614634222; cv=none; d=google.com; s=arc-20160816; b=l6iJ/Bzz245x2Y/jdUAkmxVmq8/tSeKB/C/sxJOsCq0Na4ttzA7y6aJg3Hj6p4ZEEY EMYaIxyfnqa67txI8bws4hozfV+eyROTfOXDKN2a95vX/GoB9YpaT+kKdwVVEQYnGihj hnbWotNYDsz5+vdZ2TO9pvSceF2Q3PnLudsgh7mSMEJILrJ0OH9Ui9OeoI/dHu0Z4vT4 yTQ5OAgeOqow0d1JWmoyNlbWZ+Y1wIDqFGKP4ebfn7RPwJxno5Zqky6vzimvEdENKRbz rYJdqi6BRksQFYKntdAq5xgoimb3gTs4+syg9rF1l0LW3olddEvTqmPDa9AElaFMDcSU Z4AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=tdxUTGi9m/Gz5i3ZHWaGA+tNFidX5BqMkBrNPYV1F7w=; b=vwGJDtsn1uTnQ3HX1ajRkIQEo91eKcF5q36OPj9pDkgcSxdVoFlZhFBjQHl1Sani6G nL2J7CJHXR276pWbZ2BIEuoyPEAVN1ZnaDSETM3t+keq2VGZfkHjQOC/RCxWNWt5n2BE dzEPHXFBw4RTP/Hlqai40v2qoWKzrplp35NifMMpzFfE6JVB5L6JEUlVsbFU5Xg0Ixfy C9PfKnJ0bx2gXHnd/RVTTQs9m6qQUnBMT2z/ATFjlmE1BF/W1uy3C8dKFsItBOxgrwDf rvtyr2Daz8e8+aq7rJyT2txyJ31D/VRVE95t9WWVIooJ6oNGh4VeNOn5GnQ65Hhi4alL D91g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KM2Hsdgm; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr14si3825272ejc.394.2021.03.01.13.30.22; Mon, 01 Mar 2021 13:30:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KM2Hsdgm; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240491AbhCAV3I (ORCPT + 7 others); Mon, 1 Mar 2021 16:29:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244234AbhCAVXq (ORCPT ); Mon, 1 Mar 2021 16:23:46 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64A91C061793 for ; Mon, 1 Mar 2021 13:23:06 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id a18so9463125wrc.13 for ; Mon, 01 Mar 2021 13:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tdxUTGi9m/Gz5i3ZHWaGA+tNFidX5BqMkBrNPYV1F7w=; b=KM2HsdgmAOVLJ1XnyzbihJMlr8Fmo8S4dS1XE40nyf802ZCVjhThMwBuViSrCwPEYp W1HPDn+yN4tm3QqxdFwb6ItVi5mCFxFV9T9pMbc3s5ZfHRfCSDJTLq22lWPaE84n9Y5D MM+b0sy+zysJy7LMXUJQAThlED5fZM2zBWM9+Tokh1Dl1wi9/dFIN1EKEyB9IB4ZFiiC Nssx+OFx2DmKMgpvA4V269Srznwf6tzHDNmZ4gR9YQkb3fVwS8IhGvYJMkwHTCbKKznO J7YZX/Qk2OYQzim7Xjau1V6mnXnwVV+omdsa3narIoOl/YFuDq97NCm6gm2p97oWBe72 ZhTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tdxUTGi9m/Gz5i3ZHWaGA+tNFidX5BqMkBrNPYV1F7w=; b=NY2QombJvMw7hcgyiGmIeaz1APNHvLF+kWH3cFg1ekAWddG9QZn3URnIppBLCxZzOR 7kqRs7NmYR4wxmtmmMk8YiMPU6hlZ/upQhk+7dG8osb8NND6FyYCTMAb0BCqA6aPxca1 lis86vUiquxJ6klRzGiFhIbEG3EnAFJkK27h2FXU4ptJvC8x0gC20SIWRpzf7p937foX P+/6wOm18sATQyaQ8v8AdMqRGl+keAHUdPMShWeY7sM91SHUymnQzDlfrXG+rZ4pBOkZ U6S9ZGJmaNOHqLKyJedYRGhjg1xe1f+eHLvnFRS/ne2pJab/1eELEvdFm0zwA9xy4VeT rRqA== X-Gm-Message-State: AOAM532NiJg9WFQHd2lkjuOJIKda7lZV38DczvYiP2lh/v6KcK/3LQfs KERvC6sfJuxgzDl2ezuEb41leQ== X-Received: by 2002:a5d:570b:: with SMTP id a11mr18660666wrv.281.1614633785103; Mon, 01 Mar 2021 13:23:05 -0800 (PST) Received: from localhost.localdomain (lns-bzn-59-82-252-144-192.adsl.proxad.net. [82.252.144.192]) by smtp.gmail.com with ESMTPSA id o11sm6783866wrq.74.2021.03.01.13.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Mar 2021 13:23:04 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 3/5] powercap/drivers/dtpm: Simplify the dtpm table Date: Mon, 1 Mar 2021 22:21:47 +0100 Message-Id: <20210301212149.22877-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210301212149.22877-1-daniel.lezcano@linaro.org> References: <20210301212149.22877-1-daniel.lezcano@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The dtpm table is an array of pointers, that forces the user of the table to define initdata along with the declaration of the table entry. It is more efficient to create an array of dtpm structure, so the declaration of the table entry can be done by initializing the different fields. Signed-off-by: Daniel Lezcano --- drivers/powercap/dtpm.c | 4 ++-- drivers/powercap/dtpm_cpu.c | 4 +++- include/linux/dtpm.h | 22 +++++++++------------- 3 files changed, 14 insertions(+), 16 deletions(-) -- 2.17.1 Reviewed-by: Lukasz Luba diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c index 20728a28ff0d..a1a70dc48f63 100644 --- a/drivers/powercap/dtpm.c +++ b/drivers/powercap/dtpm.c @@ -607,7 +607,7 @@ int dtpm_create(const char *name, struct dtpm *dtpm, struct dtpm *parent) static int __init dtpm_init(void) { - struct dtpm_descr **dtpm_descr; + struct dtpm_descr *dtpm_descr; pct = powercap_register_control_type(NULL, "dtpm", NULL); if (IS_ERR(pct)) { @@ -616,7 +616,7 @@ static int __init dtpm_init(void) } for_each_dtpm_table(dtpm_descr) - (*dtpm_descr)->init(*dtpm_descr); + dtpm_descr->init(); return 0; } diff --git a/drivers/powercap/dtpm_cpu.c b/drivers/powercap/dtpm_cpu.c index 1a10537c4434..c5fe98eeec52 100644 --- a/drivers/powercap/dtpm_cpu.c +++ b/drivers/powercap/dtpm_cpu.c @@ -207,7 +207,7 @@ static int cpuhp_dtpm_cpu_online(unsigned int cpu) return ret; } -int dtpm_register_cpu(struct dtpm *parent) +static int __init dtpm_cpu_init(void) { int ret; @@ -223,3 +223,5 @@ int dtpm_register_cpu(struct dtpm *parent) return 0; } + +DTPM_DECLARE(dtpm_cpu, dtpm_cpu_init); diff --git a/include/linux/dtpm.h b/include/linux/dtpm.h index 447ea6c60b59..8a2dbbc334b9 100644 --- a/include/linux/dtpm.h +++ b/include/linux/dtpm.h @@ -34,25 +34,23 @@ struct dtpm_ops { void (*release)(struct dtpm *); }; -struct dtpm_descr; - -typedef int (*dtpm_init_t)(struct dtpm_descr *); +typedef int (*dtpm_init_t)(void); struct dtpm_descr { - struct dtpm *parent; - const char *name; dtpm_init_t init; }; /* Init section thermal table */ -extern struct dtpm_descr *__dtpm_table[]; -extern struct dtpm_descr *__dtpm_table_end[]; +extern struct dtpm_descr __dtpm_table[]; +extern struct dtpm_descr __dtpm_table_end[]; -#define DTPM_TABLE_ENTRY(name) \ - static typeof(name) *__dtpm_table_entry_##name \ - __used __section("__dtpm_table") = &name +#define DTPM_TABLE_ENTRY(name, __init) \ + static struct dtpm_descr __dtpm_table_entry_##name \ + __used __section("__dtpm_table") = { \ + .init = __init, \ + } -#define DTPM_DECLARE(name) DTPM_TABLE_ENTRY(name) +#define DTPM_DECLARE(name, init) DTPM_TABLE_ENTRY(name, init) #define for_each_dtpm_table(__dtpm) \ for (__dtpm = __dtpm_table; \ @@ -74,8 +72,6 @@ void dtpm_destroy(struct dtpm *dtpm); int dtpm_create(const char *name, struct dtpm *dtpm, struct dtpm *parent); -int dtpm_register_cpu(struct dtpm *parent); - int dtpm_register(const char *name, struct dtpm *dtpm); void dtpm_unregister(const char *name);