From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 10F3B3CE0B8 for ; Fri, 29 May 2026 10:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780051561; cv=none; b=LKdNjXdbSXnPdJzZAhRQRr1A03YxvcgkCdvKEPLpCVpZJdmyIa/vTh3hhvFt18gZ7MZ89pbYuX+lOa4W5RiKCX3dJ6aMVY34876b6xZNlnu2V4KoVw3neRUYgmSQgwFGDOsAzyTw+6ZNVQCMO4HCyKBLTy3osuWIqZzMK+/HbhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780051561; c=relaxed/simple; bh=audYFOC1F1czBfQ12j4ij8tbLhn97+qowaIfjvNDfss=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F84GDcbrDo5/flukhevk1sCwTYmZA/ppszVGM3UM0y6M/zjU8BfNeXhScUZb0nDw9xnh6Ed4dNchmm0wLokj3O6nAW8hrAATzYX39PqDKtg0bdIFjQH3tL003bV8xut4BjSHRHPDtzg3vco8U9xSSLiyx8R3QDDhJXsHOw4cnm0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=tHWFjNOm; arc=none smtp.client-ip=209.85.167.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tHWFjNOm" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-5a8e387baaaso1173008e87.2 for ; Fri, 29 May 2026 03:45:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780051558; x=1780656358; 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=8RX6HPkvTVnTrWIRcVhe8QYP1zROuwlfOtGDPwiQtAU=; b=tHWFjNOm6jjRdTQM6Nz6v3LEvWzePYkbZT8fiLPKzTooJWVUrucr2OPG7YLIbMc2Cf wbEQWOkCjrhtT4D4VRYRc2AY1x91Px4xSsbm0MQq+4DPhavctbPcSVTO5HrXf8SEAOCm ++AlpOkMD9fvIj8KIVwVL9kLIwx5F8iIm6KtuQwFk2U3o/m3avyohcWvu7Xhc96hb+Hd EOntw6x30fM9XTNLqAnV3HnXp1QdQGGy4YYp2HJIgQTZIIS5Rcq5+jHipEZAKAy2i7FN MCklgGj5F4OmH/Us+N27V29n0solXAgwGSu+wosfK5vkbW91ztAf+54eDy9txwXFOaTq UIsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780051558; x=1780656358; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8RX6HPkvTVnTrWIRcVhe8QYP1zROuwlfOtGDPwiQtAU=; b=PgL6hnCjHfTj7l2rcxD4DASoiRTMJsQisD/58cZIGiHqeiE4D69IHbKOnpDX4b1glY x3a7WMmDiGDWMPBWwD3lXNvUZAWp+gzy49tuVMOVyqlnIgL6h/l+2mK0l3EhNOFO5uzk n0L1rzpGudcCGvh9GSWBEnK/PDRZoJHDVFNaaSfmjPbLHC53064YcELcyklp1yShNFvE dO633dHBqVxw8G2ZFuDOzPYPGjPwwzy3ttOb+A7Qj9d1U3BOMi+/4d3JhI8ATusS/E6d /ARiVowZCIDmOL04oEPALbqJwjOcvqbU7jv1pBTgksIcbM8Sa7p2KgN3o/39FGHmXRzI woOw== X-Forwarded-Encrypted: i=1; AFNElJ8nSbgDUrC+RvFidWusHIGQVBso/vsdf/kO0AkwnxKwtaXghWBKz1tNta/ECl/G5//EHHOgypA+DvQ62aI=@vger.kernel.org X-Gm-Message-State: AOJu0YzAZukan69qC/84VF6gmxaRu5D/Dldt8gY/sxEBzMI5/Y/7vUQZ L219uqJXI1EhvCslHEtdleeI7GE/Na2VfirlJ7pBsdC1PqRAvZfF+MHo X-Gm-Gg: Acq92OHtgW/N5ZCqrycC/wVT8ae6VrHxTzajNk3Bsm9tAsjzuFRAKWdz9i7eHD8/5nt 0zuacdqDpLhE2CIac8gVY/2OH4xl9HpBQcBxyaX6RtT5Tnd3NtxeM0HHRVBeH67DsgFwiDu5i80 rxCwK0xrgDV9D+5E5/ktCjFmeCV5OCrYltWFghCHNfRoVl+OGDJoLwl3/KaQhX0UIIHuXxQ2emU iNA6JAnEg+Od/kICru8pCyHbjxY4pce29CzCL6MH91bx7zUCi0ZfjVCHR51nYw6C6qjMCnsHFuQ PzSQMGcU/GLeZtZrQVQKwwHEC5t/bO3t8t/yOZ8KaD5M+pWpclEPuprSNWfvD71+bsT+9RKZs9I eqqb3l42TDY7CS+34FFS63VDKkpU0HpjDipSDHWb6dlrykqNe6G/xnZSUZszSTYSphNswC6ro6f 1SKJEogrXsbHIhw9vSFXUyP2RTvM4mx0/3eNnmTpAYSyEbPtzkvuB13uo= X-Received: by 2002:a05:6512:3988:b0:5a8:7396:63e3 with SMTP id 2adb3069b0e04-5aa59523751mr306571e87.5.1780051558250; Fri, 29 May 2026 03:45:58 -0700 (PDT) Received: from localhost.localdomain ([94.158.61.193]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5aa5b788811sm192604e87.63.2026.05.29.03.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 03:45:57 -0700 (PDT) From: Stepan Ionichev To: jic23@kernel.org Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] iio: light: us5182d: use devm_pm_runtime_enable() to fix probe error path Date: Fri, 29 May 2026 15:45:42 +0500 Message-Id: X-Mailer: git-send-email 2.33.0.windows.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit us5182d_probe() calls pm_runtime_enable() and then iio_device_register(). If iio_device_register() fails the function jumps to out_err but the existing out_err handler does not call pm_runtime_disable(), leaking the runtime PM enable_count on probe failure and on subsequent rebind. Switch to devm_pm_runtime_enable() so the enable (and the matching dont_use_autosuspend) are torn down automatically. On its new error path the probe jumps to the existing out_err label so the shutdown_en() cleanup stays in step with the rest of the manual unwind. The pm_runtime_disable() and pm_runtime_set_suspended() calls in us5182d_remove() are dropped; the devm action runs after .remove() and handles the teardown. Signed-off-by: Stepan Ionichev --- drivers/iio/light/us5182d.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/us5182d.c b/drivers/iio/light/us5182d.c index d2f5a44892a8..ada75f710bfc 100644 --- a/drivers/iio/light/us5182d.c +++ b/drivers/iio/light/us5182d.c @@ -880,7 +880,9 @@ static int us5182d_probe(struct i2c_client *client) goto out_err; } - pm_runtime_enable(&client->dev); + ret = devm_pm_runtime_enable(&client->dev); + if (ret) + goto out_err; pm_runtime_set_autosuspend_delay(&client->dev, US5182D_SLEEP_MS); pm_runtime_use_autosuspend(&client->dev); @@ -904,9 +906,6 @@ static void us5182d_remove(struct i2c_client *client) iio_device_unregister(i2c_get_clientdata(client)); - pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); - ret = us5182d_shutdown_en(data, US5182D_CFG0_SHUTDOWN_EN); if (ret) dev_warn(&client->dev, "Failed to shut down (%pe)\n", -- 2.43.0