Counter fixes for 6.12

Fix device_node handling in stm32-timer-cnt by calling required
 of_node_put() after device node is no longer needed. Check and handle
 clk_enable() failures in stm32-timer-cnt and ti-ecap-capture.
 
 Signed-off-by: William Breathitt Gray <wbg@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQSNN83d4NIlKPjon7a1SFbKvhIjKwUCZyxlnwAKCRC1SFbKvhIj
 K9ZqAQD+qKOSu2VajfKZRhT7MZJSm4TXCPIELVBrjMs8iFBfPgD8DW+sdTBlm3tp
 XegnQW/cEqLskpD8/O3WBYuin69AFQ4=
 =GF8Q
 -----END PGP SIGNATURE-----

Merge tag 'counter-fixes-for-6.12' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter into char-misc-next

William writes:

Counter fixes for 6.12

Fix device_node handling in stm32-timer-cnt by calling required
of_node_put() after device node is no longer needed. Check and handle
clk_enable() failures in stm32-timer-cnt and ti-ecap-capture.

Signed-off-by: William Breathitt Gray <wbg@kernel.org>

* tag 'counter-fixes-for-6.12' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/wbg/counter:
  counter: ti-ecap-capture: Add check for clk_enable()
  counter: stm32-timer-cnt: Add check for clk_enable()
  counter: stm32-timer-cnt: fix device_node handling in probe_encoder()
This commit is contained in:
Greg Kroah-Hartman 2024-11-07 08:25:08 +01:00
commit a32a8057af
2 changed files with 20 additions and 4 deletions

View File

@ -214,11 +214,17 @@ static int stm32_count_enable_write(struct counter_device *counter,
{
struct stm32_timer_cnt *const priv = counter_priv(counter);
u32 cr1;
int ret;
if (enable) {
regmap_read(priv->regmap, TIM_CR1, &cr1);
if (!(cr1 & TIM_CR1_CEN))
clk_enable(priv->clk);
if (!(cr1 & TIM_CR1_CEN)) {
ret = clk_enable(priv->clk);
if (ret) {
dev_err(counter->parent, "Cannot enable clock %d\n", ret);
return ret;
}
}
regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN,
TIM_CR1_CEN);
@ -694,6 +700,7 @@ static int stm32_timer_cnt_probe_encoder(struct device *dev,
}
ret = of_property_read_u32(tnode, "reg", &idx);
of_node_put(tnode);
if (ret) {
dev_err(dev, "Can't get index (%d)\n", ret);
return ret;
@ -816,7 +823,11 @@ static int __maybe_unused stm32_timer_cnt_resume(struct device *dev)
return ret;
if (priv->enabled) {
clk_enable(priv->clk);
ret = clk_enable(priv->clk);
if (ret) {
dev_err(dev, "Cannot enable clock %d\n", ret);
return ret;
}
/* Restore registers that may have been lost */
regmap_write(priv->regmap, TIM_SMCR, priv->bak.smcr);

View File

@ -574,8 +574,13 @@ static int ecap_cnt_resume(struct device *dev)
{
struct counter_device *counter_dev = dev_get_drvdata(dev);
struct ecap_cnt_dev *ecap_dev = counter_priv(counter_dev);
int ret;
clk_enable(ecap_dev->clk);
ret = clk_enable(ecap_dev->clk);
if (ret) {
dev_err(dev, "Cannot enable clock %d\n", ret);
return ret;
}
ecap_cnt_capture_set_evmode(counter_dev, ecap_dev->pm_ctx.ev_mode);