From patchwork Mon May 31 13:12:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 450500 Delivered-To: patch@linaro.org Received: by 2002:a02:c735:0:0:0:0:0 with SMTP id h21csp850283jao; Mon, 31 May 2021 06:53:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk8+EcoEH53q1caq2eYaQD1Q4gTKdUQldEIH+Neh9qkoOC0SsI07Fv7/2TL9zEp6zGJz6I X-Received: by 2002:a05:6602:14c8:: with SMTP id b8mr17017291iow.209.1622469223056; Mon, 31 May 2021 06:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622469223; cv=none; d=google.com; s=arc-20160816; b=dLqprW2NDFG2oKSBQullvav07He3q3vIi6OS0Te1K8Msi49n79u6yKbNJySVBkjBJy cnnHk5saLG5FVSgPtg6nyoyQOpsJfgBAFuT0BX3IvyRZah5hrlobQyeTj2i08ciLiM+y 0oOlO1EECoQpeL2P6XbQFLOQpeCPNV/ltxbv8Fa806/d7PoOflvfJOlroknMtftTxic6 A02W4kkZHIdNytEcNzBfMGUK5rIkEWR7DGhJN4RYHzaKr5GrfTTxJUxE7Y4RsVNyd4xL RGZO4dmvCVMCXXNbXmuDnXaGMu6h/Uc5j2X220UcUMBYgfVTNaLEfT1PLalo3VSeAA3q 6mMg== 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=KhzhVAXv/Rgan+/wwMrmUwAFzpH1yT3iCZi8V9Jpom+cft6tAhX2EUgCqmjbwViXZu 2+WaWiHVWAB0I0Enucjk7lfiICc9bac7AzpCdva4/u470Cv5+WbvQee9FRkaHlqlYy+s q6+IkHQuTbDro3rZ5QN4QZKkJEJfj4bbdTq73YFVNGL3b4bzwXv0D5mG0mrbJhCdkpCg NBOnn8Vq/Gi+dAfhnK2K1pHHMj3PEpbwAXNAUgQAyf+yKQDmK2gnkAjNIimausZh8Ipk yVqCT3a6HsdGAwSrZMfWbtG4H6I4O2ON0tDFCxlZf8SCV9WeFNu8FoaIDd6iiXnkh9cc ljiQ== 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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 h10si16461652ili.90.2021.05.31.06.53.42; Mon, 31 May 2021 06:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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 stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S231706AbhEaNzN (ORCPT + 12 others); Mon, 31 May 2021 09:55:13 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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);