From patchwork Fri Mar 12 13:04:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 398609 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1181586jai; Fri, 12 Mar 2021 05:10:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJw35CGTrWWDMddgtuUfGMWGNgLmTqq4u9U9DigH4nId5YmKEHc39H7E9g34DK2ufliVMA27 X-Received: by 2002:aa7:c345:: with SMTP id j5mr13660914edr.338.1615554635471; Fri, 12 Mar 2021 05:10:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615554635; cv=none; d=google.com; s=arc-20160816; b=AyTb/XHOC/APq/IlAb2kMD++ll2TsZ6k8MODINdCqbjWvEJ5n0a8dM4DjKKsxWyJ3h 53StagxxoFseZpK1AlTLzLt8zS3NB/c9A3J6uqsDzIF5t51n8a38iwFprQ5CuCsc+i8I ppUMZaK+xkA4smKyRipRm4fQkkEsr/Tb+KBjDWpalbfdx/NQOX5NZS7THILimDzjgKDR x9Y//MZrvC4XZf/DrVIzHSuWfpo45fPidyJXAtB0cbCUTCqI9FZx+2s2+YCIZ09uOWaP NEfQiXQ+3TAxD6TK6I/b1ej1U/MtrFwwQDBI7CqBN2CDvjDcUrQv+kvNWcqFh3T1s+mn 7upg== 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=Y+3de1AeeAJ1f3wvK6vHJ9cHErXRUBGiuppggQN/HY8=; b=syIVCIkbcShglrmiVj9mLx6y9bgX1r89oT9llGqtyxzJjJNgXg713lBvdkE1yeezoT RvUeIPjTNMGDWWE2kR+w+LtlH9u6YowQl2EIQec3ONbjv5bW2IZX2E4FvgXMXVID+kbl BcR7SEE+tPCXJ1bgbUZSWX4o7t98n1lGgVv+8Efk7BDmdJ/Qnq5mekGU7a52jbVphFiI WrMM0RPirqpjO15FdQCoK5Dyo8LWNXSUMKR5X//Ix56E+VtS/MT36napMtTJZVVf8ufD K46HW6KaSB2jErfkriXp4eBj7kFKu2e9WEKjAotMoeIA9x46Sg3eXccwWnSZJ9eSjXyF eOcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Pkgj/hKq"; 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 jz7si4043056ejb.476.2021.03.12.05.10.35; Fri, 12 Mar 2021 05:10:35 -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="Pkgj/hKq"; 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 S230243AbhCLNKE (ORCPT + 7 others); Fri, 12 Mar 2021 08:10:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbhCLNJt (ORCPT ); Fri, 12 Mar 2021 08:09:49 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88DD6C061761 for ; Fri, 12 Mar 2021 05:09:49 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id e10so4764182wro.12 for ; Fri, 12 Mar 2021 05:09:49 -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=Y+3de1AeeAJ1f3wvK6vHJ9cHErXRUBGiuppggQN/HY8=; b=Pkgj/hKqaE5pZ9CRW1TFxEV3VYj479VPkYabx0stapmnfeYvEipZ62n4iTBYqKsvlG 0d9JosIdJZp26i9crzbWxJMw15hpPU/hxsJ17qd5uNj2sO+x6SQ6qteZjiPaspB4p3Qj dbQa+tw5W4FoPXr5D1ka+3DwwifS+40VImXpTU1aTJX661EwlB31jS0QFu4Ni1E3zum9 rd++tKPJbXVVk5mHdMTBOpX1/EnJDeDZXYh2y2tB6Bzue2pNvzX628DUnN1lJGyvOgzg IK11/3zPDOmaaiYXnrnZZbv0Ojl+NET2GOw8S8jiXNvn1GxTyPyScJvSCMXsYOsJ/GvP QNFA== 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=Y+3de1AeeAJ1f3wvK6vHJ9cHErXRUBGiuppggQN/HY8=; b=X2od+fYJLn+y9a5hHXqunBldfy/FWBFpza/UwyBgMILZOhi27fq60ymbxUhfotrgcO V6R5SaEDV6nOGPWKndUjjYm6MraIzBaq/y3NZHxno4KZDdWzn0JJqB/xkDrb48NOSY7X VprszKX5G2yGapvaw1shjnk40Ug3JLhxsOIZzJYpJpUrEKDkPcL3PdrB+kEU3WbM4sV1 xHd1UNYXpKMTO3Y963g2ofI8fxdc78vYXynxLHoOpETlWHUEoJC0qmwUQUb1+6dnYWCo 93py316bTKhqTynPLCO5Fk6opaiXqsOsrSGeKkrl4iHHy3FrK+K1dHANTeoGyD//yJK8 QqQA== X-Gm-Message-State: AOAM531XPoiIU9jsNe5VdLP2XSHUN3V4l+o0GQy5d5juyxS51ya2jlN3 eqVkrPtBMcNjI7xz0UQBwN0tcQ== X-Received: by 2002:a5d:4445:: with SMTP id x5mr14268622wrr.30.1615554588225; Fri, 12 Mar 2021 05:09:48 -0800 (PST) Received: from localhost.localdomain ([82.142.0.212]) by smtp.gmail.com with ESMTPSA id q15sm7655033wrr.58.2021.03.12.05.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 05:09:47 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, lukasz.luba@arm.com Subject: [PATCH v4 3/5] powercap/drivers/dtpm: Simplify the dtpm table Date: Fri, 12 Mar 2021 14:04:09 +0100 Message-Id: <20210312130411.29833-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210312130411.29833-1-daniel.lezcano@linaro.org> References: <20210312130411.29833-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 Reviewed-by: Lukasz Luba --- 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 diff --git a/drivers/powercap/dtpm.c b/drivers/powercap/dtpm.c index d00f55f0ee30..74d9603bd42a 100644 --- a/drivers/powercap/dtpm.c +++ b/drivers/powercap/dtpm.c @@ -610,7 +610,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)) { @@ -619,7 +619,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 8592a78e47e4..c4fa35fabc40 100644 --- a/drivers/powercap/dtpm_cpu.c +++ b/drivers/powercap/dtpm_cpu.c @@ -204,7 +204,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; @@ -241,3 +241,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 d724c5a7b2f4..5f71ddc18ee9 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);