Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp535532ybk; Fri, 15 May 2020 07:13:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySG1l+kGGvegUXIaymD0qP6AIwzPog5n+RSGhH9qXq/evlHRrFPRc7UWKP0Lm0/LXrOt3r X-Received: by 2002:a17:906:dbc9:: with SMTP id yc9mr2996709ejb.157.1589552015636; Fri, 15 May 2020 07:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589552015; cv=none; d=google.com; s=arc-20160816; b=OeBJhBkj1BQPZ69qSZfbTc+QY9TQd2Pk0Lgsiga7VArf1rzk52Sf3E4tcLqYWIhJex oJs6ihrSdqfxR8sG0aKYd1VOxI0+AnT5gELw9w0/6Gj/tXosRyhaUrhz5cPTF/y+r5Cn C7Xb3F6ucwCg9+9t2+hmw10IpGjgrnHlOn4Fn4952GaF5ULGReKNPgBlUgYN4ZWWiD+3 0BhQMOupt1zPV8edjVfj9kNj6I+ekMXIwewSfKLo6NlstVNqhVEPFb86YH+ViO5tpqbY LNdQEcfPMFQ9XsX7jAQgOnes0srkk/U1LwsS28/apkoIX8nEbGBpUDt3cec2rDOYJRA3 kfWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=RJ6XAk7W2stQGCvpULKUDc0FYaIKu2TAbXfun2Pkr3g=; b=WcCwoAn9pnFTHxhB3U0jK7dwfMqjeyrnFPxNEZOlXWlvwfASDuktIX4uCmo4K/nfbO 98uKoNlTxttj/eMNMlJA2xQ9YhK/93kz7ZMTUoLlqsb61lbMKWHAcGzeX9rAGKI+DRtI tDaaTGeyaKSWPzn5WIJmch0AB69M2MKcOZTs9HOdPRWh3+swtmN+Pbn5NdRCVVD9VtXX qNWj+RcO5eRBRZrRgPCb9tye5iKVjx5Jp0HlNx5kemcNIv0peGOvaFVgFVAj/NCt5gkh MzxFMZyG8NtRJ3OqKMZr4G/xz6HEb3n2UDrdTE6eLzUZ1NPqEeof7EhiqEpoSb0J4rFA pyYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SLCIRIPg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 l30si1248127edl.555.2020.05.15.07.13.11; Fri, 15 May 2020 07:13:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=SLCIRIPg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726263AbgEOOLJ (ORCPT + 99 others); Fri, 15 May 2020 10:11:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726140AbgEOOLI (ORCPT ); Fri, 15 May 2020 10:11:08 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FA4DC05BD09 for ; Fri, 15 May 2020 07:11:07 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id y3so3770034wrt.1 for ; Fri, 15 May 2020 07:11:07 -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=RJ6XAk7W2stQGCvpULKUDc0FYaIKu2TAbXfun2Pkr3g=; b=SLCIRIPgLr81qFn7rCPeQwMQ8ryyFGrY2/HbUJTmnKVab0yEXJjD6YYun/KgxmHLfa iTZY5RxWXu/lKag4MbSRKfr8KHpZgny0vACzyjMaRXlXwR2wx9hlK4TzIIzI6CQwPW0t C9/T+hIi3zQqpW5KDpNm7YM4k+uUyjHI1g1MxgvxDHCqXH7kJBfQrcQtudhrXouZgFkO DZ5si5zjMelJhMBgWbqELsztELd6IYd9ohBo2+zZegUH4RlrUxeFWKUro2gRMbFKV/lB sM8OF1pMLTo9sOW/dyaYJu9vhScBU+jDkZ4dfwLIwSxGu3a3RMLIwI0Sw8pqCSm7Ox2A aDWw== 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=RJ6XAk7W2stQGCvpULKUDc0FYaIKu2TAbXfun2Pkr3g=; b=n2fypx66PmwB9E7gXmChBxyfixeva3Olv7FDi+fD31sHNgfEErun5vgcF8No5HotyD cmPY+EJvVOAI7uuLVdlms2KgmCdCEaM0TAoL/R2hvsepDjftpr0D8wntWO5YrUM6FF1Z juWhP4kTkis1Mof4vNl2bt62Ra/rqF4Y9GjwuZf1Vaniqz4Wd7guuVkiRlz/dXJg3ujg RDfMG3Ms1518bKZs8kNPLdmF1C6V8SAoVYZF+CjSqsdBmdEiPBGnkw2BCYhvz1df39cp XQUU0s0hburFtydF1nfpbtvvbIJ7gcCB2CC/cqOiTyu5u95V2yDlDDSdhZZPDpNq8dpE 0TWQ== X-Gm-Message-State: AOAM53190LrzwNufcdnu0PLu6PeNqSK6jKjh+29Q2fLIosjVLMjMQF+L qqpgiyTTs4X+sXQpwSa1kWE2wfEq3jc= X-Received: by 2002:a5d:438c:: with SMTP id i12mr4512075wrq.14.1589551865810; Fri, 15 May 2020 07:11:05 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 07:11:05 -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 2/4] thermal: core: Get thermal zone by id Date: Fri, 15 May 2020 16:10:31 +0200 Message-Id: <20200515141034.19154-2-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The next patch will introduce the generic netlink protocol to handle events, sampling and command from the thermal framework. In order to deal with the thermal zone, it uses its unique identifier to characterize it in the message. Passing an integer is more efficient than passing an entire string. This change provides a function returning back a thermal zone pointer corresponding to the identifier passed as parameter. Signed-off-by: Daniel Lezcano --- drivers/thermal/thermal_core.c | 14 ++++++++++++++ drivers/thermal/thermal_core.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 54208b6deb42..6f7a1a7ffd2a 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -689,6 +689,20 @@ int for_each_thermal_zone(int (*cb)(struct thermal_zone_device *, void *), return ret; } +struct thermal_zone_device *thermal_zone_get_by_id(int id) +{ + struct thermal_zone_device *tz = NULL; + + mutex_lock(&thermal_list_lock); + list_for_each_entry(tz, &thermal_tz_list, node) { + if (tz->id == id) + break; + } + mutex_unlock(&thermal_list_lock); + + return tz; +} + 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 bb8f8aee79eb..7e8f45db6bbf 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -50,6 +50,8 @@ int for_each_thermal_cooling_device(int (*cb)(struct thermal_cooling_device *, int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *), void *thermal_governor); +struct thermal_zone_device *thermal_zone_get_by_id(int id); + struct thermal_attr { struct device_attribute attr; char name[THERMAL_NAME_LENGTH]; -- 2.17.1