Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1432836lqa; Mon, 29 Apr 2024 08:19:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2qKOKFEA0IT93WIhqv1pyNNaPO+B800bF1PM/sISV4erUolll9ofrTiW1F1IdYiPYp1WrTd4ZHNMXnyVgYC/He+pi4VuAM38VJ4DAjA== X-Google-Smtp-Source: AGHT+IErIOQbsqQTdyqFh3GP7fQrXPxqOHc0losMvIB/M5+SRFGgCd1TYtiwXCRbUD/ZZI+1jiG0 X-Received: by 2002:a05:6e02:1389:b0:36c:4c0e:6e96 with SMTP id d9-20020a056e02138900b0036c4c0e6e96mr5321220ilo.21.1714403959672; Mon, 29 Apr 2024 08:19:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714403959; cv=pass; d=google.com; s=arc-20160816; b=JRmRygdkarGfwJZY0s3vhIupbqPOALwABIpZPKuxexvembD42eKTBlygIq4vj8f+Ur 9J9FuEFfgRufnApS1BaRn18aa43azNPgoZLwZY0o35Tl4mtw1jV/gWVs/5cAV+DsADFt wvLNNz95IIYll1htyW9UXU62I0SdATBRmt+7y94se4pOa09KLlmO2qmcsCmx9miPLkqm 20wprlLaH+bpCmmTBJXvIf/aJJ1ocy2czWf2EfwOrY5zzchANWGlEXJclqFRequ+Je5O OVHnt9J+BkZc0JC+dxhmlSSNVhw0caJePN7raTqjwgaBOI88HCNyxkmyFFk80pTMlt4j jB/Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:dkim-signature; bh=R9glZ529O8mtMPUa8VffWuYBzQmIZ8D0Xiz3G+wHP5U=; fh=9+JPiKUqmiwg7nrgynbn+qu8x0UhUJwyp0gAHVwwYQs=; b=yAm/GU7J8YEwbLzmKaTD65jx/4xhe+JBTR43x6VN42MIY4QcYAilQx4VGmsJpkJNFN 6ZHnRDV4Mm+LCbe2jISqw9BBC6r/P+JI14hAMONK0zlH6Gmhtmxw3gAqvxdFj/Z/NDD2 C73ERbApNbiCzr/BFjT0r5k2b9S/9KAzOoOsreUSTyoFZbBLLP2SBIWDicjh8HyRHEHV 4QOIwiZOZYdUeEG1gJlsQ9znNWLSH89E2aUW5AzxPiiEYqTlu6oqXXDVKJuVAX05g5Fv XvzZQ6I3i1E7KxukRZWyQnDBAd/9gDgOeS6C2fe77x8dkLB+xtmQ0bnyO5dMYYT2Oi/x UZMA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b="K/6yZKWl"; arc=pass (i=1 spf=pass spfdomain=rere.qmqm.pl dkim=pass dkdomain=rere.qmqm.pl dmarc=pass fromdomain=rere.qmqm.pl); spf=pass (google.com: domain of linux-kernel+bounces-162477-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162477-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s205-20020a632cd6000000b005fda09321dbsi15653793pgs.815.2024.04.29.08.19.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:19:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162477-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b="K/6yZKWl"; arc=pass (i=1 spf=pass spfdomain=rere.qmqm.pl dkim=pass dkdomain=rere.qmqm.pl dmarc=pass fromdomain=rere.qmqm.pl); spf=pass (google.com: domain of linux-kernel+bounces-162477-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162477-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=rere.qmqm.pl Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 509B0B25B07 for ; Mon, 29 Apr 2024 14:47:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0E0784A2B; Mon, 29 Apr 2024 14:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="K/6yZKWl" Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBE5780630 for ; Mon, 29 Apr 2024 14:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.227.64.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714401942; cv=none; b=MysiyK6O1QSwB6h6VBoNwh+Qt8zxB6Bpi4BEThgGq7kElAY1e3BU2o1Mj9wzNP3dhGCZaLVEmUleZanqAcbeNgn4+jIVU/mbR02jvVJv/leQ5jFcxCVPaEnnFLZAKtbuRfBxDX7vwqUWfxg2dkgJaXpqUKpsE5jxRrQ6EHDMvZY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714401942; c=relaxed/simple; bh=k7yssPLl4cYxHXyuaFfTk1eIg9XDOAgEkwYZs+A/6+Y=; h=Date:Message-Id:In-Reply-To:References:Subject:MIME-Version: Content-Type:From:To:Cc; b=Upo9rjNLD8poYag7dp059SOqFWtZ+ziX96y2XY2AF4bmI11mGNzq9B90EWyNqHxFyzZ3VUMyRLUM8WLlwe92xdstpc1PTnSfRMphyj2xdFDVu5EvFkb8/h6P1wUplS4cYa3xu+gIBgc6mKGad91I77PTq5KJsBN2gLpaFYD6P0M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=rere.qmqm.pl; spf=pass smtp.mailfrom=rere.qmqm.pl; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b=K/6yZKWl; arc=none smtp.client-ip=91.227.64.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=rere.qmqm.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rere.qmqm.pl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1714401929; bh=k7yssPLl4cYxHXyuaFfTk1eIg9XDOAgEkwYZs+A/6+Y=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=K/6yZKWlXnXuIAKoHr8Up9gv8Xr1P9W4PDTG7JgJoiRBvl00GyLGx8jdDUfHnFTlb JgIFTglD3fLXds8DHiufcvT4RF9DF7XNXdtsnT+sCLJEGzXLnjKWGpV3iytmFBJK3w yASZcniKZ8d9qgxf0S3xMjICRi7clmRUQ7AE1bpedNPviPbsskDL80xX7GaxD6sVn7 zAdS4iP6GBOYaDqSQxq6xwUyoICJ7D8oK0LWN240MPqhk8wuCsOJvqx/9XBWkVZXEf hJl3MhDbym+ZaSEWl7N2V9ZP4jt9j1sium6WqLffrI74nLhK0OsLGcqXLfsPo0l95v sXjXGztBpywKg== Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4VSmMs287zzFK; Mon, 29 Apr 2024 16:45:29 +0200 (CEST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 1.0.5 at mail Date: Mon, 29 Apr 2024 16:45:29 +0200 Message-Id: <43306deb3b0200298dded485bfa4057f37f1e7a5.1714399603.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH v2 05/12] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Deduplicate `ena_gpio_state` handling by pulling it into regulator_ena_gpio_ctrl(). Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a1573a7ff2b2..4cb30e49c03d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2625,6 +2625,10 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) if (!pin) return -EINVAL; + if (rdev->ena_gpio_state == enable) + return 0; + rdev->ena_gpio_state = enable; + if (enable) { /* Enable GPIO at initial use */ if (pin->enable_count == 0) @@ -2744,12 +2748,9 @@ static int _regulator_do_enable(struct regulator_dev *rdev) } if (rdev->ena_pin) { - if (!rdev->ena_gpio_state) { - ret = regulator_ena_gpio_ctrl(rdev, true); - if (ret < 0) - return ret; - rdev->ena_gpio_state = 1; - } + ret = regulator_ena_gpio_ctrl(rdev, true); + if (ret < 0) + return ret; } else if (rdev->desc->ops->enable) { ret = rdev->desc->ops->enable(rdev); if (ret < 0) @@ -2963,13 +2964,9 @@ static int _regulator_do_disable(struct regulator_dev *rdev) trace_regulator_disable(rdev_get_name(rdev)); if (rdev->ena_pin) { - if (rdev->ena_gpio_state) { - ret = regulator_ena_gpio_ctrl(rdev, false); - if (ret < 0) - return ret; - rdev->ena_gpio_state = 0; - } - + ret = regulator_ena_gpio_ctrl(rdev, false); + if (ret < 0) + return ret; } else if (rdev->desc->ops->disable) { ret = rdev->desc->ops->disable(rdev); if (ret != 0) -- 2.39.2