Skip to content

Commit

Permalink
iio: m2k-logic-analyzer: use devm_add_action_or_reset() for disabling…
Browse files Browse the repository at this point in the history
… clock

This change moves the clock disable (on error or reset) on the
devm_add_action_or_reset() logic/helper.

That way, the clock is disabled if there is an error during probe, and the
remove callback can be removed.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
  • Loading branch information
commodo committed Mar 27, 2020
1 parent a7ab90f commit e55b829
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions drivers/iio/logic/m2k-logic-analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,14 @@ static const struct iio_buffer_setup_ops m2k_la_tx_setup_ops = {
.postdisable = m2k_la_tx_postdisable,
};

static void m2k_la_disable_clk(void *data)
{
struct m2k_la *m2k_la = data;

if (!m2k_la->powerdown)
clk_disable_unprepare(m2k_la->clk);
}

static int m2k_la_probe(struct platform_device *pdev)
{
struct iio_dev *indio_dev, *indio_dev_tx, *indio_dev_rx;
Expand Down Expand Up @@ -814,6 +822,10 @@ static int m2k_la_probe(struct platform_device *pdev)

m2k_la->powerdown = false;

ret = devm_add_action_or_reset(&pdev->dev, m2k_la_disable_clk, m2k_la);
if (ret)
return ret;

mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
m2k_la->regs = devm_ioremap_resource(&pdev->dev, mem);
if (IS_ERR(m2k_la->regs))
Expand Down Expand Up @@ -883,17 +895,6 @@ static int m2k_la_probe(struct platform_device *pdev)
return devm_iio_device_register(&pdev->dev, indio_dev_rx);
}

static int m2k_la_remove(struct platform_device *pdev)
{
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
struct m2k_la *m2k_la = iio_priv(indio_dev);

if (!m2k_la->powerdown)
clk_disable_unprepare(m2k_la->clk);

return 0;
}

static const struct of_device_id m2k_la_of_match[] = {
{ .compatible = "adi,m2k-logic-analyzer" },
{},
Expand All @@ -905,7 +906,6 @@ static struct platform_driver m2k_la_driver = {
.of_match_table = m2k_la_of_match,
},
.probe = m2k_la_probe,
.remove = m2k_la_remove,
};
module_platform_driver(m2k_la_driver);

Expand Down

0 comments on commit e55b829

Please sign in to comment.