Skip to content

Commit 0e1bd49

Browse files
Li Zetaodamien-lemoal
authored andcommitted
ata: pata_imx: Use helper function devm_clk_get_enabled()
After the commit 7ef9651 ("clk: Provide new devm_clk helpers for prepared and enabled clocks"), the pair of functions devm_clk_get() and clk_prepare_enable() can be replaced with the single function devm_clk_get_enabled(). Moreover, the driver will keep the clock prepared (or enabled) during the whole lifetime of the device, so it is unnecessary to unprepare and disable the clock explicitly when removing the device or in the error handling path. Signed-off-by: Li Zetao <lizetao1@huawei.com> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
1 parent caea958 commit 0e1bd49

1 file changed

Lines changed: 7 additions & 21 deletions

File tree

drivers/ata/pata_imx.c

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -141,21 +141,15 @@ static int pata_imx_probe(struct platform_device *pdev)
141141
if (!priv)
142142
return -ENOMEM;
143143

144-
priv->clk = devm_clk_get(&pdev->dev, NULL);
144+
priv->clk = devm_clk_get_enabled(&pdev->dev, NULL);
145145
if (IS_ERR(priv->clk)) {
146-
dev_err(&pdev->dev, "Failed to get clock\n");
146+
dev_err(&pdev->dev, "Failed to get and enable clock\n");
147147
return PTR_ERR(priv->clk);
148148
}
149149

150-
ret = clk_prepare_enable(priv->clk);
151-
if (ret)
152-
return ret;
153-
154150
host = ata_host_alloc(&pdev->dev, 1);
155-
if (!host) {
156-
ret = -ENOMEM;
157-
goto err;
158-
}
151+
if (!host)
152+
return -ENOMEM;
159153

160154
host->private_data = priv;
161155
ap = host->ports[0];
@@ -165,10 +159,8 @@ static int pata_imx_probe(struct platform_device *pdev)
165159
ap->flags |= ATA_FLAG_SLAVE_POSS;
166160

167161
priv->host_regs = devm_platform_get_and_ioremap_resource(pdev, 0, &io_res);
168-
if (IS_ERR(priv->host_regs)) {
169-
ret = PTR_ERR(priv->host_regs);
170-
goto err;
171-
}
162+
if (IS_ERR(priv->host_regs))
163+
return PTR_ERR(priv->host_regs);
172164

173165
ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA;
174166
ap->ioaddr.ctl_addr = priv->host_regs + PATA_IMX_DRIVE_CONTROL;
@@ -194,13 +186,9 @@ static int pata_imx_probe(struct platform_device *pdev)
194186
&pata_imx_sht);
195187

196188
if (ret)
197-
goto err;
189+
return ret;
198190

199191
return 0;
200-
err:
201-
clk_disable_unprepare(priv->clk);
202-
203-
return ret;
204192
}
205193

206194
static void pata_imx_remove(struct platform_device *pdev)
@@ -211,8 +199,6 @@ static void pata_imx_remove(struct platform_device *pdev)
211199
ata_host_detach(host);
212200

213201
__raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN);
214-
215-
clk_disable_unprepare(priv->clk);
216202
}
217203

218204
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)