Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4765042pxj; Wed, 12 May 2021 12:45:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnCAXn6rgCHUDxfysWzQDHNXHJkED2bfJJ/PI++yWDidHQTzVatLf81T6ZgUMdnc0Ipmam X-Received: by 2002:a05:6830:4a4:: with SMTP id l4mr18859978otd.194.1620848718104; Wed, 12 May 2021 12:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620848718; cv=none; d=google.com; s=arc-20160816; b=tNkIf2xW8wom7hRJU7FscbMsLgEIz2jjKYVCl5XNjfhDF8hI9SayESVNb+JdlJDT5u G/k0MtXMYBQGcPCHNWhs1kTUDJmGS6S9WY6qDOJXja1L/9Kf8iWgfcpV08MMWUqR6FT6 lYFytfqNm7s6cRbUxjaJjf7yyHlTtBiyPx7l/NpdtprV9RcDW39Ig0r6bieFx3S3LGtn 8a7BqJekRHG5u/wPIdQVKWWG1yBsk9EQqhDhpo/6bDrM3KMpTbWoxVgEWInBUTtgkSfo V0qmCbZAI4H6Dqt5d/F5NwUQHqO/BGHdro2mlnUsRXv8cGVgIt7nxHPMTYlj1Z4R5VEY WJxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nkXARO+FVrewyUKtJO4CN2s0umqdJR4fAYNaOAsTCV0=; b=jZkcaXSB4PPIymiCG7nyPd+aBSun3dZ7tVYjp+URLEh7DNsiCjo//UqmQ3FQ598V5d /f12nBlnMmn/C/3jSfjRZgVf7lKIbzA3bXciNjEqdTBqIE7wID6fya7G5pgLsjq+FmzX 7+CVldB+8CVWCNoH8+fhnN/dwcj7zIkVncraiEah9UbMCkUKPEil25LVKuPlkk+2ECbF TbuJx6dM5TDUm9Za1ogTU8Hupyfj0YF7Kk7GkE1X7xe4bNDw1o1VS7QvdEarQqryQm89 Q0dz4NZpB6ZnDTowajpcnL5W+EWvWhHCtZOtJrHCM1NVSN7U4pJ4HktnkdFbvL7mXQoG PoMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b="SYDiblT/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si768815otu.223.2021.05.12.12.45.00; Wed, 12 May 2021 12:45:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b="SYDiblT/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381823AbhELTfX (ORCPT + 99 others); Wed, 12 May 2021 15:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350523AbhELRvL (ORCPT ); Wed, 12 May 2021 13:51:11 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D2BC06138D for ; Wed, 12 May 2021 10:50:00 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id w3so36272216ejc.4 for ; Wed, 12 May 2021 10:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nkXARO+FVrewyUKtJO4CN2s0umqdJR4fAYNaOAsTCV0=; b=SYDiblT/FKbuA+P5DtK7LLEjtQVRy9buQ9rlNnDPTNyrJ6fCURA7APFNkba9LrMETA cp3y5kAVDg7FK34ik232iLoQpAG5Vp1LMM0FdeDtuaNFTN+91XFonJ9BJZWNrqPEGgPa h6sV98fIZv24fN/XvrB0Zl5JgWBVZ/c4dc9RYJsSoQQwzbnJnrKMF67YsAoTvYTGUFf8 8fwD+RyHyj1pUkVk0vJC6sT4gB2u3ZhkssdBvugnvV2eK955YM7zcrQ5hJsHYwpHNaXy 3ieX3bz92AFTz9y6vERaW/F6Sgc8Ba31m5jd1csiSZupR98LhBfDBDUd/dSSY+l7zwQU EoJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nkXARO+FVrewyUKtJO4CN2s0umqdJR4fAYNaOAsTCV0=; b=QYWdIobV3j6BrWWS9L0gpoZyo1MN6A/txpy2xPn3pzduYOTmJm8GYNixWC8wMQujFI yW5vNCawzqXfXy9I14k9G3yS21dGNGu3QDBdSlHg0PiJpCDv0SWEefBH4lVgmAOlRBuR Ua/kC9CfnXdElSi+6AP1FNsSaccGn8ZFOlSWGjtp9xrKE1lOVrBhMenvIypu4kx/o9jP A9IidAfi4GQlsHdjvPbg0C9IPEGdBl9dg1dwTntCvIaCgK1bruf5RPUs+bR3fEi3R6s/ nAfKO868eKuG3ZTBeW4WqWoenkACEzOde0+jN/r4o718isRCjcZYo9I7fyVglHQjvaij a9+A== X-Gm-Message-State: AOAM532B+Us3wEXBkYIxHyE3kvNqctmUdHe9Kxs48FIFVIiYurMl5dfV hfePxPGWWKsJmVv2I9mV1CtuIw== X-Received: by 2002:a17:906:d978:: with SMTP id rp24mr39245712ejb.333.1620841798809; Wed, 12 May 2021 10:49:58 -0700 (PDT) Received: from neptune.. ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id r16sm338058edq.87.2021.05.12.10.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 10:49:58 -0700 (PDT) From: Alexandru Ardelean To: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jic23@kernel.org, Jonathan.Cameron@huawei.com, alexandru.tachici@analog.com, linux@deviqon.com, Alexandru Ardelean , Alexandru Ardelean Subject: [PATCH v3 03/12] iio: adc: ad7192: Avoid disabling a clock that was never enabled. Date: Wed, 12 May 2021 20:49:05 +0300 Message-Id: <20210512174914.10549-4-aardelean@deviqon.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512174914.10549-1-aardelean@deviqon.com> References: <20210512174914.10549-1-aardelean@deviqon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathan Cameron Found by inspection. If the internal clock source is being used, the driver doesn't call clk_prepare_enable() and as such we should not call clk_disable_unprepare() Use the same condition to protect the disable path as is used on the enable one. Note this will all get simplified when the driver moves over to a full devm_ flow, but that would make backporting the fix harder. Fix obviously predates move out of staging, but backporting will become more complex (and is unlikely to happen), hence that patch is given in the fixes tag. Fixes: b581f748cce0 ("staging: iio: adc: ad7192: move out of staging") Cc: Alexandru Tachici Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Alexandru Ardelean --- drivers/iio/adc/ad7192.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index 2ed580521d81..d3be67aa0522 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -1014,7 +1014,9 @@ static int ad7192_probe(struct spi_device *spi) return 0; error_disable_clk: - clk_disable_unprepare(st->mclk); + if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 || + st->clock_sel == AD7192_CLK_EXT_MCLK2) + clk_disable_unprepare(st->mclk); error_remove_trigger: ad_sd_cleanup_buffer_and_trigger(indio_dev); error_disable_dvdd: @@ -1031,7 +1033,9 @@ static int ad7192_remove(struct spi_device *spi) struct ad7192_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); - clk_disable_unprepare(st->mclk); + if (st->clock_sel == AD7192_CLK_EXT_MCLK1_2 || + st->clock_sel == AD7192_CLK_EXT_MCLK2) + clk_disable_unprepare(st->mclk); ad_sd_cleanup_buffer_and_trigger(indio_dev); regulator_disable(st->dvdd); -- 2.31.1