8000 iio: m2k-logic-analyzer: use devm_add_action_or_reset() for disabling… · analogdevicesinc/linux@e55b829 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit e55b829

Browse files
committed
iio: m2k-logic-analyzer: use devm_add_action_or_reset() for disabling 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>
1 parent a7ab90f commit e55b829

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/iio/logic/m2k-logic-analyzer.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,14 @@ static const struct iio_buffer_setup_ops m2k_la_tx_setup_ops = {
781781
.postdisable = m2k_la_tx_postdisable,
782782
};
783783

784+
static void m2k_la_disable_clk(void *data)
785+
{
786+
struct m2k_la *m2k_la = data;
787+
788+
if (!m2k_la->powerdown)
789+
clk_disable_unprepare(m2k_la->clk);
790+
}
791+
784792
static int m2k_la_probe(struct platform_device *pdev)
785793
{
786794
struct iio_dev *indio_dev, *indio_dev_tx, *indio_dev_rx;
@@ -814,6 +822,10 @@ static int m2k_la_probe(struct platform_device *pdev)
814822

815823
m2k_la->powerdown = false;
816824

825+
ret = devm_add_action_or_reset(&pdev->dev, m2k_la_disable_clk, m2k_la);
826+
if (ret)
827+
return ret;
828+
817829
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
818830
m2k_la->regs = devm_ioremap_resource(&pdev->dev, mem);
819831
if (IS_ERR(m2k_la->regs))
@@ -883,17 +895,6 @@ static int m2k_la_probe(struct platform_device *pdev)
883895
return devm_iio_device_register(&pdev->dev, indio_dev_rx);
884896
}
885897

886-
static int m2k_la_remove(struct platform_device *pdev)
887-
{
888-
struct iio_dev *indio_dev = platform_get_drvdata(pdev);
889-
struct m2k_la *m2k_la = iio_priv(indio_dev);
890-
891-
if (!m2k_la->powerdown)
892-
clk_disable_unprepare(m2k_la->clk);
893-
894-
return 0;
895-
}
896-
897898
static const struct 6C8A of_device_id m2k_la_of_match[] = {
898899
{ .compatible = "adi,m2k-logic-analyzer" },
899900
{},
@@ -905,7 +906,6 @@ static struct platform_driver m2k_la_driver = {
905906
.of_match_table = m2k_la_of_match,
906907
},
907908
.probe = m2k_la_probe,
908-
.remove = m2k_la_remove,
909909
};
910910
module_platform_driver(m2k_la_driver);
911911

0 commit comments

Comments
 (0)
0