From patchwork Wed Jun 12 20:13:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 166592 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4107601ilk; Wed, 12 Jun 2019 13:13:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOMoNJN0x3watv5ByOayBsrMPx866n4INrlh2Bfe2XXKHGDU6u66R2oYmk1BlczwWfLIfr X-Received: by 2002:aa7:9a92:: with SMTP id w18mr58757970pfi.167.1560370425960; Wed, 12 Jun 2019 13:13:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560370425; cv=none; d=google.com; s=arc-20160816; b=Vxz9lf4lXS0x/fOVbGWnT+I1ZBSO0He1cdMNoBVSxd9FuHgfEGS2BX0MksaELZ5wrG EcN22IqNZTsaJN6CX8ayM1M9evWyCIIJWY8ao7nnmGgKki4EPj64K4tW4rSl8NIRxu/5 +yopNF59M9f2/vmBtEw3CrsmdW+n32Hw4VnMQzmd4HF+OrwG7zafbLwn5usJ3WCKQbK8 veEHR+izAiD+nhHFagKE0QnF4vJ+JOygEvkW1uqFE3MZtms3sp5h2lGF/MF47M0d+OwL G1QBbjjCy7DeaiODagrr6uiZpg67cSi+D93wi2jfXOUXaRsi1We5zmTsKq81tY21jDCO 43UQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=A36/iHVaO3uEyS+d/EzeUq+RkDaMz832JoNltOURTBo=; b=eIaRs1kdoJCIRsOUAeCH+44gdgD4ib+0sFpXDLIdXH9bekmSYwjjkwSEAjABG0nJCA ZuUxlC3ZKH4soMasaryhtS46RMHB8aiIF+u+3hmspsOqHsI/AqTeaWamSLc1RzYxLgYF gQTFH8Ad6OFoenUT1ddsRn2elERfZZUUGN3P67dRyHxUobJPODjMZSW9VhRXn1gx5uyn k6GXAxaFz6dMf1Mv/5t+WiPN/ZUQkjHqa397dCLo9PDc++SCdHcxXc6FYhCHhdYLKRuU 3aBY/YDgcT/AjMPbukUnRzSyIVr5wC2W4CtsduLQV2iyrOnkT4VVnoU9b7m3LTWwBvF3 EjCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pJZ/5d5b"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d9si636354pgj.505.2019.06.12.13.13.45; Wed, 12 Jun 2019 13:13:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="pJZ/5d5b"; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 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 S1728328AbfFLUNp (ORCPT + 11 others); Wed, 12 Jun 2019 16:13:45 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:37315 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726735AbfFLUNo (ORCPT ); Wed, 12 Jun 2019 16:13:44 -0400 Received: by mail-wm1-f65.google.com with SMTP id 22so7802698wmg.2 for ; Wed, 12 Jun 2019 13:13:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=A36/iHVaO3uEyS+d/EzeUq+RkDaMz832JoNltOURTBo=; b=pJZ/5d5bOCs+D/TMQ5HtKnIIGvOiYfkzCi/ZdmCXPovFoxtFlNW+znmeVJoNQ24uOO SP6bNoCNILq9tzyaj/oXNFP72q58wVj6ldVo7xeSZ179In8KmiNQUIL8XU2paluGue7x Q66eCs7deVGb04ErpjQlM4ZSoVDTf9QDkETW+J/XJ7bkdpTWNXfPsnhf0UC4pQJnbIuO bkXgtexgQBm6pOpdRJsuutM7+EQydWCkL8IjcPlTk8hjbUceGQMlIgamepIbUVHaQ0g5 D1A9v2CpVNgp625F4yhbrH8LLw1kmqnefVhKPIN1l+ZwyYO5XiCJRPfsm6HCNkXLTRmZ df0Q== 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; bh=A36/iHVaO3uEyS+d/EzeUq+RkDaMz832JoNltOURTBo=; b=CTVKznb7PoUvfkndqwrdfDfIdnewoSxrueH8XJvx4Yc3JdWFPW4lSp1ZB2VLis9OwG 0eEp6Yn0Gq8xJsbwgBq3mWP0esli85epWgrOGirXFdmE7I2pmwEzwh83fy9CAnkSZqxW PH+PiUoKywNte8Ada7joNyxsDEQ+ximh58d4Nd6adD3sKfA2LVSRCx7C0caT1SetYRUv bneiNvex5FUYpmdTcA3b2wbJekx3pucINbe7Vj7Ub/UlQxmjQiAEB1BphMN0frfat/ve 3bjrS5cqA//v+R+mBBL4kBeiOnMTeO+l0t8fZr/KKZIML8OCfLPpv0JfSa69PQBH5AaY tk6g== X-Gm-Message-State: APjAAAV+9vkfLwnQqHHCWZzD2xZz1Bm+h6aUL5QHH34pqzPWQPR1eGvg lYqs7L53ugXDebiV0IPINJ5+fQ== X-Received: by 2002:a1c:343:: with SMTP id 64mr704892wmd.116.1560370422201; Wed, 12 Jun 2019 13:13:42 -0700 (PDT) Received: from mai.imgcgcw.net (237.65.130.77.rev.sfr.net. [77.130.65.237]) by smtp.gmail.com with ESMTPSA id l8sm1119566wrg.40.2019.06.12.13.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2019 13:13:41 -0700 (PDT) From: Daniel Lezcano To: rui.zhang@intel.com Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, amit.kucheria@linaro.org Subject: [PATCH 1/2] thermal/drivers/core: Add init section table for self-encapsulation Date: Wed, 12 Jun 2019 22:13:24 +0200 Message-Id: <20190612201325.1150-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the governors are declared in their respective files but they export their [un]register functions which in turn call the [un]register governors core's functions. That implies a cyclic dependency which is not desirable. There is a way to self-encapsulate the governors by letting them to declare themselves in a __init section table. Define the table in the asm generic linker description like the other tables and provide the specific macros to deal with. Reviewed-by: Amit Kucheria Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.h | 15 +++++++++++++++ include/asm-generic/vmlinux.lds.h | 11 +++++++++++ 2 files changed, 26 insertions(+) -- 2.17.1 diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 0df190ed82a7..be901e84aa65 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -15,6 +15,21 @@ /* Initial state of a cooling device during binding */ #define THERMAL_NO_TARGET -1UL +/* Init section thermal table */ +extern struct thermal_governor *__governor_thermal_table[]; +extern struct thermal_governor *__governor_thermal_table_end[]; + +#define THERMAL_TABLE_ENTRY(table, name) \ + (static typeof(name) *__thermal_table_entry_##name \ + __used __section(__##table##_thermal_table) = &name) + +#define THERMAL_GOVERNOR_DECLARE(name) THERMAL_TABLE_ENTRY(governor, name) + +#define for_each_governor_table(__governor) \ + for (__governor = __governor_thermal_table; \ + __governor < __governor_thermal_table_end; \ + __governor++) + /* * This structure is used to describe the behavior of * a certain cooling device on a certain trip point diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index f8f6f04c4453..8312fdc2b2fa 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -239,6 +239,16 @@ #define ACPI_PROBE_TABLE(name) #endif +#ifdef CONFIG_THERMAL +#define THERMAL_TABLE(name) \ + . = ALIGN(8); \ + __##name##_thermal_table = .; \ + KEEP(*(__##name##_thermal_table)) \ + __##name##_thermal_table_end = .; +#else +#define THERMAL_TABLE(name) +#endif + #define KERNEL_DTB() \ STRUCT_ALIGN(); \ __dtb_start = .; \ @@ -609,6 +619,7 @@ IRQCHIP_OF_MATCH_TABLE() \ ACPI_PROBE_TABLE(irqchip) \ ACPI_PROBE_TABLE(timer) \ + THERMAL_TABLE(governor) \ EARLYCON_TABLE() \ LSM_TABLE()