Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1055490pxb; Thu, 5 Nov 2020 22:51:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWesNb9ofDtG8Bd4WiTX3AzqPsBd5PAibsenRyqpo2cgOCKHx//1+dB6inFtqeAa0i6uc2 X-Received: by 2002:a17:906:c1c7:: with SMTP id bw7mr676241ejb.290.1604645479891; Thu, 05 Nov 2020 22:51:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604645479; cv=none; d=google.com; s=arc-20160816; b=EXhlXFfz1X8EOiNVVXIswTC4Va7E2OgXExcmUszdCA0ceQn2SN7W7N9/W6rb1M/9eG fMXB3dwF57BhBmfK+8kEyDO/Z1m8IZc783T5vU0rDoDoPN/AGD0Zhj1M6U4LgsNYE7jM zm1gEkHHpLUtEyB2jvDrElZoGyaBrIwG0NnBCy36iidihclEZyJcO2meGNAuEqY+TQe0 ywWSmER3J2qqLbSqUUkNcgbxfeFYkusZ839WF3AyEDq8NEEuWbBxHz+go7TYJ2xOMqnw Sp+yQ7imvTEmOnrBWwGs7zT7ps3FLqaymtH8VRUjSGrwew459aAWVxmpEdwDHsSS66pL Y+dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=EhBdW5IWB8IOJUCB3Jns04hRuavBXzgRCXhTaB+mxw4=; b=HSkwG345bs+KQAivVyPYLpH2ffCsGwmqBv/COfgsrA6zzyAUFhGOIbDavttm+xa82k nwZpwpIwCg+ENj6FGdONLEtpbd780dZD3Gx1+jRCm4F/qZPJdOPGfMB+yJOJtUsZav/u OOvYVLNDpHkaqjrtNSiv8O3ZpuXPNues4OSsZXeLRNQ86gtiOqBVJS3FAtHnXFF9GBTn fyiZgjRLXSa/rl/sc0PQTGZbf0L/grkbxqys66GdSx/WZPRCvGwEjcRdAIjCPrChiGSC QLriNmhCMoXdhKFLpsX66bzbfa7IaTKrWa+aScQdMvDZ7nXglWDNK6Z9mXDhajsIMcYS UoYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chromium.org header.s=google header.b=Ic4slt0B; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk1si199870ejb.556.2020.11.05.22.50.56; Thu, 05 Nov 2020 22:51:19 -0800 (PST) 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=fail header.i=@chromium.org header.s=google header.b=Ic4slt0B; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgKFGtY (ORCPT + 99 others); Fri, 6 Nov 2020 01:49:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbgKFGtX (ORCPT ); Fri, 6 Nov 2020 01:49:23 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 558FEC0613CF for ; Thu, 5 Nov 2020 22:49:22 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id a18so243019pfl.3 for ; Thu, 05 Nov 2020 22:49:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EhBdW5IWB8IOJUCB3Jns04hRuavBXzgRCXhTaB+mxw4=; b=Ic4slt0BtFKc2d/3FAW3k6CtAPGxQoplvI6cwh1JMjup8B+Dkqz50zALb2AvZFe3Om i0MY41Vh3HRbfjpTdbiuXt8i99hTrp1o6mObsERP820UjUm2CQlDO0fOvmModRJO0kky 7pcBA+eZn9XWFJbpGX3zCOulMTiOgOVbl9Xn8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EhBdW5IWB8IOJUCB3Jns04hRuavBXzgRCXhTaB+mxw4=; b=ia+1KBLaY1lAiPugjq2tOybTmohKHoMQA1FfcSn5MJSPidS6o8IqcjRUhHBIMj+gt9 yznUTm4pBgMlEuXPuYSrUx7eLDs5UcXLxkVzqB66lsKGKzAco05/vwVA/Mcq97rMbkna vWlxLbbTyfnAGJNX/uGKhkLvd7QhNX2E1SM5TkK+7d5oCfBvXgg1NMIHrjtflX84bmfx jzD+rhS+xJQNIlEb0hZ3G8ifVHsZQy0E6NfoUP5zlEq6CK+9gSs1g1XSv7NhZbygcn6T TqFB8wC0mMrjkyIrDd99XfAu4fgQWt7x66cbiVh8YB3Cd2/wdX+uPeWVUvAv3DFr1bPl cg3Q== X-Gm-Message-State: AOAM5309UGnKJ0kUmfJYZttu70VYvEOQQ6gq2V6PK3gr+sYkWa+RSpqe XeF0HANKcqZEk59qUQ0ip8xcEA== X-Received: by 2002:a17:90b:4683:: with SMTP id ir3mr917982pjb.212.1604645361916; Thu, 05 Nov 2020 22:49:21 -0800 (PST) Received: from kafuu-chino.c.googlers.com.com (105.219.229.35.bc.googleusercontent.com. [35.229.219.105]) by smtp.googlemail.com with ESMTPSA id d68sm752405pfc.135.2020.11.05.22.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 22:49:21 -0800 (PST) From: Pi-Hsun Shih Cc: Pi-Hsun Shih , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org (open list:VOLTAGE AND CURRENT REGULATOR FRAMEWORK) Subject: [PATCH] regulator: core: don't disable regulator if is_enabled return error. Date: Fri, 6 Nov 2020 14:48:17 +0800 Message-Id: <20201106064817.3290927-1-pihsun@chromium.org> X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In regulator_late_cleanup when is_enabled failed, don't try to disable the regulator since it would likely to fail too and causing confusing error messages. Signed-off-by: Pi-Hsun Shih --- This is encountered while using drivers/regulator/cros-ec-regulator.c. Since the driver controls the regulator through ChromeOS EC host commands, it is not available when doing suspend / resume. But since the regulator_late_cleanup is delayed to 30 seconds after boot, it is possible that the regulator_late_cleanup is run during suspend / resume, which cause the is_enabled call to fail, and printing out some confusing error messages later when trying to disable the regulator and fail. This commit attempts to address part of this issue by not trying to disable the regulator if the is_enabled call failed. --- drivers/regulator/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a5ad553da8cd..70168f2a53ed 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5843,13 +5843,14 @@ static int regulator_late_cleanup(struct device *dev, void *data) if (rdev->use_count) goto unlock; - /* If we can't read the status assume it's on. */ + /* If we can't read the status assume it's always on. */ if (ops->is_enabled) enabled = ops->is_enabled(rdev); else enabled = 1; - if (!enabled) + /* But if reading the status failed, assume that it's off. */ + if (enabled <= 0) goto unlock; if (have_full_constraints()) { base-commit: 521b619acdc8f1f5acdac15b84f81fd9515b2aff -- 2.29.1.341.ge80a0c044ae-goog