Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: pata_imx: Use helper function devm_clk_get_enabled()

After the commit 7ef9651e9792 ("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>

authored by

Li Zetao and committed by
Damien Le Moal
0e1bd497 caea9589

+7 -21
+7 -21
drivers/ata/pata_imx.c
··· 141 141 if (!priv) 142 142 return -ENOMEM; 143 143 144 - priv->clk = devm_clk_get(&pdev->dev, NULL); 144 + priv->clk = devm_clk_get_enabled(&pdev->dev, NULL); 145 145 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"); 147 147 return PTR_ERR(priv->clk); 148 148 } 149 149 150 - ret = clk_prepare_enable(priv->clk); 151 - if (ret) 152 - return ret; 153 - 154 150 host = ata_host_alloc(&pdev->dev, 1); 155 - if (!host) { 156 - ret = -ENOMEM; 157 - goto err; 158 - } 151 + if (!host) 152 + return -ENOMEM; 159 153 160 154 host->private_data = priv; 161 155 ap = host->ports[0]; ··· 159 165 ap->flags |= ATA_FLAG_SLAVE_POSS; 160 166 161 167 priv->host_regs = devm_platform_get_and_ioremap_resource(pdev, 0, &io_res); 162 - if (IS_ERR(priv->host_regs)) { 163 - ret = PTR_ERR(priv->host_regs); 164 - goto err; 165 - } 168 + if (IS_ERR(priv->host_regs)) 169 + return PTR_ERR(priv->host_regs); 166 170 167 171 ap->ioaddr.cmd_addr = priv->host_regs + PATA_IMX_DRIVE_DATA; 168 172 ap->ioaddr.ctl_addr = priv->host_regs + PATA_IMX_DRIVE_CONTROL; ··· 186 194 &pata_imx_sht); 187 195 188 196 if (ret) 189 - goto err; 197 + return ret; 190 198 191 199 return 0; 192 - err: 193 - clk_disable_unprepare(priv->clk); 194 - 195 - return ret; 196 200 } 197 201 198 202 static void pata_imx_remove(struct platform_device *pdev) ··· 199 211 ata_host_detach(host); 200 212 201 213 __raw_writel(0, priv->host_regs + PATA_IMX_ATA_INT_EN); 202 - 203 - clk_disable_unprepare(priv->clk); 204 214 } 205 215 206 216 #ifdef CONFIG_PM_SLEEP