Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp942624ybp; Thu, 17 Oct 2019 05:58:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRprnfTC5Eer/hp3B7e5txdMYqciwjIqZr6CUZiNEBR9FWhNoIrzYRbZ9Nld3DnCw1Xs4X X-Received: by 2002:a05:6402:160f:: with SMTP id f15mr3592988edv.142.1571317105797; Thu, 17 Oct 2019 05:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571317105; cv=none; d=google.com; s=arc-20160816; b=JVw+T7cluFtTJAP2o1ZIY4tIx/OzFOzsCYY/UP+fCnxU8e8Vslx3bXvH2/6BGw2GcM d98lYHkgIOl3fpJXy0aDPB2jB3eZq7J4vBf+ZsfQH+DhwgmIFhXk8QGUTI6f/SHn4EkO 2LzOICqngaGAzud6UcK+o70bsz8kzRf5W8pOcGMGHlHbNZ98QfSnpi7fJjt4dZGkfhmY e4nKb/3gEimNmwqpkp32bpr1AgBRXaZ9rsB0vkNXWYNHsCPPFywYdbpWfiJpDiQZLvLL CfwDTmz3s4QwxugPg2X7LVkrtJuT6rR7Fy3nNy4HDTokbAP+dY0PYdP1SInGH/Wzoz3o g/og== 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=SEzzpxn6TNoCaJjNnbG2b9pO7Zr0jWolxxLkxLULV5c=; b=v8KdmhWW/n0Ckb4QVQn0jhaY69Eu4IcNBdDC9zzJfsn+K2x73sQdzGeWLt6r8XE/mo Pjccw8Ikqvt6tcop+kslNUZsC6eDg2lAiA8XZ0xoACdplMf75xv9iLEWSyki7EucsBUA +iY/RgsXuBDNZcrkoQJ6xgoXlggLSHjvjF863AnCIBDm2AJVq5W2AyQz+zxPwM+f9uUe 9BaLsYQ6OoVFwzLBg/v4HrhvpkTqEsRYqkfQF86grBPsxqEPqRwjtAmjy1uiUugnTJrw EGZMVmjm7o9s4UIh6mFGNue35ISuK+oUl3hAdI/qJrYjr2k2+7Mvs6yaUs7Y+Rkt9JDR izSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jtg46D18; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id j21si1355782eja.5.2019.10.17.05.58.02; Thu, 17 Oct 2019 05:58:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=jtg46D18; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2394479AbfJPThg (ORCPT + 99 others); Wed, 16 Oct 2019 15:37:36 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:37055 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394464AbfJPThf (ORCPT ); Wed, 16 Oct 2019 15:37:35 -0400 Received: by mail-qk1-f194.google.com with SMTP id u184so23930281qkd.4 for ; Wed, 16 Oct 2019 12:37:33 -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=SEzzpxn6TNoCaJjNnbG2b9pO7Zr0jWolxxLkxLULV5c=; b=jtg46D18bjGRyC40A5rJir1izsa/p65sPjSA6mfWjUIbPAwgAbDKZuoyK3S88fFVaw kuXOvBRiVr3prI14Wzpr879D32cekWxy2DfL9VOQ2S1SIbB3nvPiazNqIlkKepocZ5DZ laBNkiMBhlGk+kgT37dsdeInOu+lArHA3YkDS712pXc2v6jeK71o8l1wuztqj+wqCoPV sZ8vQS0SqkAK3789qvJtMJMZOLtTFDvdKIED6p38HeakzS1elUEavpdgF1ZXo8k0oXoa afIKOcKef7hh8Skn3Qb5TDFs2mP8t+6bBhJf0iEclk9Rstsq7HuNJh9zdbn/QS/T/ieW VIjg== 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=SEzzpxn6TNoCaJjNnbG2b9pO7Zr0jWolxxLkxLULV5c=; b=Y6GimNf/eOyx0U874MDNVa+uCSvpZJ4Be+2CjWYpygk0xLJwEtO8fz8aCX8Q7sF65g pllMv4ynKmVw0vE/JsYip0huqdpp7+WMzQsDPDD+Bmx98Yp7n3yXxUaUx7qKTYgLIXHc bRms/t3C0+PKbroW0uLDFVSC1tOmupWPM9Wh4mB7BXedb5r55EkgpgUJQ7RGPexVLGAh rJOyaq/G+q83O2jIQ7/twPdfBlsAvqpDlUXoyUMg32PThQODlBilnvFmfDCE11Fmco5f 9SHNB2NZ3AJfpqPuLY2k9M4IWSJPNuBCy5CMWRkQmlIPpNGuO1OiG+5XTg+gSLI1Ce6o OWuQ== X-Gm-Message-State: APjAAAXbl/uBYSZngXweML2i6Gg71tM8e+b2cVlYQlIs0OjjjBB5P7DO i8pRSPDzlfgEx+pMhK+6IWzdIg== X-Received: by 2002:a37:f70f:: with SMTP id q15mr39409920qkj.428.1571254652961; Wed, 16 Oct 2019 12:37:32 -0700 (PDT) Received: from Thara-Work-Ubuntu.fios-router.home (pool-71-255-246-27.washdc.fios.verizon.net. [71.255.246.27]) by smtp.googlemail.com with ESMTPSA id 54sm16246030qts.75.2019.10.16.12.37.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Oct 2019 12:37:32 -0700 (PDT) From: Thara Gopinath To: edubezval@gmail.com, rui.zhang@intel.com, ulf.hansson@linaro.org, daniel.lezcano@linaro.org, bjorn.andersson@linaro.org, agross@kernel.org Cc: amit.kucheria@verdurent.com, mark.rutland@arm.com, rjw@rjwysocki.net, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/7] thermal: core: Add late init hook to cooling device ops Date: Wed, 16 Oct 2019 15:37:17 -0400 Message-Id: <1571254641-13626-4-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1571254641-13626-1-git-send-email-thara.gopinath@linaro.org> References: <1571254641-13626-1-git-send-email-thara.gopinath@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a hook in thermal_cooling_device_ops to be called after the cooling device has been initialized and registered but before binding it to a thermal zone. In this patch series it is used to hook up a power domain to the device pointer of cooling device. It can be used for any other relevant late initializations of a cooling device as well. Signed-off-by: Thara Gopinath --- drivers/thermal/thermal_core.c | 13 +++++++++++++ include/linux/thermal.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 886e8fa..c2ecb73 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -994,6 +994,19 @@ __thermal_cooling_device_register(struct device_node *np, list_add(&cdev->node, &thermal_cdev_list); mutex_unlock(&thermal_list_lock); + /* Call into cdev late initialization if defined */ + if (cdev->ops->late_init) { + result = cdev->ops->late_init(cdev); + if (result) { + ida_simple_remove(&thermal_cdev_ida, cdev->id); + put_device(&cdev->device); + mutex_lock(&thermal_list_lock); + list_del(&cdev->node); + mutex_unlock(&thermal_list_lock); + return ERR_PTR(result); + } + } + /* Update binding information for 'this' new cdev */ bind_cdev(cdev); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e45659c..e94b3de 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -125,6 +125,7 @@ struct thermal_cooling_device_ops { struct thermal_zone_device *, unsigned long, u32 *); int (*power2state)(struct thermal_cooling_device *, struct thermal_zone_device *, u32, unsigned long *); + int (*late_init)(struct thermal_cooling_device *); }; struct thermal_cooling_device { -- 2.1.4