Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2387482ybl; Mon, 19 Aug 2019 00:59:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1Y3zj50r9vFvgLfqpp/VopjvlOR8GPycdeddxwpK1yMAhCeuDk90pq0dUvu0x+BWso7B9 X-Received: by 2002:a17:90a:e392:: with SMTP id b18mr18831416pjz.140.1566201595153; Mon, 19 Aug 2019 00:59:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566201595; cv=none; d=google.com; s=arc-20160816; b=S2Lt5XewQBklzjEhY8e+YW6CZYuf83SVJgAGaFetlBAqHCnMJK+xy5doX8v8fcrM34 g0GzW+e88Ozu6ld1k4Vh8x/PVzYfLQfnU0WmJbDxzPj66pLD11K+3D8wKNJJ0YgVrJN9 hEfFaLaFLHEEIUfgbvXWnh6Uh5JKVw3uWpKX78Nt/2jUNExLHHLN5XXCe8WIDm8BPdSN IFMDNCqSsvyr51Tx6PEVS/jIan5ppH7LnBLQeHh4B4qD4GuHq46YEkfgffJemr0a86nP 6IpRBAHFKnTg7uZE2RmzMDztyYgCKX5gC0qNxhu1789GqtO+EIzhsjRqRgLOrJzMmlkR NCjQ== 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=9FY2ZK8jbTU1ozDDRr8vUXsHqK4aXnekG9ru1GMfhss=; b=ysZzilAx6XkNVG1sO+npzQONky4BRS+VcdoXeyphRXAvxPbLK/XqdaAx0HXlSX8LXf WWCstBY3UnXsKLHy+DTk55OBfu/5+lVZgx5DyHRbS3Ptm13nTo9loHiGAy2aFgiBF+VS eEn/o8iIvZ76e113h6Oz0e93GaGLpZniIrvY+HZoJ0DZOzqtfNUGHGEzx3tA6RwcTVv6 F/KPlp/SF8Pu/KjVrxkLfc61pUCTNA5RcJhyb/MGunUIUMnyAZGXqle1rc73g2M2MLNJ AQuc0rZPDv6FApaK2uE1+OUXzUWUq6TqscajI9cY56qznykb/QnpE7JqHpgciwICa7sI 2Aog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Uyh+uiK8; 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 2si8238866pgj.349.2019.08.19.00.59.40; Mon, 19 Aug 2019 00:59:55 -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=Uyh+uiK8; 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 S1726961AbfHSH6g (ORCPT + 99 others); Mon, 19 Aug 2019 03:58:36 -0400 Received: from mail-vs1-f66.google.com ([209.85.217.66]:39551 "EHLO mail-vs1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726867AbfHSH6f (ORCPT ); Mon, 19 Aug 2019 03:58:35 -0400 Received: by mail-vs1-f66.google.com with SMTP id y62so595303vsb.6 for ; Mon, 19 Aug 2019 00:58:35 -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=9FY2ZK8jbTU1ozDDRr8vUXsHqK4aXnekG9ru1GMfhss=; b=Uyh+uiK8JClxk5NbW6qP4yg7djHjjtMS5906hdZ2wcI9WsqK7bhIsA2KGUdHiMavvS MEk6YuncME4pW8B+5dX1MLBVL837L7fZdzZsXCKMmQDffEsZrZdbtVJILnUoUFbwzbyU PbaNQH4YhAxb8u15DvaYs7Pyu2c/HvgEhP/qT0eRbyT8R9OiYLJNk2nBF4kf3s2CnEUC urhgnaoKmLq9/Vv19XcizK6eAv6rvWMRDF27CrK32gk9k5cUYAMJXF4vM/Izb7yqbL89 UBxRSTKBhwNtQWSvoQhfv427fgcq7pU0vUB+rHD/eA36vvmdyzPcjijbgGC09vRxdN3r RXnA== 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=9FY2ZK8jbTU1ozDDRr8vUXsHqK4aXnekG9ru1GMfhss=; b=WO3Hz00TXJ+3lSTYoIeXSTayCZN7pt3G9VUbYIeQ9VWC9Ac26gcM0BU615gBgGjgbK r1ni/hiOtE28ysEddTu5MQM9TlqC7ZnbwaK8e0K6df8JvaogIa57Eyig52bvm4Cuwp2/ DrHfxU+ao6tA+BdhAEQsCtYZBCpr4TUTdy+kbL2JkZmp3EUL+wK4SEIkBf8paWuNFC6c umZhbZ1yOxGPaNP9myUSw/ZMUrEmeroqYnSQnjVN3VzPodha2Bms37qsMLhEaesYJaxz Sd7rm7F8dXvrmfYPNO1hmh8HFyyclWhe2oOsfnLJgXeRBQqrJS5c3T+oh8DN3atrDeXw i34g== X-Gm-Message-State: APjAAAVk+f5383JkG+jHmSzfwA6hOLisOADJ8ab/03wdwdXmYf7qpbVK /A/Smpr10jz6wli42ABurSvILSHgxhS/E9I5VqRumQ== X-Received: by 2002:a05:6102:7d5:: with SMTP id y21mr13140149vsg.9.1566201514268; Mon, 19 Aug 2019 00:58:34 -0700 (PDT) MIME-Version: 1.0 References: <534b5017c2210ba8d541c206dace204d6617b4c9.1564091601.git.amit.kucheria@linaro.org> <5d577d77.1c69fb81.b6b07.83e6@mx.google.com> In-Reply-To: <5d577d77.1c69fb81.b6b07.83e6@mx.google.com> From: Amit Kucheria Date: Mon, 19 Aug 2019 13:28:23 +0530 Message-ID: Subject: Re: [PATCH 04/15] drivers: thermal: tsens: Add debugfs support To: Stephen Boyd Cc: Andy Gross , Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui , Andy Gross , Bjorn Andersson , Eduardo Valentin , linux-arm-msm , LKML , Linux PM 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 Sat, Aug 17, 2019 at 9:37 AM Stephen Boyd wrote: > > Quoting Amit Kucheria (2019-07-25 15:18:39) > > Dump some basic version info and sensor details into debugfs > > > > Maybe you can put some sample output in the commit text. Will do. > > Signed-off-by: Amit Kucheria > > --- > > drivers/thermal/qcom/tsens-common.c | 85 +++++++++++++++++++++++++++++ > > drivers/thermal/qcom/tsens.c | 2 + > > drivers/thermal/qcom/tsens.h | 6 ++ > > 3 files changed, 93 insertions(+) > > > > diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/tsens-common.c > > index 7437bfe196e5..7ab2e740a1da 100644 > > --- a/drivers/thermal/qcom/tsens-common.c > > +++ b/drivers/thermal/qcom/tsens-common.c > > @@ -3,6 +3,7 @@ > > * Copyright (c) 2015, The Linux Foundation. All rights reserved. > > */ > > > > +#include > > #include > > #include > > #include > > @@ -139,6 +140,79 @@ int get_temp_common(struct tsens_sensor *s, int *temp) > > return 0; > > } > > > > +#ifdef CONFIG_DEBUG_FS > > +static int dbg_sensors_show(struct seq_file *s, void *data) > > +{ > > + struct platform_device *pdev = s->private; > > + struct tsens_priv *priv = platform_get_drvdata(pdev); > > + int i; > > + > > + seq_printf(s, "max: %2d\nnum: %2d\n\n", > > + priv->feat->max_sensors, priv->num_sensors); > > + > > + seq_puts(s, " id slope offset\n------------------------\n"); > > + for (i = 0; i < priv->num_sensors; i++) { > > + seq_printf(s, "%8d%8d%8d\n", priv->sensor[i].hw_id, > > Does this not have spaces between the digits on purpose? Nice catch. The 8-char width above hid the problem. Will add. > > + priv->sensor[i].slope, priv->sensor[i].offset); > > + } > > + > > + return 0; > > +} > > + > > +static int dbg_version_show(struct seq_file *s, void *data) > > +{ > > + struct platform_device *pdev = s->private; > > + struct tsens_priv *priv = platform_get_drvdata(pdev); > > + u32 maj_ver, min_ver, step_ver; > > + int ret; > > + > > + if (tsens_ver(priv) > VER_0_1) { > > + ret = regmap_field_read(priv->rf[VER_MAJOR], &maj_ver); > > + if (ret) > > + return ret; > > + ret = regmap_field_read(priv->rf[VER_MINOR], &min_ver); > > + if (ret) > > + return ret; > > + ret = regmap_field_read(priv->rf[VER_STEP], &step_ver); > > + if (ret) > > + return ret; > > + seq_printf(s, "%d.%d.%d\n", maj_ver, min_ver, step_ver); > > + } else { > > + seq_puts(s, "0.1.0\n"); > > + } > > + > > + return 0; > > +} > > + > > +DEFINE_SHOW_ATTRIBUTE(dbg_version); > > +DEFINE_SHOW_ATTRIBUTE(dbg_sensors); > > + > > +static void tsens_debug_init(struct platform_device *pdev) > > +{ > > + struct tsens_priv *priv = platform_get_drvdata(pdev); > > + struct dentry *root, *file; > > + > > + root = debugfs_lookup("tsens", NULL); > > Does this get created many times? Why doesn't tsens have a pointer to > the root saved away somewhere globally? > I guess we could call the statement below to create the root dir and save away the pointer. I was trying to avoid #ifdef CONFIG_DEBUG_FS in init_common() and instead have all of it in a single function that gets called once per instance of the tsens controller. > > + if (!root) > > + priv->debug_root = debugfs_create_dir("tsens", NULL); > > + else > > + priv->debug_root = root; > > + > > + file = debugfs_lookup("version", priv->debug_root); > > + if (!file) > > + debugfs_create_file("version", 0444, priv->debug_root, > > + pdev, &dbg_version_fops); > > + > > + /* A directory for each instance of the TSENS IP */ > > + priv->debug = debugfs_create_dir(dev_name(&pdev->dev), priv->debug_root); > > + debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sensors_fops); > > + > > + return; > > +}