Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3527228ybt; Tue, 30 Jun 2020 05:14:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwl44kiw5f/X+56T2GHWEy5jEkhFyy5snsZrdIaOMGLoIIYkEP/x1lqPmH5KhclPN4BtB/ X-Received: by 2002:a17:906:1d5b:: with SMTP id o27mr13086355ejh.367.1593519288848; Tue, 30 Jun 2020 05:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593519288; cv=none; d=google.com; s=arc-20160816; b=SXiIwNR6oOLNF2jM8rGXSZVAl6Rp9gNcXrP2W/zkVH21gZGerbHAMhidBTM1MIg2XM l0H3eYpFM9qrEaeqEZY0Le+Kpv9C9bzykDPOuOB0SmI9xfLZPUQeiS9vJDujntHNwmlX T/c9vwHZGtbAbOSBZbhpuXQ7JdyuYqzu90S3rpzNfJzWv+IsM8boAGAJzWpYdjRNCg5p 9lOUFiv4zRNd/2BnKSmdw7rA3YwQrUQUO1Ih3471GAFuU4sTmwguVIH4i//VbDy+HasS fGvORmf9Ah+WYyIPMrU7QHIDgF+6m+1RFvTmlMj981kxPygKFX+JMAnqfIckfQlLG8R6 Bckw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=3Sw9nk0pUqlamMtDF/A1y1W0bhwmtGZsbc1p0vQcgjs=; b=dR/kHg4fXt8Q/uHU5UXEk1AO0RAoUNIyB8GF+ISRBwMIe2cKqklZNYSrG2vur1GkV6 yeyo594gCCniz9y6r66SbV/eF64NEVZ8HaIip/rtC12DvAIOfbqrvvvlCif/8S7LNpa/ bv2NAQcGQmEahtgM1AD9PKDzNr6T6z4aUCHxBwAmVVheoRPtNuuyG5mUgQNPOnm9XoaS M9YR05Bdbi8ErFDGUGPtfMl1DFOJoBvVtGfj+zIKr4TebsLtDqf5fsRubRcRNIZU9Hxk 82yCVcaX0UIxeDFaJhXIV+wbA4cE/NsNSMA2xrIFsATLSOpe2zRY64Xwa+Z4YTanAEEA dstA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="l9MCLQ8/"; 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 gu17si1527819ejb.132.2020.06.30.05.14.25; Tue, 30 Jun 2020 05:14:48 -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="l9MCLQ8/"; 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 S1733159AbgF3Lyp (ORCPT + 99 others); Tue, 30 Jun 2020 07:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729580AbgF3Lyo (ORCPT ); Tue, 30 Jun 2020 07:54:44 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2461C061755 for ; Tue, 30 Jun 2020 04:54:43 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id n23so22133116ljh.7 for ; Tue, 30 Jun 2020 04:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3Sw9nk0pUqlamMtDF/A1y1W0bhwmtGZsbc1p0vQcgjs=; b=l9MCLQ8/EyoUtHQcTzgha4HMSEo4rl5gnFrYir8oXjdQ1UOcZ7P/SkODxs7I2Zm84h 24IEnFGrGm9FW2htI690colRruwLQlBdrmyQgWSqBUVsvleTMTohZ6u5Y8OxjjwT3gOk kFFPiVDYExmK26jY38bGZ99Mnps9Ry/VZV5yi6XzMp0zEXcoX5x91jf/WPJZCFRk7/xZ arXk3GuawDZwHGWQ0e1Pi47/fVHME7zlotgUt6G6CTzPoRIBkcr1pbXaOUVFmmRjA8hD dSTQtJyjS8UA8vZNgKF1yrC0Qx/l7wuXmrDFFlH6TSD2guGJHE0TQKH1yQlQA4P/QUYi ufIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3Sw9nk0pUqlamMtDF/A1y1W0bhwmtGZsbc1p0vQcgjs=; b=H/fQgSmaNa9rkb+VBVXDfgP2e7QAgqGzNyGF8j8qxyHg2frME1TxUcy5sG41SZkOU6 WfQNyO2v1p5UX5qzwqMGlu12ubcTfJbmVm5aGNSdJtHKQao5Yi0Z4n8euue7LbKAkCgM anp30t62i9QCMI6olIPfUReuAWGYC+I/qZJYpSJ11ytu1yXA+bdP2EKeBEvMT8jR8wQu OD+nCuvsVuD99R5GQu6zyklv9a96VX8SU9IXP6zspX8bQ/eMmF9g5ZspgiQrzKYeRthd O1Z8GKOIuhmaL7sIDIT+/Y/oJHPdNTwgQyojtkiDgYWUF0HjeeG+U83HH8etCLkotSK2 85dg== X-Gm-Message-State: AOAM532/vw0t5baPNkHya+ctTL5jZWLJRd6VbcBOVBbQ9K8pPhXzdVVE 59tJv08jS4Cg7F1PQPeYjGrEALA52itMbufg/02QmdFr X-Received: by 2002:a2e:9d10:: with SMTP id t16mr10362739lji.46.1593518082232; Tue, 30 Jun 2020 04:54:42 -0700 (PDT) MIME-Version: 1.0 References: <20200625144509.17918-1-daniel.lezcano@linaro.org> <20200625144509.17918-2-daniel.lezcano@linaro.org> In-Reply-To: <20200625144509.17918-2-daniel.lezcano@linaro.org> From: Amit Kucheria Date: Tue, 30 Jun 2020 17:24:31 +0530 Message-ID: Subject: Re: [PATCH v2 2/5] thermal: core: Get thermal zone by id To: Daniel Lezcano Cc: Zhang Rui , Srinivas Pandruvada , Ram Chandrasekar , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 8:15 PM Daniel Lezcano wrote: > > 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 Reviewed-by: Amit Kucheria > --- > 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 e2f8d2550ecd..58c95aeafb7f 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -662,6 +662,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 >