From patchwork Thu Apr 4 08:06:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 161754 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1293365jan; Thu, 4 Apr 2019 01:07:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCg82yxx8oH7jOLd6TAvVayNDVC2rPRNDQ15hPybuv3xPeF+BqZ+O+hEWHU06H8QEmif/i X-Received: by 2002:a17:902:7247:: with SMTP id c7mr4892609pll.255.1554365226868; Thu, 04 Apr 2019 01:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554365226; cv=none; d=google.com; s=arc-20160816; b=pXX1Ycv6rz0/wXJRN/ciMo0bXd3AzgPlwmY2tlbpJqy+SKCf9Qz4ISAa3+D/FDPAzM TMEheUvKrWMu9cF3RRhx1x1esk2l2jTBc2L2UQsi7xCr/hHWnEmaGFfIiKeT0LpE6N/7 PmMFd32trnS65QQp/JPuEdvsUcUGo0XG0j+fpR8iXsyUnFgHUMunpB5MotDDWFTPQIEx 8ScNxYJqoZSQebx+eo2v3n4IRso1mfaMBGH27LHSASr3AkvxKkfnRqsYqb5gvxnTTlIc UZLs4yM6QQaoRq+sP3kytDGzMonderuUg0gmBm5fon4vV0GaBD4wqOIhIKkt1O3jdGP5 CJOA== 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=X5EjowjeZ3lBCaiOxRkIEY3EgwtWt+4pPPGinUjsGf0=; b=ULD2CKAg15bYcVutxdxHqghQyMhiHjQWBXVat0F2BGI//3MrpyqgO9c98aS+lLN1tf 2em/SsiybjI3AKLQQ9y8viZ7MmiWc5K8t9JrdDVfTsceCGvvyqj6prqEe2ViM4harulL rnd9E9v+zcKy7D+6zE/WVA2vJpzom+Cu16fnRyN2ekgS/+OqGxLqHxIj9WgPjRteQCTM H7X9FLbzD8J1BDHrroZekP/VsiG1gzwYoB81WEfKqXWWmy91MKIJGSkgwug892lS43oU vtMswcklT8laBQARisjJzuOw80xX+v1GVt4qkqEEeoc+pAETOrTO2Bf02k55RAwaqZfP 8dGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZQ0v5O9T; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 j24si11544107pll.286.2019.04.04.01.07.06; Thu, 04 Apr 2019 01:07:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=ZQ0v5O9T; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1726530AbfDDIHG (ORCPT + 11 others); Thu, 4 Apr 2019 04:07:06 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42834 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbfDDIHF (ORCPT ); Thu, 4 Apr 2019 04:07:05 -0400 Received: by mail-pl1-f193.google.com with SMTP id cv12so758806plb.9 for ; Thu, 04 Apr 2019 01:07: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:in-reply-to:references; bh=X5EjowjeZ3lBCaiOxRkIEY3EgwtWt+4pPPGinUjsGf0=; b=ZQ0v5O9TBvpHSZWD1HXxvJy3G27safHY07lxtBzZc0TsvglUPkaCctkATHKclz9/0I DPaGgB7voUEjbPbAYR38btNBdH3SII2DxiWhNhn91DnE+ZwQkRncAwWuUpVLDI0EnQbA l5+vNtyfHgk946oXNrRbmuvjo0azGoBs9Hy/AMt/bv2MbfyenYW4urdN2jD+MrxqVmv8 pi4j8qGQ4HaN7AEFq/ubJ5+M0gyA0CX+vaDq0YpyexgM0I+a+agFFZuzzggG4Z7wqaAO xLDEFA/gOQcS2kVqsb1GnmmqvMf+OKqOwj51rxF9T6f3aBaX2jCppeqllJgwy1t31K8N wXYw== 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=X5EjowjeZ3lBCaiOxRkIEY3EgwtWt+4pPPGinUjsGf0=; b=ksnJxhv+rCOBo3fc1nB4T7tvL1f5Tsg7JYaUjS4qCO+x8IOatWvdbeTlrC+9FbK4uj n6pMPzWCX8ofaun1haTfNsykSllO1TrNUxM4QWAytD+zr/zs+SqT0hE0+ppOCDX8E32Q bhSXMwajLkPeaecZTQ9C92ihHlwEnkH8lEhzLAqTqfAVa+3CAw5gNhsY7e78zMnJQttW cJl0alsVNS4l9+9G1wjY/LK6WB9io0Rrmw0MCGqH6jfgWjFDWPYRDXBz4sjwAWPLu4D5 CM2sfwn5AptDKLZyGxT2qCIWEWE5fxxGcJT0J3xXmoQRvgXpbnEYOHoroFiQfLfNfHMM Kj6Q== X-Gm-Message-State: APjAAAUaKdKc7IBuxjTP5swG3bhNGWEh4eaoKQwliDMc15e/NFwM9jVb zHAVO0kWXQBtQFdoqt32Ev9MAg== X-Received: by 2002:a17:902:bd41:: with SMTP id b1mr4951965plx.221.1554365224645; Thu, 04 Apr 2019 01:07:04 -0700 (PDT) Received: from mai.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id x9sm32380940pfn.60.2019.04.04.01.07.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 01:07:03 -0700 (PDT) From: Daniel Lezcano To: andrew.smirnov@gmail.com Cc: linux-pm@vger.kernel.org, Zhang Rui , Eduardo Valentin , linux-kernel@vger.kernel.org (open list) Subject: [PATCH RFC 1/2] thermal/drivers/of: Add a get_temp_id callback function Date: Thu, 4 Apr 2019 10:06:46 +0200 Message-Id: <20190404080647.8173-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <00a5711b-5120-9e77-91a0-e0cbab456d92@linaro.org> References: <00a5711b-5120-9e77-91a0-e0cbab456d92@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently when we register a sensor, we specify the sensor id and a data pointer to be passed when the get_temp function is called. However the sensor_id is not passed to the get_temp callback forcing the driver to do extra allocation and adding back pointer to find out from the sensor information the driver data and then back to the sensor id. Add a new callback get_temp_id() which will be called if set. It will call the get_temp_id() with the sensor id. That will be more consistent with the registering function. Signed-off-by: Daniel Lezcano --- drivers/thermal/of-thermal.c | 19 +++++++++++++------ include/linux/thermal.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-) -- 2.17.1 Tested-by: Andrey Smirnov diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 2df059cc07e2..787d1cbe13f3 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -78,6 +78,8 @@ struct __thermal_zone { /* sensor interface */ void *sensor_data; + int sensor_id; + const struct thermal_zone_of_device_ops *ops; }; @@ -88,10 +90,14 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz, { struct __thermal_zone *data = tz->devdata; - if (!data->ops->get_temp) - return -EINVAL; + if (data->ops->get_temp) + return data->ops->get_temp(data->sensor_data, temp); - return data->ops->get_temp(data->sensor_data, temp); + if (data->ops->get_temp_id) + return data->ops->get_temp_id(data->sensor_id, + data->sensor_data, temp); + + return -EINVAL; } static int of_thermal_set_trips(struct thermal_zone_device *tz, @@ -407,8 +413,8 @@ static struct thermal_zone_device_ops of_thermal_ops = { /*** sensor API ***/ static struct thermal_zone_device * -thermal_zone_of_add_sensor(struct device_node *zone, - struct device_node *sensor, void *data, +thermal_zone_of_add_sensor(struct device_node *zone, struct device_node *sensor, + int sensor_id, void *data, const struct thermal_zone_of_device_ops *ops) { struct thermal_zone_device *tzd; @@ -426,6 +432,7 @@ thermal_zone_of_add_sensor(struct device_node *zone, mutex_lock(&tzd->lock); tz->ops = ops; tz->sensor_data = data; + tz->sensor_id = sensor_id; tzd->ops->get_temp = of_thermal_get_temp; tzd->ops->get_trend = of_thermal_get_trend; @@ -516,7 +523,7 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, } if (sensor_specs.np == sensor_np && id == sensor_id) { - tzd = thermal_zone_of_add_sensor(child, sensor_np, + tzd = thermal_zone_of_add_sensor(child, sensor_np, sensor_id, data, ops); if (!IS_ERR(tzd)) tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED); diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 5f4705f46c2f..2762d7e6dd86 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -351,6 +351,7 @@ struct thermal_genl_event { * hardware. */ struct thermal_zone_of_device_ops { + int (*get_temp_id)(int, void *, int *); int (*get_temp)(void *, int *); int (*get_trend)(void *, int, enum thermal_trend *); int (*set_trips)(void *, int, int); From patchwork Thu Apr 4 08:06:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 161755 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1293512jan; Thu, 4 Apr 2019 01:07:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT3eVuo+vGdKBb8fTebvP74Mq+T5RQQGK4DPI8VSnt0icw8h5J2kVGxC2AW2LCJudloONy X-Received: by 2002:a62:7590:: with SMTP id q138mr4425154pfc.74.1554365235145; Thu, 04 Apr 2019 01:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554365235; cv=none; d=google.com; s=arc-20160816; b=YfC4VYFbuL2vG3/V15LTwlRov9dKS8wlHKnmP5Ntl0ehjTDxr5No83f+ACzlPel0eP kaXsLNeVHYlNi1v4TOnS+JpaeWLmgp/r9wfqhdkqjK1PY/bhEiSOBw0fLgymES1fe4rc d0t0umbxzte8OIYj0GeDwMLd//qm1tqOx0k7aX927F1BtyHoeNhUbJezjLACAv/DW1eM f4EUUn6DqHydt0ElX4oJkLqT4JMC0Z2JwxCO1YyEqKxnLZqj3CicGx20b54AmAqtfSur Qk81q9KQMbMedaiBsyBZrKZkWVJsL5EF+2GEILdzMPQC8g+S+5fcGnDufMeLBP2ROcun sGOQ== 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=ibM3lHeqJzWAyx2I7VLyFgmTRoqBMjsuQ/db2mydldI=; b=yB6bI6+IUjNFf/maCaSgspyYdNfqcHu3gTHERengt84MBxy01124jef9YqQtEvjHsB t5yIhVFuByo207Ai1Yx5+yCrDz9Pra8L0FGVoBrancHu1O7ahBHOmMlNgv8+w83oWvut NEYMnpW4Keq8cV+afk7Fnv30ge9e2Ba4waglZtpa/TSgRr43FdZLW7L1e/hxJD3uMJH7 zYANZPUCNmXzkSQowHET5xsl7dy8vUzcpMpBrneKB7pfN4p8cmLcPmSMrmvC2A+VfLOr 14tBFNPHLk/48c+i/L+cnW8EkXPBwdgKGScFYT0P+2CzTgU1ucqfkizikCOcqwH566aX +lkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eZfKtX4l; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 i7si15510535plt.332.2019.04.04.01.07.14; Thu, 04 Apr 2019 01:07:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=eZfKtX4l; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1727324AbfDDIHO (ORCPT + 11 others); Thu, 4 Apr 2019 04:07:14 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39689 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726122AbfDDIHO (ORCPT ); Thu, 4 Apr 2019 04:07:14 -0400 Received: by mail-pl1-f193.google.com with SMTP id b65so766828plb.6 for ; Thu, 04 Apr 2019 01:07:13 -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=ibM3lHeqJzWAyx2I7VLyFgmTRoqBMjsuQ/db2mydldI=; b=eZfKtX4lsRpGT7pRHg5sNpC8SAp2bYdtvTa3cbXRkSl5Fc9RMIM/A2yon7YwcG9TuP TACqLqVii5l0KjdP0oTi9X/vm33eeKy805mOsXn9Rzmtd+RXB0zJNzOmIhAc0073F3CO ApknFQQbhyORoABtRDBZB1I/gG7j1DizZvuGHkxv9wZchNWH7C7GGlbYi+2ru0z97lb3 loINPYJ6ZGH5dD5XM0XvifMF4Werfk2UBAYjnT1mAxsofW8gBM3rYzeiS6BKBHoUnSnU KEYEja3yVzWB0uRjcO4C3Q7OkvkIPn7Fa8lqYA2zeVDqD34jq8b1kyDS9gmFEEal9jXI H6TA== 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=ibM3lHeqJzWAyx2I7VLyFgmTRoqBMjsuQ/db2mydldI=; b=R9xAjalb1oCw+6SXaPr0va3C1FwSy/MDzajyozRDRLB6iuSqhevNLx2u9lHBJWb0RR OPquzPWgcXCTOCOjm/9iwCp/6u1oiNxXPZDxLkskYu/4ggTZ3BkKE2RtihhJfYUaxQir rqeYcUm5LHLO/f4WCH+Q0on9NyqQIoxJC1+Z1az0RZjXy2Eh792euhtzrdgAJYigzqqP 3ZA148ALEBPGytyRd3rWoup0C0mF04DFfVelw0kaGeGfveUdMj0iVfV50KJ7hDZtyiL1 Dxah6IoBp2DagKNfbnbQsrJoBAwgAejDrzG/ms241bKLF0WRkFBW+KpOFVaXcxiVKZak hAIA== X-Gm-Message-State: APjAAAWTbtYVVv89uqgB+ocfHETOPfcHGZmqxK4nXS7Y1QdUSfT8lfaI Ywby0ErKLJYm9wD2iLlb3cokyg== X-Received: by 2002:a17:902:7885:: with SMTP id q5mr5043893pll.12.1554365233446; Thu, 04 Apr 2019 01:07:13 -0700 (PDT) Received: from mai.imgcgcw.net ([147.50.13.10]) by smtp.gmail.com with ESMTPSA id x9sm32380940pfn.60.2019.04.04.01.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 01:07:12 -0700 (PDT) From: Daniel Lezcano To: andrew.smirnov@gmail.com Cc: linux-pm@vger.kernel.org, Zhang Rui , Eduardo Valentin , linux-kernel@vger.kernel.org (open list) Subject: [PATCH RFC 2/2] thermal/drivers/qoriq: Use the get_temp_id() Date: Thu, 4 Apr 2019 10:06:47 +0200 Message-Id: <20190404080647.8173-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190404080647.8173-1-daniel.lezcano@linaro.org> References: <00a5711b-5120-9e77-91a0-e0cbab456d92@linaro.org> <20190404080647.8173-1-daniel.lezcano@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Currently the code is adding extra back pointer to find out the general structure for the driver from the sensor data. Use the get_temp_id() which pass the sensor id when registering the callback. Signed-off-by: Daniel Lezcano --- drivers/thermal/qoriq_thermal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/thermal/qoriq_thermal.c b/drivers/thermal/qoriq_thermal.c index 3b5f5b3fb1bc..405d1fbdd0cb 100644 --- a/drivers/thermal/qoriq_thermal.c +++ b/drivers/thermal/qoriq_thermal.c @@ -92,20 +92,20 @@ static u32 tmu_read(struct qoriq_tmu_data *p, void __iomem *addr) return ioread32be(addr); } -static int tmu_get_temp(void *p, int *temp) +static int tmu_get_temp(int id, void *p, int *temp) { struct qoriq_sensor *qsensor = p; struct qoriq_tmu_data *qdata = qsensor->qdata; u32 val; - val = tmu_read(qdata, &qdata->regs->site[qsensor->id].tritsr); + val = tmu_read(qdata, &qdata->regs->site[id].tritsr); *temp = (val & 0xff) * 1000; return 0; } static const struct thermal_zone_of_device_ops tmu_tz_ops = { - .get_temp = tmu_get_temp, + .get_temp_id = tmu_get_temp, }; static int qoriq_tmu_register_tmu_zone(struct platform_device *pdev)