Message ID | 20210926134237.23863-1-dmitry.baryshkov@linaro.org |
---|---|
State | New |
Headers | show |
Series | [v2,1/2] thermal: qcom: tsens: remove data indirection in the debugfs | expand |
Hi Dimitry, Thanks for the patch On 9/26/21 9:42 AM, Dmitry Baryshkov wrote: > There is no reason to pass platform device to debugfs just to get the > tsens_priv from it. Not to mention that for TSENS_V0 the platform device > (gcc) might have other device data. Pass the tsens_priv data to debugfs > callbacks directly. > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- > drivers/thermal/qcom/tsens.c | 17 +++++++---------- > 1 file changed, 7 insertions(+), 10 deletions(-) > > diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c > index 4c7ebd1d3f9c..6aeea74c1bb0 100644 > --- a/drivers/thermal/qcom/tsens.c > +++ b/drivers/thermal/qcom/tsens.c > @@ -657,8 +657,7 @@ int get_temp_common(const struct tsens_sensor *s, int *temp) > #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); > + struct tsens_priv *priv = s->private; > int i; > > seq_printf(s, "max: %2d\nnum: %2d\n\n", > @@ -675,8 +674,7 @@ static int dbg_sensors_show(struct seq_file *s, void *data) > > 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); > + struct tsens_priv *priv = s->private; > u32 maj_ver, min_ver, step_ver; > int ret; > > @@ -701,9 +699,8 @@ static int dbg_version_show(struct seq_file *s, void *data) > DEFINE_SHOW_ATTRIBUTE(dbg_version); > DEFINE_SHOW_ATTRIBUTE(dbg_sensors); > > -static void tsens_debug_init(struct platform_device *pdev) > +static void tsens_debug_init(struct platform_device *pdev, struct tsens_priv *priv) You anyways have to pass pdev here, as it is used for referencing dev name below. So drop sending tsens_priv as well. You can get it via platform_get_drvdata as in the original code. I am okay with the change in using priv instead of pdev as private pointer in the fops. > { > - struct tsens_priv *priv = platform_get_drvdata(pdev); > struct dentry *root, *file; > > root = debugfs_lookup("tsens", NULL); > @@ -715,14 +712,14 @@ static void tsens_debug_init(struct platform_device *pdev) > file = debugfs_lookup("version", priv->debug_root); > if (!file) > debugfs_create_file("version", 0444, priv->debug_root, > - pdev, &dbg_version_fops); > + priv, &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); > + debugfs_create_file("sensors", 0444, priv->debug, priv, &dbg_sensors_fops); > } > #else > -static inline void tsens_debug_init(struct platform_device *pdev) {} > +static inline void tsens_debug_init(struct platform_device *pdev, struct tsens_priv *priv) {} > #endif > > static const struct regmap_config tsens_config = { > @@ -918,7 +915,7 @@ int __init init_common(struct tsens_priv *priv) > if (tsens_version(priv) >= VER_0_1) > tsens_enable_irq(priv); > > - tsens_debug_init(op); > + tsens_debug_init(op, priv); > > err_put_device: > put_device(&op->dev); > -- Warm Regards Thara (She/Her/Hers)
On 9/26/21 9:42 AM, Dmitry Baryshkov wrote: > For VER_0 tsens shares the device with the clock controller, but > nevertheless it does not use syscon for these registers. Drop > syscon_node_to_regmap() and acquire the regmap on our own. > > apq8064 has tsens as a part of gcc device tree node, ipq8064 puts tsens > node as a child node of gcc. Thus check whether tsens resource can be > fetched either from the device itself or from it's parent. > > Fixes: 53e2a20e4c41 ("thermal/drivers/tsens: Add VER_0 tsens version") > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Acked-by: Thara Gopinath <thara.gopinath@linaro.org> -- Warm Regards Thara (She/Her/Hers) > --- > drivers/thermal/qcom/tsens.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c > index 6aeea74c1bb0..bc0c86a54fe7 100644 > --- a/drivers/thermal/qcom/tsens.c > +++ b/drivers/thermal/qcom/tsens.c > @@ -12,7 +12,6 @@ > #include <linux/of.h> > #include <linux/of_address.h> > #include <linux/of_platform.h> > -#include <linux/mfd/syscon.h> > #include <linux/platform_device.h> > #include <linux/pm.h> > #include <linux/regmap.h> > @@ -773,19 +772,19 @@ int __init init_common(struct tsens_priv *priv) > if (tsens_version(priv) >= VER_0_1) { > res = platform_get_resource(op, IORESOURCE_MEM, 0); > tm_base = devm_ioremap_resource(dev, res); > - if (IS_ERR(tm_base)) { > - ret = PTR_ERR(tm_base); > - goto err_put_device; > - } > - > - priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); > - } else { /* VER_0 share the same gcc regs using a syscon */ > - struct device *parent = priv->dev->parent; > + } else { /* VER_0 share the same gcc regs. It can be either the same device, or parent */ > + res = platform_get_resource(op, IORESOURCE_MEM, 0); > + if (!res && dev_is_platform(priv->dev->parent)) > + res = platform_get_resource(to_platform_device(priv->dev->parent), IORESOURCE_MEM, 0); > + tm_base = devm_ioremap(dev, res->start, resource_size(res)); > + } > > - if (parent) > - priv->tm_map = syscon_node_to_regmap(parent->of_node); > + if (IS_ERR(tm_base)) { > + ret = PTR_ERR(tm_base); > + goto err_put_device; > } > > + priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config); > if (IS_ERR_OR_NULL(priv->tm_map)) { > if (!priv->tm_map) > ret = -ENODEV; >
diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c index 4c7ebd1d3f9c..6aeea74c1bb0 100644 --- a/drivers/thermal/qcom/tsens.c +++ b/drivers/thermal/qcom/tsens.c @@ -657,8 +657,7 @@ int get_temp_common(const struct tsens_sensor *s, int *temp) #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); + struct tsens_priv *priv = s->private; int i; seq_printf(s, "max: %2d\nnum: %2d\n\n", @@ -675,8 +674,7 @@ static int dbg_sensors_show(struct seq_file *s, void *data) 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); + struct tsens_priv *priv = s->private; u32 maj_ver, min_ver, step_ver; int ret; @@ -701,9 +699,8 @@ static int dbg_version_show(struct seq_file *s, void *data) DEFINE_SHOW_ATTRIBUTE(dbg_version); DEFINE_SHOW_ATTRIBUTE(dbg_sensors); -static void tsens_debug_init(struct platform_device *pdev) +static void tsens_debug_init(struct platform_device *pdev, struct tsens_priv *priv) { - struct tsens_priv *priv = platform_get_drvdata(pdev); struct dentry *root, *file; root = debugfs_lookup("tsens", NULL); @@ -715,14 +712,14 @@ static void tsens_debug_init(struct platform_device *pdev) file = debugfs_lookup("version", priv->debug_root); if (!file) debugfs_create_file("version", 0444, priv->debug_root, - pdev, &dbg_version_fops); + priv, &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); + debugfs_create_file("sensors", 0444, priv->debug, priv, &dbg_sensors_fops); } #else -static inline void tsens_debug_init(struct platform_device *pdev) {} +static inline void tsens_debug_init(struct platform_device *pdev, struct tsens_priv *priv) {} #endif static const struct regmap_config tsens_config = { @@ -918,7 +915,7 @@ int __init init_common(struct tsens_priv *priv) if (tsens_version(priv) >= VER_0_1) tsens_enable_irq(priv); - tsens_debug_init(op); + tsens_debug_init(op, priv); err_put_device: put_device(&op->dev);
There is no reason to pass platform device to debugfs just to get the tsens_priv from it. Not to mention that for TSENS_V0 the platform device (gcc) might have other device data. Pass the tsens_priv data to debugfs callbacks directly. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- drivers/thermal/qcom/tsens.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) -- 2.30.2