Skip to content

Commit

Permalink
drivers: thermal: tsens: Save reference to the device pointer and use it
Browse files Browse the repository at this point in the history
Code cleanup making it easier to read

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
  • Loading branch information
Amit Kucheria authored and Eduardo Valentin committed May 14, 2019
1 parent c199705 commit 52eafd6
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/thermal/qcom/tsens-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ static const struct regmap_config tsens_srot_config = {
int __init init_common(struct tsens_priv *priv)
{
void __iomem *tm_base, *srot_base;
struct device *dev = priv->dev;
struct resource *res;
u32 enabled;
int ret, i, j;
Expand All @@ -137,7 +138,7 @@ int __init init_common(struct tsens_priv *priv)
goto err_put_device;
}

priv->srot_map = devm_regmap_init_mmio(priv->dev, srot_base,
priv->srot_map = devm_regmap_init_mmio(dev, srot_base,
&tsens_srot_config);
if (IS_ERR(priv->srot_map)) {
ret = PTR_ERR(priv->srot_map);
Expand All @@ -155,13 +156,13 @@ int __init init_common(struct tsens_priv *priv)
goto err_put_device;
}

priv->tm_map = devm_regmap_init_mmio(priv->dev, tm_base, &tsens_config);
priv->tm_map = devm_regmap_init_mmio(dev, tm_base, &tsens_config);
if (IS_ERR(priv->tm_map)) {
ret = PTR_ERR(priv->tm_map);
goto err_put_device;
}

priv->rf[TSENS_EN] = devm_regmap_field_alloc(priv->dev, priv->srot_map,
priv->rf[TSENS_EN] = devm_regmap_field_alloc(dev, priv->srot_map,
priv->fields[TSENS_EN]);
if (IS_ERR(priv->rf[TSENS_EN])) {
ret = PTR_ERR(priv->rf[TSENS_EN]);
Expand All @@ -171,28 +172,28 @@ int __init init_common(struct tsens_priv *priv)
if (ret)
goto err_put_device;
if (!enabled) {
dev_err(priv->dev, "tsens device is not enabled\n");
dev_err(dev, "tsens device is not enabled\n");
ret = -ENODEV;
goto err_put_device;
}

priv->rf[SENSOR_EN] = devm_regmap_field_alloc(priv->dev, priv->srot_map,
priv->rf[SENSOR_EN] = devm_regmap_field_alloc(dev, priv->srot_map,
priv->fields[SENSOR_EN]);
if (IS_ERR(priv->rf[SENSOR_EN])) {
ret = PTR_ERR(priv->rf[SENSOR_EN]);
goto err_put_device;
}
/* now alloc regmap_fields in tm_map */
for (i = 0, j = LAST_TEMP_0; i < priv->num_sensors; i++, j++) {
priv->rf[j] = devm_regmap_field_alloc(priv->dev, priv->tm_map,
priv->rf[j] = devm_regmap_field_alloc(dev, priv->tm_map,
priv->fields[j]);
if (IS_ERR(priv->rf[j])) {
ret = PTR_ERR(priv->rf[j]);
goto err_put_device;
}
}
for (i = 0, j = VALID_0; i < priv->num_sensors; i++, j++) {
priv->rf[j] = devm_regmap_field_alloc(priv->dev, priv->tm_map,
priv->rf[j] = devm_regmap_field_alloc(dev, priv->tm_map,
priv->fields[j]);
if (IS_ERR(priv->rf[j])) {
ret = PTR_ERR(priv->rf[j]);
Expand Down

0 comments on commit 52eafd6

Please sign in to comment.