From nobody Mon Feb 9 11:02:38 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12EA91FA8F7 for ; Fri, 17 Jan 2025 11:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737114356; cv=none; b=FE9OyCurHDQlc9zWJZCj4Ix6ACzFfZcQmzpUv4lUOEM4ny4v7N/9aKCF+wMLVTHrjDPlhkc6e5Uk90TlQVZqXF3bw+XbzU3fRJ0qGCMZcFjEjdJ65AuhfpCVMEcb/LlN49/ZjJWNn8r4UbXUMLS+sRp33HIES5GsOHhiqkMbaR4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737114356; c=relaxed/simple; bh=53V4mDk+itym6kMFP2LAtwCEDK2W9XMEniFbze8Xb58=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ga+28aCxWUBy+82Aj4eQOzxvy9RAJ7xcXMv4OaMbK22G4LZ7W72w10CmgcfnjXNFkQ/UYxQBJNndpimBAzLqCCQelXV9Zj+hMuaOV+oMfVeJRCTkB25XUYTYfX/bykDL2PbZGD6zFYhQLhQ5BBLCGWcRMP8c+CTuGxeuroADMnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=HoUGYT5C; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="HoUGYT5C" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4364a37a1d7so18743255e9.3 for ; Fri, 17 Jan 2025 03:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1737114352; x=1737719152; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vDWSQkaFP0eTmUAVm7GcOJC09zF+62CBev8hupRleKw=; b=HoUGYT5CHIO/otbFKeiooWH5qLEBqWjJlLyj8COpml+jfWDm7fj3goU6LRlukzH9Ok 0+ePTzhWSfPXva3qhyB6XQfvbW3nTlDXstsmLhS5iFmeWRmOjD3/k2QMZVurtyyXR35Q unK7iXDVXF7QxDR2lyS2gdqRidxsmB9WJGFBGK9nPtKFoT8UBXwLNozV52hYV5OoeKkB bwgxnX7xTk8pAMl+/dfqbH23v0EWWhWLpEslZE+eYYKYoRB+b8dNn8MOI13+Qc2QRPlk HwfKGIkC3k2scQyJ+hZ7Rc/dRjdI+X4KazdFCh0s89d0xeQxeYyllPhEH7zFgE3QMJna p2gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737114352; x=1737719152; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vDWSQkaFP0eTmUAVm7GcOJC09zF+62CBev8hupRleKw=; b=Me6M4IisNZCR8mQAsMW0fDUze9W+V/i/70eIrrANqY48fJhlLCty+ZMoB272ZCl62x upBGY8gpm4oyH3hePCHDtUPKB+YSyFtqnd19IeEmzvenuUDt+8MfhLZuSnTqGZux6+iI LFds9+Rg5p3FK+7GIyIQsYBKgA0iTCNTbXFL/92jUnD3xtYT8bKm2ZZNGGdUoK6UKjJD qxe27FYqLzCK7S7MKd+Gs8H7R1IOeMwwfBoMYWfGs7mOFeTLvSWO0esef17C4abk2Gwl idlOO5ty/7AISUlhYlWvaAXORUYITL+IpQKue4apr53ds+IHLHhGxC7wNG38dXAtzPQC fFXw== X-Forwarded-Encrypted: i=1; AJvYcCVZ+lLFGVlyEK4mliBRDY6PFRaCTZE/N0XZrLeqiYZHdBJu/GrF1WOGLUiRxAeMxrbRx+RLOM1ImrR4Ffk=@vger.kernel.org X-Gm-Message-State: AOJu0YxgU7shg7tBHD6iqJAnVOpVzi4HoqFKfTCCVWQzPl3p9gGBodTa rNAQd8QAbR/4O7b3iMG6ThaHEqLCmwrwSVQuG0aRt8lyy0crMC3V75BUc/Hri14= X-Gm-Gg: ASbGncuDWih5yMw5gLnAWw4q2M6QfFcsDLVV0lU39DvJK9sc8O1e/hw+FDT94FCqJDE 4zCGwgVltrVqgWi+m4uQl1ChvqvbpU31K+lSt7Y9HLg4A5Pny+gFqHLFnOwX8wzEQ8diY/fp9sF 7O/2Vz1Syo6QkYnl0m0t7+PNx2HmVurtGa1g0sFDuhpsl4RkdH7zqEE6MtTNssl1L9QgU6jx+CA Ro9eYBW1RB3/QE9vadz0+p600hmaZm27yy0FL00AiUmPcuBdSEIDwOFx74zwRYcNDMZLqV+Brjk 9cxzz1Ty3Yo= X-Google-Smtp-Source: AGHT+IGU/eWQr6GxoGkP+hRgnfbSFQIEduWrJJ3ySOP/gb2XWklvdeAu5zzmhcBMS+53D7WILmKsYw== X-Received: by 2002:a5d:588b:0:b0:385:f1d9:4b90 with SMTP id ffacd0b85a97d-38bf577f826mr1988861f8f.13.1737114352231; Fri, 17 Jan 2025 03:45:52 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.165]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf322aab8sm2348496f8f.57.2025.01.17.03.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 03:45:51 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, ulf.hansson@linaro.org Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 1/2] iio: adc: rzg2l_adc: Drop devm_pm_runtime_enable() Date: Fri, 17 Jan 2025 13:45:39 +0200 Message-ID: <20250117114540.289248-2-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250117114540.289248-1-claudiu.beznea.uj@bp.renesas.com> References: <20250117114540.289248-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea On all systems where the rzg2l_adc driver is used, the ADC clocks are part of a PM domain. The code that implements the PM domains support is in drivers/clk/renesas/rzg2l-cpg.c, the functions of interest for this commit being rzg2l_cpg_attach_dev() and rzg2l_cpg_deattach_dev(). The PM domains support is registered with GENPD_FLAG_PM_CLK which, according to the documentation, instructs genpd to use the PM clk framework while powering on/off attached devices. During probe, the ADC device is attached to the PM domain controlling the ADC clocks. Similarly, during removal, the ADC device is detached from the PM domain. The detachment call stack is as follows: device_driver_detach() -> device_release_driver_internal() -> __device_release_driver() -> device_remove() -> platform_remove() -> dev_pm_domain_detach() During driver unbind, after the ADC device is detached from its PM domain, the device_unbind_cleanup() function is called, which subsequently invokes devres_release_all(). This function handles devres resource cleanup. If runtime PM is enabled via devm_pm_runtime_enable(), the cleanup process triggers the action or reset function for disabling runtime PM. This function is pm_runtime_disable_action(), which leads to the following call stack of interest when called: pm_runtime_disable_action() -> pm_runtime_dont_use_autosuspend() -> __pm_runtime_use_autosuspend() -> update_autosuspend() -> rpm_idle() The rpm_idle() function attempts to runtime resume the ADC device. However, at the point it is called, the ADC device is no longer part of the PM domain (which manages the ADC clocks). Since the rzg2l_adc runtime PM APIs directly modifies hardware registers, the rzg2l_adc_pm_runtime_resume() function is invoked without the ADC clocks being enabled. This is because the PM domain no longer resumes along with the ADC device. As a result, this leads to system aborts. Drop the devres API for runtime PM enable along with the other devres APIs after it (devm_request_irq(), devm_register_iio_device()). Fixes: 89ee8174e8c8 ("iio: adc: rzg2l_adc: Simplify the runtime PM code") Reviewed-by: Ulf Hansson Signed-off-by: Claudiu Beznea --- Changes in v2: - collected Ulf's tag - add a comment above pm_runtime_enable() explaining the reason it shouldn't be converted to devres - drop devres calls that request IRQ and register IIO device as proposed in the review process: Ulf, I still kept you Rb tag; please let me know otherwise drivers/iio/adc/rzg2l_adc.c | 60 ++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 883c167c0670..4742a727a80c 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -87,6 +87,7 @@ struct rzg2l_adc { const struct rzg2l_adc_hw_params *hw_params; struct completion completion; struct mutex lock; + int irq; u16 last_val[RZG2L_ADC_MAX_CHANNELS]; bool was_rpm_active; }; @@ -430,7 +431,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev) struct iio_dev *indio_dev; struct rzg2l_adc *adc; int ret; - int irq; =20 indio_dev =3D devm_iio_device_alloc(dev, sizeof(*adc)); if (!indio_dev) @@ -464,25 +464,33 @@ static int rzg2l_adc_probe(struct platform_device *pd= ev) =20 pm_runtime_set_autosuspend_delay(dev, 300); pm_runtime_use_autosuspend(dev); - ret =3D devm_pm_runtime_enable(dev); - if (ret) - return ret; + /* + * Use non-devres APIs from this point onward, as the ADC clocks are + * managed through its power domain. Otherwise, durring repeated + * unbind/bind operations, the ADC may be runtime resumed when it + * is not part of its power domain, leading to accessing ADC + * registers without its clocks being enabled and its PM domain + * being turned on. + */ + pm_runtime_enable(dev); =20 platform_set_drvdata(pdev, indio_dev); =20 ret =3D rzg2l_adc_hw_init(dev, adc); - if (ret) - return dev_err_probe(&pdev->dev, ret, - "failed to initialize ADC HW\n"); + if (ret) { + dev_err_probe(&pdev->dev, ret, "failed to initialize ADC HW\n"); + goto rpm_disable; + } + + ret =3D platform_get_irq(pdev, 0); + if (ret < 0) + goto rpm_disable; =20 - irq =3D platform_get_irq(pdev, 0); - if (irq < 0) - return irq; + adc->irq =3D ret; =20 - ret =3D devm_request_irq(dev, irq, rzg2l_adc_isr, - 0, dev_name(dev), adc); + ret =3D request_irq(adc->irq, rzg2l_adc_isr, 0, dev_name(dev), adc); if (ret < 0) - return ret; + goto rpm_disable; =20 init_completion(&adc->completion); =20 @@ -492,7 +500,30 @@ static int rzg2l_adc_probe(struct platform_device *pde= v) indio_dev->channels =3D adc->data->channels; indio_dev->num_channels =3D adc->data->num_channels; =20 - return devm_iio_device_register(dev, indio_dev); + ret =3D iio_device_register(indio_dev); + if (ret) + goto free_irq; + + return 0; + +free_irq: + free_irq(adc->irq, adc); +rpm_disable: + pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); + return ret; +} + +static void rzg2l_adc_remove(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct iio_dev *indio_dev =3D dev_get_drvdata(dev); + struct rzg2l_adc *adc =3D iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + free_irq(adc->irq, adc); + pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); } =20 static const struct rzg2l_adc_hw_params rzg2l_hw_params =3D { @@ -614,6 +645,7 @@ static const struct dev_pm_ops rzg2l_adc_pm_ops =3D { =20 static struct platform_driver rzg2l_adc_driver =3D { .probe =3D rzg2l_adc_probe, + .remove =3D rzg2l_adc_remove, .driver =3D { .name =3D DRIVER_NAME, .of_match_table =3D rzg2l_adc_match, --=20 2.43.0 From nobody Mon Feb 9 11:02:38 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 12AF31FCFF9 for ; Fri, 17 Jan 2025 11:45:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737114356; cv=none; b=rSWJzNQZESEbs8JOUoMmMo3boIb45Rn+pJ1gUvfWX0xIXb6+RjjJHcVHlIQ2dezyxPP08zLXaf7pYATyf6cvzTbsb4+gfr2MU8P6DrJ/shWp5t6HUu6DFltfbxKdFXU4QZsxn9kdX1ibPn/SpX6AgpcjaF1RiP9zcNlPPXsjgeU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737114356; c=relaxed/simple; bh=Ic0dUSRBbSPcwd8A1dpe05r/cEGAMekPsiRX2TPIQhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y82DDFaGzEulUQlmej8LllBTFvDi6YIovfXcS98phNsjsxRkjtJmw+nZLaaQfePfSMmUvt01wT6wIKS09+kjSON5/yA51iKjqvNpmmTZ3IF5734pS4DnyahKJWLDqsTuChrpfye67w2V3mu0+RL5tRxaKlbPxZt1kRymSH1a8z8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev; spf=pass smtp.mailfrom=tuxon.dev; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b=JaR/M2YS; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tuxon.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tuxon.dev header.i=@tuxon.dev header.b="JaR/M2YS" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-385eed29d17so1093909f8f.0 for ; Fri, 17 Jan 2025 03:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuxon.dev; s=google; t=1737114353; x=1737719153; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7TZRktyyBG60hFO6UMKwaUx5vSkkWfjes2WCMQi2PJU=; b=JaR/M2YScD/mbjyMV/6qv+SVyyRek3pCsHiQ6Q/U1g6U62l5ykqkCYOubUyD7pDQDX iT/AwWjP9INYHi1zerf80LdCvNaZdZXgieYPxY8RFRJtJ1IJjW28N8iL9pEBNS1IBIx0 scp38sPbaVaEUGnJoGqa8p4qwdm4VcagFjGQb+NLBNn9HlGKHfd4s4qVMt6D576LITGB eOZPypulGqBoZuXqQAptSW4ueOntDizr4FeuOhgW1UoAg7wQTd1fmsB2FGK2brEACrGf hRsHLtRGhLWP9o99egY+KzKlwIhyLz03tuTdcenyMycMEgt/TiIgeIBR+I5LZsXjwkDS o5EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737114353; x=1737719153; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7TZRktyyBG60hFO6UMKwaUx5vSkkWfjes2WCMQi2PJU=; b=t8RofuWbDENHLjxUYu5En23w+utXsMfmh+gGvem1+mPrIX8b2nXycpaGaa/NJGBLj9 0XTgTaN/gjaXrGZler9pwxOngrXGRzUE7pA08bamULUk0bj7N8NA5mE3j0LdGJVYGZJs Ih77M2r6jMYlNssmMD3RSafY374YHLb8s7o1wU9asV/pX8w9LlwkJ5E2Pire9yTymjyX Oot2azNGISeEpoNFyg934aeZ0padjxUqGbWGT1f0gD00BLCL4QpKG4gTMyTj3I+YO5OD rM0TuCJLP7e3Yi3tOI1pBaZUDcQSY5HdH1o9e9L3xTFKU+1I3DUAsCB4F33a0Jl+R3bQ VNxQ== X-Forwarded-Encrypted: i=1; AJvYcCWBrHEm+DYAnJV6pi+0Y0XIQ7LV9NPH7n+h/5NEaiLQo1kut80NEuwz4McS/IUkSIA2oeuESc0RmEXMMM0=@vger.kernel.org X-Gm-Message-State: AOJu0YypI6ZIbJPvIfr788WqwgNE/jHEyu0h/TA2ShJSDkQVkCiK29Eg +m5QHxhFbRdcXSNq8pYZfvvb8dXhMdxe7iOBTt0fg8Bk7c10R0pAO36HoO8Un4w= X-Gm-Gg: ASbGncu46SG+i/wx+yNa3lpBC03E8m50M+bI5Ilho8M+W6i3azkp/dtGBVcEBuAyYVX RZjQ9DpPIRRHV7HrPaHTrRLBYInf3mquTuirJIOuPk+mmKNkKxkPYDRTZ+T9TgtLfa2gouRH8Uk 8T0AcXgSOB0ANPoBu5coe+AnFsthfJf3cfFSY0jD6qmIchDZxvnSPxvGp1B7Y4qrBRUTt+0N5fZ PJmP3xrxtnhTE/DkfYXQqiTnJFXDIBWsBjuZz4O9vXF8fZWOY8j9rwmkQGSIteYQX6kIAToXbm0 horORxtEatw= X-Google-Smtp-Source: AGHT+IGVMbNBWKyEsgqUoHAN8pJLCCoglPmI1Y5TRMuv0rz7Lsw40J1JRHBIdaOY0OSqyYHQYiJtMw== X-Received: by 2002:a05:6000:186f:b0:38a:8647:3dac with SMTP id ffacd0b85a97d-38bf57a68aemr2062457f8f.34.1737114353444; Fri, 17 Jan 2025 03:45:53 -0800 (PST) Received: from claudiu-X670E-Pro-RS.. ([82.78.167.165]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38bf322aab8sm2348496f8f.57.2025.01.17.03.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jan 2025 03:45:53 -0800 (PST) From: Claudiu X-Google-Original-From: Claudiu To: prabhakar.mahadev-lad.rj@bp.renesas.com, jic23@kernel.org, lars@metafoo.de, ulf.hansson@linaro.org Cc: claudiu.beznea@tuxon.dev, linux-iio@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Claudiu Beznea Subject: [PATCH v2 2/2] iio: adc: rzg2l: Cleanup suspend/resume path Date: Fri, 17 Jan 2025 13:45:40 +0200 Message-ID: <20250117114540.289248-3-claudiu.beznea.uj@bp.renesas.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250117114540.289248-1-claudiu.beznea.uj@bp.renesas.com> References: <20250117114540.289248-1-claudiu.beznea.uj@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Claudiu Beznea There is no need to manually track the runtime PM status in the driver. The pm_runtime_force_suspend() and pm_runtime_force_resume() functions already call pm_runtime_status_suspended() to check the runtime PM state. Additionally, avoid calling pm_runtime_put_autosuspend() during the suspend/resume path, as this would decrease the usage counter of a potential user that had the ADC open before the suspend/resume cycle. Fixes: cb164d7c1526 ("iio: adc: rzg2l_adc: Add suspend/resume support") Signed-off-by: Claudiu Beznea Reviewed-by: Ulf Hansson --- Changes in v2: - none drivers/iio/adc/rzg2l_adc.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c index 4742a727a80c..99cb73347b18 100644 --- a/drivers/iio/adc/rzg2l_adc.c +++ b/drivers/iio/adc/rzg2l_adc.c @@ -89,7 +89,6 @@ struct rzg2l_adc { struct mutex lock; int irq; u16 last_val[RZG2L_ADC_MAX_CHANNELS]; - bool was_rpm_active; }; =20 /** @@ -580,14 +579,9 @@ static int rzg2l_adc_suspend(struct device *dev) }; int ret; =20 - if (pm_runtime_suspended(dev)) { - adc->was_rpm_active =3D false; - } else { - ret =3D pm_runtime_force_suspend(dev); - if (ret) - return ret; - adc->was_rpm_active =3D true; - } + ret =3D pm_runtime_force_suspend(dev); + if (ret) + return ret; =20 ret =3D reset_control_bulk_assert(ARRAY_SIZE(resets), resets); if (ret) @@ -596,9 +590,7 @@ static int rzg2l_adc_suspend(struct device *dev) return 0; =20 rpm_restore: - if (adc->was_rpm_active) - pm_runtime_force_resume(dev); - + pm_runtime_force_resume(dev); return ret; } =20 @@ -616,11 +608,9 @@ static int rzg2l_adc_resume(struct device *dev) if (ret) return ret; =20 - if (adc->was_rpm_active) { - ret =3D pm_runtime_force_resume(dev); - if (ret) - goto resets_restore; - } + ret =3D pm_runtime_force_resume(dev); + if (ret) + goto resets_restore; =20 ret =3D rzg2l_adc_hw_init(dev, adc); if (ret) @@ -629,10 +619,7 @@ static int rzg2l_adc_resume(struct device *dev) return 0; =20 rpm_restore: - if (adc->was_rpm_active) { - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); - } + pm_runtime_force_suspend(dev); resets_restore: reset_control_bulk_assert(ARRAY_SIZE(resets), resets); return ret; --=20 2.43.0