Skip to content

Commit

Permalink
thermal: rcar_thermal: remove redundant operation
Browse files Browse the repository at this point in the history
Probe error operation and remove operation are same.
Let's use same function.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
  • Loading branch information
Kuninori Morimoto authored and Eduardo Valentin committed Nov 16, 2015
1 parent 2852498 commit 84f0e49
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions drivers/thermal/rcar_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,24 @@ static irqreturn_t rcar_thermal_irq(int irq, void *data)
/*
* platform functions
*/
static int rcar_thermal_remove(struct platform_device *pdev)
{
struct rcar_thermal_common *common = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
struct rcar_thermal_priv *priv;

rcar_thermal_for_each_priv(priv, common) {
if (rcar_has_irq_support(priv))
rcar_thermal_irq_disable(priv);
thermal_zone_device_unregister(priv->zone);
}

pm_runtime_put(dev);
pm_runtime_disable(dev);

return 0;
}

static int rcar_thermal_probe(struct platform_device *pdev)
{
struct rcar_thermal_common *common;
Expand All @@ -377,6 +395,8 @@ static int rcar_thermal_probe(struct platform_device *pdev)
if (!common)
return -ENOMEM;

platform_set_drvdata(pdev, common);

INIT_LIST_HEAD(&common->head);
spin_lock_init(&common->lock);
common->dev = dev;
Expand Down Expand Up @@ -454,43 +474,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
rcar_thermal_common_write(common, ENR, enr_bits);
}

platform_set_drvdata(pdev, common);

dev_info(dev, "%d sensor probed\n", i);

return 0;

error_unregister:
rcar_thermal_for_each_priv(priv, common) {
if (rcar_has_irq_support(priv))
rcar_thermal_irq_disable(priv);
thermal_zone_device_unregister(priv->zone);
}

pm_runtime_put(dev);
pm_runtime_disable(dev);
rcar_thermal_remove(pdev);

return ret;
}

static int rcar_thermal_remove(struct platform_device *pdev)
{
struct rcar_thermal_common *common = platform_get_drvdata(pdev);
struct device *dev = &pdev->dev;
struct rcar_thermal_priv *priv;

rcar_thermal_for_each_priv(priv, common) {
if (rcar_has_irq_support(priv))
rcar_thermal_irq_disable(priv);
thermal_zone_device_unregister(priv->zone);
}

pm_runtime_put(dev);
pm_runtime_disable(dev);

return 0;
}

static const struct of_device_id rcar_thermal_dt_ids[] = {
{ .compatible = "renesas,rcar-thermal", },
{},
Expand Down

0 comments on commit 84f0e49

Please sign in to comment.