]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
iio: adc: npcm: fix unbalanced clk_disable_unprepare()
authorDavid Carlier <devnexen@gmail.com>
Tue, 14 Apr 2026 12:30:06 +0000 (13:30 +0100)
committerJonathan Cameron <jic23@kernel.org>
Tue, 28 Apr 2026 15:36:09 +0000 (16:36 +0100)
commit0d42e2c0bd6ceb89e44c6e065f9bdf9b1df3ef0c
treeaf47b9af0f077153667ef0112d4e0035c37fef5b
parent7e5c0f97c66ad538b87c04a640573371fb434b4f
iio: adc: npcm: fix unbalanced clk_disable_unprepare()

The driver acquired the ADC clock with devm_clk_get() and read its
rate, but never called clk_prepare_enable(). The probe error path and
npcm_adc_remove() both called clk_disable_unprepare() unconditionally,
causing the clk framework's enable/prepare counts to underflow on
probe failure or module unbind.

The issue went unnoticed because NPCM BMC firmware leaves the ADC
clock enabled at boot, so the driver happened to work in practice.

Switch to devm_clk_get_enabled() so the clock is properly enabled
during probe and automatically released by the device-managed
cleanup, and drop the now-redundant clk_disable_unprepare() from
both the probe error path and remove().

While at it, drop the duplicate error message on devm_request_irq()
failure since the IRQ core already logs it.

Fixes: 9bf85fbc9d8f ("iio: adc: add NPCM ADC driver")
Signed-off-by: David Carlier <devnexen@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/adc/npcm_adc.c