From patchwork Fri May 15 14:10:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 212021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB38EC433E0 for ; Fri, 15 May 2020 14:11:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 823112076A for ; Fri, 15 May 2020 14:11:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NUjZzrQH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726237AbgEOOLG (ORCPT ); Fri, 15 May 2020 10:11:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726226AbgEOOLF (ORCPT ); Fri, 15 May 2020 10:11:05 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52EBCC05BD09 for ; Fri, 15 May 2020 07:11:05 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id z72so2838790wmc.2 for ; Fri, 15 May 2020 07:11:05 -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=A4+UkWcvLP2WT8CuakkXaohSADBdrjeeNAnbolDDe08=; b=NUjZzrQH7/8UPP7L24eoPhEPg6G8tZ2NntXz0lwP2s0+zSuswWa26LQVNl+OrxXnJo yudmQee/QQ6NO3s4BTkl/KR8DMF4HZ27qvEvCKr3mSJPwhznPRytkZk6IkZDqL+EJl6m cWqf5WDuVjEl6Jm4k1+seLdLsemn5kRPoBbpaTUWwot8wcWQ69n2b8K9k4LUsBKMziay 4OZ7V9i574hixJhPtRi+84gxc/mEDA1aCqdpQxSS8LjVP9SoUAiHNIdCYLbi6hveqxgN C08vZZmrigL+fS+teNs/xXJxLoPmRO6GVbb9r/WY377bW5tJ+29fL0cS3gbrP4PcgPFh C5kA== 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=A4+UkWcvLP2WT8CuakkXaohSADBdrjeeNAnbolDDe08=; b=a3vr1RiuTF2knW9kCuCu6GQUaoaOqI2t0VWZ4eNN2fOS02b1H8kUm+N3kdCxDSWE50 qcliau/lFpKPcmXx0yytAbyf8IIp0Dh8SnB59mDu1coDStQaeR7iEh1DCKYuEe7Dsnj3 D2RqDVkmBdt9fbMdzVe5Xc7XydsGFZ+2uH0F0msIr4NZJogx6OQLATAYVps/uubfQsWv Lafu/gtRnvwq9/rnCDQIK6qq1vwsTlacXJluuZvgo9EEfjY0lldmU0+QsMvve018Jwx8 DQHLhz9s+2fdpvhQ1BwQfyiTPUSUCLZfowPahO94OA5ZjLApkttwRx8JcG8l3kbHnS7w 43Fg== X-Gm-Message-State: AOAM532MURHfUjj3XAfVAbHTnNIawVrtHvPdokLuY4L0Zu3iW2d+defV v9BkxXS4D7DRKPq05Cz/4gXyxw== X-Google-Smtp-Source: ABdhPJzcMZfZ6NXde6nZJ9Qrvuofbkk+4OFACM9BWBFB//xLPloqviY3hVReBzWCB1pZLgBNCIYCSw== X-Received: by 2002:a7b:c413:: with SMTP id k19mr4243265wmi.124.1589551863052; Fri, 15 May 2020 07:11:03 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-59-82-252-135-148.adsl.proxad.net. [82.252.135.148]) by smtp.gmail.com with ESMTPSA id d6sm4432438wra.63.2020.05.15.07.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:11:02 -0700 (PDT) From: Daniel Lezcano To: rui.zhang@intel.com Cc: amit.kucheria@verdurent.com, srinivas.pandruvada@linux.intel.com, arnd@arndb.de, rkumbako@codeaurora.org, ilina@codeaurora.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/4] thermal: core: Add helpers to browse the cdev, tz and governor list Date: Fri, 15 May 2020 16:10:30 +0200 Message-Id: <20200515141034.19154-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 The cdev, tz and governor list, as well as their respective locks are statically defined in the thermal_core.c file. In order to give a sane access to these list, like browsing all the thermal zones or all the cooling devices, let's define a set of helpers where we pass a callback as a parameter to be called for each thermal entity. We keep the self-encapsulation and ensure the locks are correctly taken when looking at the list. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 51 ++++++++++++++++++++++++++++++++++ drivers/thermal/thermal_core.h | 9 ++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index a6b8c0240656..54208b6deb42 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -638,6 +638,57 @@ void thermal_zone_device_rebind_exception(struct thermal_zone_device *tz, mutex_unlock(&thermal_list_lock); } +int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), + void *data) +{ + struct thermal_governor *gov; + int ret = 0; + + mutex_lock(&thermal_governor_lock); + list_for_each_entry(gov, &thermal_governor_list, governor_list) { + ret = cb(gov, data); + if (ret) + break; + } + mutex_unlock(&thermal_governor_lock); + + return ret; +} + +int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *, + void *), void *data) +{ + struct thermal_cooling_device *cdev; + int ret = 0; + + mutex_lock(&thermal_list_lock); + list_for_each_entry(cdev, &thermal_cdev_list, node) { + ret = cb(cdev, data); + if (ret) + break; + } + mutex_unlock(&thermal_list_lock); + + return ret; +} + +int for_each_thermal_zone(int (*cb)(struct thermal_zone_device *, void *), + void *data) +{ + struct thermal_zone_device *tz; + int ret = 0; + + mutex_lock(&thermal_list_lock); + list_for_each_entry(tz, &thermal_tz_list, node) { + ret = cb(tz, data); + if (ret) + break; + } + mutex_unlock(&thermal_list_lock); + + return ret; +} + void thermal_zone_device_unbind_exception(struct thermal_zone_device *tz, const char *cdev_type, size_t size) { diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index 4e271016b7a9..bb8f8aee79eb 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -41,6 +41,15 @@ extern struct thermal_governor *__governor_thermal_table_end[]; __governor < __governor_thermal_table_end; \ __governor++) +int for_each_thermal_zone(int (*cb)(struct thermal_zone_device *, void *), + void *); + +int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *, + void *), void *); + +int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), + void *thermal_governor); + struct thermal_attr { struct device_attribute attr; char name[THERMAL_NAME_LENGTH]; From patchwork Fri May 15 14:10:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 212020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEFACC433E1 for ; Fri, 15 May 2020 14:11:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDC7E2075F for ; Fri, 15 May 2020 14:11:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Das9pl01" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726290AbgEOOLL (ORCPT ); Fri, 15 May 2020 10:11:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726278AbgEOOLK (ORCPT ); Fri, 15 May 2020 10:11:10 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 539F9C061A0C for ; Fri, 15 May 2020 07:11:10 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id k12so2473850wmj.3 for ; Fri, 15 May 2020 07:11:10 -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:in-reply-to:references; bh=PKPieQCHF+nm/iYn6FAQVcl/MzY/rRP6qinUb5RW81I=; b=Das9pl01gBCsp1gGCbQcY1KZ1UFy97GIBpNJBqvH/Awn51perczGgth8S4CeOAhzAP wGe0X1exwRTLH60MlculCA+31NYczsae4pTkldI+iugU0PKRFlmC7+WYDolDVZWOw2lD QYh1w4oZrMCCfO+9vGwKudbEGpf3q7AZ1TbsCoSPBUghb1iiSLa7UGX/VWJgPzW6XNQp QzNpzf743a5dS89YPm9dMHWJ9DxQ0TOtsgTo+gkJtyzdOPGyjOXBtMCIT2OkEGvmuCWp w/C1gOomtr4YvD7lpKGrrfIulHzxFNWC9UdIX3eknuqsLgiO8k4PDD9SZSSYxTQzKoc/ e+Fw== 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=PKPieQCHF+nm/iYn6FAQVcl/MzY/rRP6qinUb5RW81I=; b=IRWhDyf7/ZXX3TGdpZv+79rpLXzqlVHgRwna2vl0jV4dXoWVJxYVrDI0Dh3pwoAcdV Eb5Wdic8LA8Oa000WVE+4HECVnFTm2zkWEnSp0bBoWty4b37oyd1oB9IjnK4gQ9I8OLz Cob949ksdVSw5lEw7DoGpbmCp11NH/6odRg3KzpgRKSHpsd2nTrFl8PQDxYlPHgtz6vm Ref3VifQC30az+6L57OTpggvxM1X7OIVgDKylIQThm58T7+ePsupgRmKxInmwQRQur8G Tqa2/ERIUFea9em7VPqKCh9EXV3sY8S7uYvLQRxJjZxpeP5KddAKVGgyVpLheY2HWdxk gwzg== X-Gm-Message-State: AOAM530RHefFt45l1RDqSw/Fo5L/Hx6SwH+4jbvn9JByv1dHRHOfYn2Q r1gYEbonOa2qlm5jPCaacDPnWw== X-Google-Smtp-Source: ABdhPJy9Gia2ZS1ien6LmcmxFdsWEHYPQ+Zkigj3OCeK7I0PgfUjljQPj9SPuCt6ryozsZsXKTdapw== X-Received: by 2002:a7b:cc84:: with SMTP id p4mr4504714wma.159.1589551868914; Fri, 15 May 2020 07:11:08 -0700 (PDT) Received: from localhost.localdomain (lns-bzn-59-82-252-135-148.adsl.proxad.net. [82.252.135.148]) by smtp.gmail.com with ESMTPSA id d6sm4432438wra.63.2020.05.15.07.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:11:08 -0700 (PDT) From: Daniel Lezcano To: rui.zhang@intel.com Cc: amit.kucheria@verdurent.com, srinivas.pandruvada@linux.intel.com, arnd@arndb.de, rkumbako@codeaurora.org, ilina@codeaurora.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org (open list) Subject: [PATCH 3/4] thermal: core: Remove old uapi generic netlink Date: Fri, 15 May 2020 16:10:32 +0200 Message-Id: <20200515141034.19154-3-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200515141034.19154-1-daniel.lezcano@linaro.org> References: <20200515141034.19154-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org In order to set the scene for the new generic netlink thermal management and notifications, let remove the old dead code remaining in the uapi headers. Signed-off-by: Daniel Lezcano --- include/linux/thermal.h | 5 ----- include/uapi/linux/thermal.h | 12 +----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/include/linux/thermal.h b/include/linux/thermal.h index faf7ad031e42..fc93a6348082 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -302,11 +302,6 @@ struct thermal_zone_params { int offset; }; -struct thermal_genl_event { - u32 orig; - enum events event; -}; - /** * struct thermal_zone_of_device_ops - scallbacks for handling DT based zones * diff --git a/include/uapi/linux/thermal.h b/include/uapi/linux/thermal.h index 96218378dda8..22df67ed9e9c 100644 --- a/include/uapi/linux/thermal.h +++ b/include/uapi/linux/thermal.h @@ -6,21 +6,12 @@ /* Adding event notification support elements */ #define THERMAL_GENL_FAMILY_NAME "thermal_event" -#define THERMAL_GENL_VERSION 0x01 +#define THERMAL_GENL_VERSION 0x02 #define THERMAL_GENL_MCAST_GROUP_NAME "thermal_mc_grp" -/* Events supported by Thermal Netlink */ -enum events { - THERMAL_AUX0, - THERMAL_AUX1, - THERMAL_CRITICAL, - THERMAL_DEV_FAULT, -}; - /* attributes of thermal_genl_family */ enum { THERMAL_GENL_ATTR_UNSPEC, - THERMAL_GENL_ATTR_EVENT, __THERMAL_GENL_ATTR_MAX, }; #define THERMAL_GENL_ATTR_MAX (__THERMAL_GENL_ATTR_MAX - 1) @@ -28,7 +19,6 @@ enum { /* commands supported by the thermal_genl_family */ enum { THERMAL_GENL_CMD_UNSPEC, - THERMAL_GENL_CMD_EVENT, __THERMAL_GENL_CMD_MAX, }; #define THERMAL_GENL_CMD_MAX (__THERMAL_GENL_CMD_MAX - 1)