Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2655606pxj; Mon, 31 May 2021 07:31:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznep74Up0v0LNAuwWvgpxUGoVPMCcm4N9sBNFbiB01sAgiP4c/XKzW0Zng6noCc2qzmkfO X-Received: by 2002:aa7:c9cf:: with SMTP id i15mr25162748edt.118.1622471491960; Mon, 31 May 2021 07:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471491; cv=none; d=google.com; s=arc-20160816; b=qJMrIHc6g6I8lDw9GBZr2NACLqh7xscRKlLtlaGrl//W6mNytRGd38SglBZ62yq09C 9X/4sjepUuUCUwj7XHMgv4ZIQQOHGC12rcoBO3Bvw3EBy6hdpu/1v3ntbXTM2m+yli/U wkX1M56SSYOpmvpHeco0vofBw6GXK0Fs9KQCFusQAN/GI0iwzljD9kNduiDw9LE++1Em +CeayoZ7F64oqidPHRkey4ww8gPRR6FFEHePaQCslFjLQ3RfVvAl9Jkq7irbJ5oTJOvS BQVbPpqEJvVNV8yfUgJk/TbgjYFZV8cCJjHV9VmeGjRbVG+7Fsqp/gkZjVoOaWHWxRM4 RzBQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/ucNzn6yiGTZhtOQ9sEeWzZx9sXnQfFKAtgSoxWQNDI=; b=AAj5Jb01dsldyTZD+79f0/964p5N0vRcJNJzeYnulD3xs1eRQC81RFKdtF0rIl6HXT m3ipo0kQc12RYTc0cGOJK4NzbXULdNrr/t7d9x9RSigqDeu+U9aM2vHUxd8gCIw1QKp4 ZML79qiGZhKanplM4tOS5x5d/2/YmuBwH9+Jhm8FRbPOkknIdWj+WDaohtoMiCYokjPA NGVTZP1orpioJ9j31bUJDCMr0fExbYkgcvsHN19qWxfhogXtNv3bb7chWdz3fvMOXvGk SY8rqc48oejhVbJTVyq/D/zHG5WSYrBalG7J0wzzVcj2gybVNG2IgAkjMkW4LDSUTT5B BpYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IBd2a86l; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb34si11496610ejc.697.2021.05.31.07.31.05; Mon, 31 May 2021 07:31:31 -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=@linuxfoundation.org header.s=korg header.b=IBd2a86l; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233540AbhEaO2d (ORCPT + 99 others); Mon, 31 May 2021 10:28:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:55720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232635AbhEaNwa (ORCPT ); Mon, 31 May 2021 09:52:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6DF5613EB; Mon, 31 May 2021 13:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467973; bh=4kczbqToKUoouxXjyJfOWnf9wHAck/hBksZMc/Wqk44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBd2a86lglooyAMWH1YliIFkO7fdi7T34UxFS1TET7pZ+dvUHLbUwgEdvnQfkQJbX z3ePBNp7mC3mVKtt8iNj9ktncd2C+pkF8LcrXZj2byE5ND/RrZJJbyhgvlDy8QwAei rdBKC7Q8/t7Ia+CUp7XiHiZSMeayaY9eH+7H5TRs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandru Tachici , Alexandru Ardelean , Jonathan Cameron , Alexandru Ardelean , Stable@vger.kernel.org Subject: [PATCH 5.10 068/252] iio: adc: ad7192: Avoid disabling a clock that was never enabled. Date: Mon, 31 May 2021 15:12:13 +0200 Message-Id: <20210531130700.303457863@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathan Cameron commit e32fe6d90f44922ccbb94016cfc3c238359e3e39 upstream. 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. Alexandru's sign off is here because he added this patch into a larger series that Jonathan then applied. 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 Cc: Signed-off-by: Greg Kroah-Hartman --- drivers/iio/adc/ad7192.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -1014,7 +1014,9 @@ static int ad7192_probe(struct spi_devic 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_devi 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);