[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5d577d77.1c69fb81.b6b07.83e6@mx.google.com>
Date: Fri, 16 Aug 2019 21:07:18 -0700
From: Stephen Boyd <swboyd@...omium.org>
To: Amit Kucheria <amit.kucheria@...aro.org>,
Andy Gross <agross@...nel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Mark Rutland <mark.rutland@....com>,
Rob Herring <robh+dt@...nel.org>,
Zhang Rui <rui.zhang@...el.com>, andy.gross@...aro.org,
bjorn.andersson@...aro.org, edubezval@...il.com,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: linux-pm@...r.kernel.org
Subject: Re: [PATCH 04/15] drivers: thermal: tsens: Add debugfs support
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.
> Signed-off-by: Amit Kucheria <amit.kucheria@...aro.org>
> ---
> 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 <linux/debugfs.h>
> #include <linux/err.h>
> #include <linux/io.h>
> #include <linux/nvmem-consumer.h>
> @@ -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?
> + 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?
> + 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;
> +}
Powered by blists - more mailing lists