OSDN Git Service

drivers: thermal: tsens: Simplify code flow in tsens_probe
authorAmit Kucheria <amit.kucheria@linaro.org>
Thu, 31 Oct 2019 18:37:26 +0000 (00:07 +0530)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Thu, 7 Nov 2019 06:00:26 +0000 (07:00 +0100)
Move platform_set_drvdata up to avoid an extra 'if (ret)' check after
the call to tsens_register.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/184422dcc1c12553e71a58c62e01425fd7d1172a.1572526427.git.amit.kucheria@linaro.org
drivers/thermal/qcom/tsens.c

index 6ed687a..542a7f8 100644 (file)
@@ -149,6 +149,8 @@ static int tsens_probe(struct platform_device *pdev)
        priv->feat = data->feat;
        priv->fields = data->fields;
 
+       platform_set_drvdata(pdev, priv);
+
        if (!priv->ops || !priv->ops->init || !priv->ops->get_temp)
                return -EINVAL;
 
@@ -167,11 +169,7 @@ static int tsens_probe(struct platform_device *pdev)
                }
        }
 
-       ret = tsens_register(priv);
-
-       platform_set_drvdata(pdev, priv);
-
-       return ret;
+       return tsens_register(priv);
 }
 
 static int tsens_remove(struct platform_device *pdev)