Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp154211ybl; Fri, 16 Aug 2019 21:08:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqz78kIXxLbBYY4oZINJbvvF6u0LarnB+/pRyPkoZixpkxT1gd+DevFvzLbCHBhR3y//gPzo X-Received: by 2002:a17:902:aa93:: with SMTP id d19mr12597386plr.148.1566014905275; Fri, 16 Aug 2019 21:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566014905; cv=none; d=google.com; s=arc-20160816; b=X/1f7pn/btyPcO/GO0MhbeqkFCxLq3eOjiezvSmAhicq2L/P5sGRD+GoHWQIXlmunQ +xUT5lBq5/0ezg14YWZ1dt1PNxPShrX/4B2hJjcGUi2NwH+5LhxhCXb5+Rukn2Rr2PDX v3OAoxIjcoorSrMIdNVXRYsfqkm+fGDtnbP03ekG841rdvdkhqxdceXFRKlZM/Pq4rPl Qcko7ZGXlShOZKvbWmlf7+2LG6dhuL8C2HeXrIiIGIpCkHKayLL7FS69v076VBz+vvk6 TOrGzM7sZr5gzkYPR3/MLLYVYBpzNbVN+c7scohP/R+r/NSOhU7RBecEyULyq6Fghbh+ HeMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:user-agent:to:cc:from:subject :references:in-reply-to:content-transfer-encoding:mime-version :message-id:dkim-signature; bh=1HgC5/QNAOHXCXC2GEYSZ/KGai77GKdH3Ngn3CXwIzc=; b=Sf+1+5WeZMlIkfMWz1U8Bq3NVzCrS/bZ2Szd5XmsN/De0jondNZAxw40OBarvpWIAN pfKkyB9fS5JpcqjwbL4XRN6xTQqhNO00Q4ceK4+fjlk3XZci1dtCPsyJY/2dpxu4w7NB w8b3virLki1V9ZQq3HjM80b2JnZxalHtUGhnTSHuKmS2vq8sp+iG0zYOOKtOMSYqbCYV MYjkM9l+nFFPRVniuvD01AJUszhU4FJsEsS5hMYWLUdWxEMcR/Oyb4N3Wyjrwyxl3Vw+ mGQKH3M34Zb1sK5RWX/EkYTrROSAhfl/PlT5tMtR6t7srKrWddPw/cq03OJegVu5pNZy 5p3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VPQQT7J3; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4si5120685pgf.470.2019.08.16.21.08.10; Fri, 16 Aug 2019 21:08: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=@chromium.org header.s=google header.b=VPQQT7J3; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725832AbfHQEHV (ORCPT + 99 others); Sat, 17 Aug 2019 00:07:21 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46540 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbfHQEHV (ORCPT ); Sat, 17 Aug 2019 00:07:21 -0400 Received: by mail-pf1-f195.google.com with SMTP id q139so4090349pfc.13 for ; Fri, 16 Aug 2019 21:07:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=message-id:mime-version:content-transfer-encoding:in-reply-to :references:subject:from:cc:to:user-agent:date; bh=1HgC5/QNAOHXCXC2GEYSZ/KGai77GKdH3Ngn3CXwIzc=; b=VPQQT7J3PEmdCd3GM/xLhIDrESV9wDUf3xiB3hUTDuucsu1hmkhVyE9M1GllFjqdck dv/tV00ZiIWa4reQQbxhLFnt/wxQkqVaYZycgOvlyNLpc/VhProajbVUCh9Imtt9N1Ir nNj66Vh1q8ib47FRZ9hwmcQUSKesHnhINywlQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:in-reply-to:references:subject:from:cc:to :user-agent:date; bh=1HgC5/QNAOHXCXC2GEYSZ/KGai77GKdH3Ngn3CXwIzc=; b=W6JSj+0oXIZ2agWAC0BoSCp7mbOhsDslplVVqb7Kb1XqdZ9PDGzZx9K152KSTg3yJ6 yKzHIHXQXLsW4XjVTP6DQW8v+f+x2hAbUyRKMUajLfz7m3bpzeoADi0u5jYQISMYmxdx D3FFD2Mgows8Yv/lN0K00J9o6u9TVmV8s2oKMUt2dYm60VhPJc6IzRLnZ8LKh/uWnZg+ NlRyfAIIPkN6s6sxbK6W5uSQ6tJDfsRJedRd+vnR2hMS0q3ubGECJWbRU7QpN3MnKcaD LcfJbGjLI+lG++VKY8onLHOJCfjVyR5EZIa66jehh4O8DFdtBq678Sy4FOiuzWSvSZXq b3qw== X-Gm-Message-State: APjAAAU3cQNDAVpjVw4vnlu9T6RTqJt8QYZiS3oPitl04MIwMeozADFi sEx3EqCsMLogf33GprQ6IqazqA== X-Received: by 2002:a05:6a00:cd:: with SMTP id e13mr14540751pfj.202.1566014840127; Fri, 16 Aug 2019 21:07:20 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id h197sm8195139pfe.67.2019.08.16.21.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2019 21:07:19 -0700 (PDT) Message-ID: <5d577d77.1c69fb81.b6b07.83e6@mx.google.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <534b5017c2210ba8d541c206dace204d6617b4c9.1564091601.git.amit.kucheria@linaro.org> References: <534b5017c2210ba8d541c206dace204d6617b4c9.1564091601.git.amit.kucheria@linaro.org> Subject: Re: [PATCH 04/15] drivers: thermal: tsens: Add debugfs support From: Stephen Boyd Cc: linux-pm@vger.kernel.org To: Amit Kucheria , Andy Gross , Daniel Lezcano , Mark Rutland , Rob Herring , Zhang Rui , andy.gross@linaro.org, bjorn.andersson@linaro.org, edubezval@gmail.com, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org User-Agent: alot/0.8.1 Date: Fri, 16 Aug 2019 21:07:18 -0700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Amit Kucheria (2019-07-25 15:18:39) > Dump some basic version info and sensor details into debugfs >=20 Maybe you can put some sample output in the commit text. > 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(+) >=20 > diff --git a/drivers/thermal/qcom/tsens-common.c b/drivers/thermal/qcom/t= sens-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. > */ > =20 > +#include > #include > #include > #include > @@ -139,6 +140,79 @@ int get_temp_common(struct tsens_sensor *s, int *tem= p) > return 0; > } > =20 > +#ifdef CONFIG_DEBUG_FS > +static int dbg_sensors_show(struct seq_file *s, void *data) > +{ > + struct platform_device *pdev =3D s->private; > + struct tsens_priv *priv =3D 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 =3D 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? > + 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 =3D s->private; > + struct tsens_priv *priv =3D platform_get_drvdata(pdev); > + u32 maj_ver, min_ver, step_ver; > + int ret; > + > + if (tsens_ver(priv) > VER_0_1) { > + ret =3D regmap_field_read(priv->rf[VER_MAJOR], &maj_ver); > + if (ret) > + return ret; > + ret =3D regmap_field_read(priv->rf[VER_MINOR], &min_ver); > + if (ret) > + return ret; > + ret =3D 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 =3D platform_get_drvdata(pdev); > + struct dentry *root, *file; > + > + root =3D debugfs_lookup("tsens", NULL); Does this get created many times? Why doesn't tsens have a pointer to the root saved away somewhere globally? > + if (!root) > + priv->debug_root =3D debugfs_create_dir("tsens", NULL); > + else > + priv->debug_root =3D root; > + > + file =3D 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 =3D debugfs_create_dir(dev_name(&pdev->dev), priv->de= bug_root); > + debugfs_create_file("sensors", 0444, priv->debug, pdev, &dbg_sens= ors_fops); > + > + return; > +}