mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2024-12-28 16:53:49 +00:00
clk: lmk04832: Use devm_clk_get_enabled() helpers
The devm_clk_get_enabled() helpers: - call devm_clk_get() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the calls to clk_disable_unprepare(). Signed-off-by: Huan Yang <link@vivo.com> Link: https://lore.kernel.org/r/20240820102119.130298-1-link@vivo.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
parent
1b2ed9df08
commit
f7e41b65bd
@ -1405,16 +1405,12 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
|
||||
lmk->dev = &spi->dev;
|
||||
|
||||
lmk->oscin = devm_clk_get(lmk->dev, "oscin");
|
||||
lmk->oscin = devm_clk_get_enabled(lmk->dev, "oscin");
|
||||
if (IS_ERR(lmk->oscin)) {
|
||||
dev_err(lmk->dev, "failed to get oscin clock\n");
|
||||
return PTR_ERR(lmk->oscin);
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(lmk->oscin);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
lmk->reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset",
|
||||
GPIOD_OUT_LOW);
|
||||
|
||||
@ -1422,14 +1418,14 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
sizeof(struct lmk_dclk), GFP_KERNEL);
|
||||
if (!lmk->dclk) {
|
||||
ret = -ENOMEM;
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
lmk->clkout = devm_kcalloc(lmk->dev, info->num_channels,
|
||||
sizeof(*lmk->clkout), GFP_KERNEL);
|
||||
if (!lmk->clkout) {
|
||||
ret = -ENOMEM;
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
lmk->clk_data = devm_kzalloc(lmk->dev, struct_size(lmk->clk_data, hws,
|
||||
@ -1437,7 +1433,7 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
GFP_KERNEL);
|
||||
if (!lmk->clk_data) {
|
||||
ret = -ENOMEM;
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
device_property_read_u32(lmk->dev, "ti,vco-hz", &lmk->vco_rate);
|
||||
@ -1465,7 +1461,7 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
dev_err(lmk->dev, "missing reg property in child: %s\n",
|
||||
child->full_name);
|
||||
of_node_put(child);
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
of_property_read_u32(child, "ti,clkout-fmt",
|
||||
@ -1486,7 +1482,7 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
|
||||
__func__, PTR_ERR(lmk->regmap));
|
||||
ret = PTR_ERR(lmk->regmap);
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
regmap_write(lmk->regmap, LMK04832_REG_RST3W, LMK04832_BIT_RESET);
|
||||
@ -1496,7 +1492,7 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
&rdbk_pin);
|
||||
ret = lmk04832_set_spi_rdbk(lmk, rdbk_pin);
|
||||
if (ret)
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
regmap_bulk_read(lmk->regmap, LMK04832_REG_ID_PROD_MSB, &tmp, 3);
|
||||
@ -1504,13 +1500,13 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
dev_err(lmk->dev, "unsupported device type: pid 0x%04x, maskrev 0x%02x\n",
|
||||
tmp[0] << 8 | tmp[1], tmp[2]);
|
||||
ret = -EINVAL;
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = lmk04832_register_vco(lmk);
|
||||
if (ret) {
|
||||
dev_err(lmk->dev, "failed to init device clock path\n");
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (lmk->vco_rate) {
|
||||
@ -1518,21 +1514,21 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
ret = clk_set_rate(lmk->vco.clk, lmk->vco_rate);
|
||||
if (ret) {
|
||||
dev_err(lmk->dev, "failed to set VCO rate\n");
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = lmk04832_register_sclk(lmk);
|
||||
if (ret) {
|
||||
dev_err(lmk->dev, "failed to init SYNC/SYSREF clock path\n");
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < info->num_channels; i++) {
|
||||
ret = lmk04832_register_clkout(lmk, i);
|
||||
if (ret) {
|
||||
dev_err(lmk->dev, "failed to register clk %d\n", i);
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1541,24 +1537,12 @@ static int lmk04832_probe(struct spi_device *spi)
|
||||
lmk->clk_data);
|
||||
if (ret) {
|
||||
dev_err(lmk->dev, "failed to add provider (%d)\n", ret);
|
||||
goto err_disable_oscin;
|
||||
return ret;
|
||||
}
|
||||
|
||||
spi_set_drvdata(spi, lmk);
|
||||
|
||||
return 0;
|
||||
|
||||
err_disable_oscin:
|
||||
clk_disable_unprepare(lmk->oscin);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void lmk04832_remove(struct spi_device *spi)
|
||||
{
|
||||
struct lmk04832 *lmk = spi_get_drvdata(spi);
|
||||
|
||||
clk_disable_unprepare(lmk->oscin);
|
||||
}
|
||||
|
||||
static const struct spi_device_id lmk04832_id[] = {
|
||||
@ -1579,7 +1563,6 @@ static struct spi_driver lmk04832_driver = {
|
||||
.of_match_table = lmk04832_of_id,
|
||||
},
|
||||
.probe = lmk04832_probe,
|
||||
.remove = lmk04832_remove,
|
||||
.id_table = lmk04832_id,
|
||||
};
|
||||
module_spi_driver(lmk04832_driver);
|
||||
|
Loading…
Reference in New Issue
Block a user