From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 CDFFB3D092F for ; Fri, 29 May 2026 10:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780051564; cv=none; b=SS/xty/F056Z1fXkx6rH5LZCWrgMTntDuiu3lnn98i+/d7FOj+Fv8um6ftttB+b6jF0vzzgGU7GVRGgVFEcd8qlrJpzSZQDJCbTxYyDXGhibBTYcRxIb+100wvEUxsB288fYu3GBlJ3mZpXmH9UL3qSlA/Xdv9ifROSoijlK6eY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780051564; c=relaxed/simple; bh=Ds1IePhPH8cdXoDJgltMRTsR7yErO+r38H8TLfydJzY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tiePYJO4ehXbAuWBbMXqcU+r9o+TFr8qoZRRgJwPye6DkzxgSC7G7SUO42wneb+it/dLzErplT7k4zjaC/dgrwo5tJ2jbmdMO11JKtYw5ceheTKySu8HQVzSsJqRRBNtXSpHz267z1OJMLl07PxOJMfHOJf5Av5G0ZpZQumAQ/o= 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=aYblXAsC; arc=none smtp.client-ip=209.85.167.46 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="aYblXAsC" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5a41a9a97d3so1082965e87.1 for ; Fri, 29 May 2026 03:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780051561; x=1780656361; 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=QrkG2GgwE7d9GVC7/yBvpw/L+5Pl56q+Sn4VeitLYBQ=; b=aYblXAsCqDdv+KXBmqJqehuByOZaXVLkINp9BGpq5p9+cVg6HJU+ysT9lFt7WFfsZg LP6e51rR4qcS6ut0KUqB4BB8Onca8L8aUABSq7diuDB7nZIGBedAbqNZJKyKjw2RinsL HGngoEQFp8CulNqE1hZuPZuN881jNz+syWpfxQfubPt9rNZ8EeA62lQrMlEMupu2u+9j 6+CuBoppG7iOJu2/YDta9P2pRxhSv+YbT+fIWNT4J8HTQ8jPEIUsg9PYkj8Z1RoXFucj 8aU8rFuK7wlDpO/1At44YuoKL5lWZPY4TFEs35dLKQsc2go5ArjZ9FhWtCiS+5EhxpZf lCrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780051561; x=1780656361; 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=QrkG2GgwE7d9GVC7/yBvpw/L+5Pl56q+Sn4VeitLYBQ=; b=Jjbvs7Ys6f4PZ8Wkcfzk8ICpZrbPgUw9j5Sh1qfLxRlDGeT4M58ilUzNTdFtzFcBvu TG561gjJNlLNS4opOp+lfkeotq0q16nXb79arexJ9EFHq8F5rtTy+f5UfOva+dzwTp6D 3bHY8/+Q8Ti7fwZJRen/FhMOMDlMpNzRuQjgTtD5MX+Q7hMabj7JLBRsmN9ldilFF6ai CfJNweOEQu+iozEYTaqIWGklIinSGhWOK9SgjNTL2C8mnr+GEIfDIfWCKm+fuHtjsdeQ I+fOMPsiZiWVrMumgXn6mYuKBNiEPwGE+fWRbVAvmOH5zjcRKqDBchyzTHBxtgmmJd6k qa3A== X-Forwarded-Encrypted: i=1; AFNElJ8qCCVmLXbd6Gfj0nuJgLQqXzBvRsDKJmzT/E3M01VNg6QlUScATXKkvxqnW2fK1+ipPxDEoT0zq120i1Q=@vger.kernel.org X-Gm-Message-State: AOJu0YziFrJLIqjlJ32xLPKGkUjqyggYSdD6aBPTjy4UwJoukMicda8i t6Jjat/TxPZHwSlcQB7kvnMzlY0R3RneT0Y6aam/lI/sT5tVQOlgkvhijCOaIT0u X-Gm-Gg: Acq92OGUy5uVdqPpiDPD/9xTLvePhwpwBPikTj5VzVtfip/D0Wp0bNjEtGYyd++mv8w JmOAEDtKIiyiong5Sh4vDPWhRaiO6Aw5jlvtY5q7NzjPc6/N+57aiQN0ZwRlzb7P0WT+T+LS44l F0SDMFXqDLf/zt0Pt9hc2tfX0lVzrH8imaidoQFF7XVh5rc963yuOpXNbd1/TiM43NKdx72SZrM RQvorWX6nWa2tLUTR4TQU0Tsgv+sybHFgCkvHg9mTFNZkoDHHt+MAxlywiqdL6m7dJXQvq9qylK xYFoT/apLvp/qcEMmHpFslsZX+DiYb81dX19uzXnpm1EWWoG9i4Z4N5OmkiH/zC45pmWrED/8Th qcttTzlwiCjBI9xZChqMu42yqQYLu42zVtQXQXgpGRfVSJb66z9x4kFHjikVB2QpTk3rF3fi6lU yAre01LzBc7ZohCV0Y8pad/sPcBDaCKtX/54eTQRdGm5C6PAmP/S14KLFeWKxfbpfW4A== X-Received: by 2002:a05:6512:3a85:b0:5a4:18cb:8850 with SMTP id 2adb3069b0e04-5aa5952acc3mr285910e87.6.1780051560916; Fri, 29 May 2026 03:46:00 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 03:45:59 -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 3/4] iio: light: apds9960: use devm_pm_runtime_enable() to fix probe error path Date: Fri, 29 May 2026 15:45:43 +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 apds9960_probe() calls pm_runtime_enable() and then several operations that may fail through goto error_power_down, ending with iio_device_register(). None of those error paths call pm_runtime_disable(), so the runtime PM enable_count leaks 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. The probe error path on devm_pm_runtime_enable() itself is a plain return because no hardware has been powered on at that point. The pm_runtime_disable() and pm_runtime_set_suspended() calls in apds9960_remove() are dropped; the devm action runs after .remove() and handles the teardown. Signed-off-by: Stepan Ionichev --- drivers/iio/light/apds9960.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c index 785c5dbe2d08..edbf149b931e 100644 --- a/drivers/iio/light/apds9960.c +++ b/drivers/iio/light/apds9960.c @@ -1074,7 +1074,9 @@ static int apds9960_probe(struct i2c_client *client) if (ret) goto error_power_down; - pm_runtime_enable(&client->dev); + ret = devm_pm_runtime_enable(&client->dev); + if (ret) + return ret; pm_runtime_set_autosuspend_delay(&client->dev, 5000); pm_runtime_use_autosuspend(&client->dev); @@ -1123,8 +1125,6 @@ static void apds9960_remove(struct i2c_client *client) struct apds9960_data *data = iio_priv(indio_dev); iio_device_unregister(indio_dev); - pm_runtime_disable(&client->dev); - pm_runtime_set_suspended(&client->dev); apds9960_set_powermode(data, 0); } -- 2.43.0