Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2098333ybc; Wed, 20 Nov 2019 08:53:30 -0800 (PST) X-Google-Smtp-Source: APXvYqzQJLL9Gmo9q8PzeHFWnyaVAyPmPaRlmW7bYsZqtZ96+n4IdwHkYh4neJ2Rh5pTZQNje4ly X-Received: by 2002:a17:906:600b:: with SMTP id o11mr6380172ejj.175.1574268809947; Wed, 20 Nov 2019 08:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574268809; cv=none; d=google.com; s=arc-20160816; b=qGAZY4jQjyzbs/QJ7xZ8wXQnIY23NrN/fdYCFLYL+rpqOzDCgzdApP6mvxcysoFtfs yM3CIrTU1/h1RcszvRCZp3pwRJDGc+DK3y25diKQ98WEYwZxOZp7iRjFhjciYtPZ4qqs WtdA34svapXJFcU/X0hV0DzI859/mTebDBVFTjpo6aHdrRRYqHpLuhHrQBeqVswlKnqA WBCynPn/aOisvcoILp5rMYMzzCip3HA0EQCslDIo6YuJCCiAzbN9iHv9ziL9zhXMyyPk RFsaMww4mK1sFZkBGWvwvJbzpd4gFIdDVynNwQOeDZBMNZ9xGisxAbP4s79QliL66ABv lwpw== 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=wtD/eNE9TAmXsnR2IF1O0WWLLWtlBArf0uI74fbpZrc=; b=BzKwFs6JOG57g7HVrZ99RGBm6yVH4CEoXjUGNpr9ko0y4Fu4quLcTpaHnqADee2se1 +fUuIYNZ0jEFaksBzyGo7K4gmzL9qNnrMjVch/g9tpoTTXMilMCMKqProCOh7AvyMdsk Sc2R6QLVtmyESPpIEgNVqeG7QZGxK0pgl+il0irLWvOG7oy6n4pVJQOTViN8U34KAP8/ saOd2et+zWYjeNw5vCHmJo7fmVrPa0BdBtAFE7qDd8Km47TE9taQOCrAnmIWNNDhniW1 h4UNmZSuLHf2Opa0cc0y+TvzRnIjp26fJyH2dhmvTKtoMgA7Zk+dSxR9AmUApVAxIc/d vMTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I6Y1ofWc; 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 w21si16277067eja.324.2019.11.20.08.53.04; Wed, 20 Nov 2019 08:53:29 -0800 (PST) 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=I6Y1ofWc; 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 S1729977AbfKTM4w (ORCPT + 99 others); Wed, 20 Nov 2019 07:56:52 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:38181 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729969AbfKTM4v (ORCPT ); Wed, 20 Nov 2019 07:56:51 -0500 Received: by mail-qv1-f67.google.com with SMTP id q19so9631170qvs.5 for ; Wed, 20 Nov 2019 04:56:50 -0800 (PST) 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=wtD/eNE9TAmXsnR2IF1O0WWLLWtlBArf0uI74fbpZrc=; b=I6Y1ofWcZLyq/uKNmdCCl9/kv6h14tQOGMfF99XIcPBr2zXYHDnctewepPWDp45hWX 34HWqvhN/ZLdDC4eL2yFrqN4yMwpNuPs2gY325lwOdWhGvbVEWeInv79vO8V8BfpLlkX 9JEpTyJJiI9ai+op+ZgJtoCD6l2BW8uOj5m+SZi84oFxc+s1N36WSISTqqDbSR4SkY6a tfA/Vovqqcwynhv5sqOdWM5nYh3U1PpHaSsYTvrcJq1FDcTgw41q2YDf8j/3KvRSqifa WQPZ9h2Zo2akBqX6c5sZPSkQ1wzwlOGpsiC5eE8v458CijsaEqC1+rSHLeM+GfHVRbN1 vovg== 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=wtD/eNE9TAmXsnR2IF1O0WWLLWtlBArf0uI74fbpZrc=; b=A8h6E9xEnwdylTJp7iGR/QXe5DzMRd64KgZeNraB+bAAtX2DwFb3+h5VAfhMGo/g7a bEmZHGc+KWBhWlzAwn8FeyU5PUlr2f7XthRXcEaev1H+BODgLB11niGQOL8OaobYl+gZ V9Iq0SsBSMoBBCsIewY508I17XK0ozCzV23AJWBBcbM8XhwkZkTURu/bWbpENoUc3J1O ALaIcbU4aGFV4rmH7qcLQAPkO2oNHq0yso90z5A96zxp9+6Ed7a3kwfaM+839ty/Dy8w nhZTma5JNlzI9P+J8lJs1SnyHGaiLEWZFpYT/Q4MnZsymjVnWwy4OeojewDmw1xaS9RF DaSQ== X-Gm-Message-State: APjAAAXaEvJvGAHhQqGdMW+5sYLi/jn2vrgK/O8P7C0B1bwdx0/6skx8 J9G7sEzrbvWfMSLLeaN/Qz26yw== X-Received: by 2002:ad4:404e:: with SMTP id r14mr2428885qvp.4.1574254609837; Wed, 20 Nov 2019 04:56:49 -0800 (PST) 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 r2sm14109637qtc.28.2019.11.20.04.56.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Nov 2019 04:56:48 -0800 (PST) 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 v4 3/7] thermal: core: Allow cooling devices to register a parent. Date: Wed, 20 Nov 2019 07:56:29 -0500 Message-Id: <1574254593-16078-4-git-send-email-thara.gopinath@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1574254593-16078-1-git-send-email-thara.gopinath@linaro.org> References: <1574254593-16078-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 With introduction of power domain warming devices, devices that control the power domain are registered as the parent of the cooling device so that the device-genpd hierarchy in kernel is maintained intact. To enable this, introduce a new API thermal_of_cooling_device_parent_register that takes a parent device pointer as input. Also, modify __thermal_cooling_device_register to register parent of a newly created cooling device, if specified. Signed-off-by: Thara Gopinath --- drivers/thermal/thermal_core.c | 22 +++++++++++++++++++--- include/linux/thermal.h | 15 +++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d4481cc..912ba75 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -947,6 +947,7 @@ static void bind_cdev(struct thermal_cooling_device *cdev) */ static struct thermal_cooling_device * __thermal_cooling_device_register(struct device_node *np, + struct device *parent, const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { @@ -979,6 +980,8 @@ __thermal_cooling_device_register(struct device_node *np, cdev->ops = ops; cdev->updated = false; cdev->device.class = &thermal_class; + if (parent) + cdev->device.parent = parent; cdev->devdata = devdata; thermal_cooling_device_setup_sysfs(cdev); dev_set_name(&cdev->device, "cooling_device%d", cdev->id); @@ -1024,7 +1027,8 @@ struct thermal_cooling_device * thermal_cooling_device_register(const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { - return __thermal_cooling_device_register(NULL, type, devdata, ops); + return __thermal_cooling_device_register(NULL, NULL, type, + devdata, ops); } EXPORT_SYMBOL_GPL(thermal_cooling_device_register); @@ -1048,10 +1052,22 @@ thermal_of_cooling_device_register(struct device_node *np, const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { - return __thermal_cooling_device_register(np, type, devdata, ops); + return __thermal_cooling_device_register(np, NULL, type, devdata, ops); } EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register); +struct thermal_cooling_device * +thermal_of_cooling_device_parent_register(struct device_node *np, + struct device *parent, + const char *type, void *devdata, + const struct + thermal_cooling_device_ops *ops) +{ + return __thermal_cooling_device_register(np, parent, type, + devdata, ops); +} +EXPORT_SYMBOL_GPL(thermal_of_cooling_device_parent_register); + static void thermal_cooling_device_release(struct device *dev, void *res) { thermal_cooling_device_unregister( @@ -1088,7 +1104,7 @@ devm_thermal_of_cooling_device_register(struct device *dev, if (!ptr) return ERR_PTR(-ENOMEM); - tcd = __thermal_cooling_device_register(np, type, devdata, ops); + tcd = __thermal_cooling_device_register(np, NULL, type, devdata, ops); if (IS_ERR(tcd)) { devres_free(ptr); return tcd; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index e45659c..ac5f268 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -448,6 +448,11 @@ struct thermal_cooling_device * thermal_of_cooling_device_register(struct device_node *np, const char *, void *, const struct thermal_cooling_device_ops *); struct thermal_cooling_device * +thermal_of_cooling_device_parent_register(struct device_node *np, + struct device *parent, + const char *, void *, const struct + thermal_cooling_device_ops *); +struct thermal_cooling_device * devm_thermal_of_cooling_device_register(struct device *dev, struct device_node *np, char *type, void *devdata, @@ -508,6 +513,16 @@ static inline struct thermal_cooling_device * thermal_of_cooling_device_register(struct device_node *np, char *type, void *devdata, const struct thermal_cooling_device_ops *ops) { return ERR_PTR(-ENODEV); } + +static inline struct thermal_cooling_device * +thermal_of_cooling_device_parent_register(struct device_node *np, + struct device *parent, + const char *, void *, const struct + thermal_cooling_device_ops *) +{ + return ERR_PTR(-ENODEV); +} + static inline struct thermal_cooling_device * devm_thermal_of_cooling_device_register(struct device *dev, struct device_node *np, -- 2.1.4