Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp46668pxa; Mon, 10 Aug 2020 18:11:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzg6xuadEk4A/eT3LtRxPKz4qcLVaOxBy5DCCggd0eHwHtJTx54b+0gx8lQIXt7j6uickkY X-Received: by 2002:a17:906:7a16:: with SMTP id d22mr24622075ejo.478.1597108318930; Mon, 10 Aug 2020 18:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597108318; cv=none; d=google.com; s=arc-20160816; b=rxr/G5egTpgZ1Apr/uQELFEb9BPKWzTgrymnyr+sDkcHMxcnkwfCZrOLWA5x5T1YQP 4IpSFewoOhdQO+F2PHvFtTdzcl8voftgYMLPxeZSQMNfzLpXaNO3W2nkGxiAcLHtN/Mq cOO0UKDznaaeoBmL8eSIG9jcUgZ4sagaF6I2MV6HadIIu/MAAxIngd4kd0KBjlPCVMW/ Hp3XZjS0mdSg9IllvOS5ufMxqs8IHVxWzFevhf8ysH47EEM+xGTSrU2Quz6rTIpaaEK2 0QpSCxTiMeufVTvGS2HbsIlQbBE46rYHZkGgg773m+0enw7Qn56SWSfWv+qhokcFe5Ul /Qbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:references:in-reply-to:message-id:date :dkim-signature; bh=K7+sJsq1/5JIEQr84Gc0mbvOsHbQwnH5xqz2F26lucc=; b=uk/yqlaI4CFsqV/E8whuIQUCoyjN3ay3LXScxxmGQoM2NZttPBb1dmc+bD71JsZE5i KL38h7xjBD0xJ79kVxxcF8fh69WM58/XMeTdfNak0X2Jh4XqkqmeLcSHEJjtDg1c5mGA +zk+Q9jsk/Xw+H33Jv5qAvoR7tWM+OcnEe68dhfJkxMQ7tWyBZuN/bgWBl5ZjZlaMLFF F5ZdZt6nM3Bwh/Fh+HRPlTOYzVdVlA+Ss/9aAHWPQZbb6fjnyZmR5ZIetJT7OYqjIy3m XJhrm8R67xVWpYD2oYAOr5vKjX+gBnlMyorelyMEzDbkIy91sVyo5tb382zPvIDEDx4T Nwug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=jWElF0wW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y22si11508063edv.326.2020.08.10.18.11.36; Mon, 10 Aug 2020 18:11:58 -0700 (PDT) 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=pass header.i=@rere.qmqm.pl header.s=1 header.b=jWElF0wW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727049AbgHKBIG (ORCPT + 99 others); Mon, 10 Aug 2020 21:08:06 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:48026 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727978AbgHKBHn (ORCPT ); Mon, 10 Aug 2020 21:07:43 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4BQZSY2hWzzL3; Tue, 11 Aug 2020 03:07:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1597108061; bh=XBigUQcy+V9cJkV3vEIxp3zZ8VW9N8bjjMb3WXILdFs=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=jWElF0wWl0RXfF9CyawDJe+2SCeIiU4od9RBi/GJMtx1NzFe+rGY+IfvH9vXBOWwq urMnQRHRNnxT8YXWziMVy8ABSkkwIAYMoOAgV+8a75epbaXxvR2o018Xd/KnNrgisj BjPKvzFwktqF4CqzocFPKJz+hQD1uQ8a47tBkrN5/sh1mLqqJ74z5UFe65L/QKg2Ar mDlWM4w5+zfAwVlcmQ8oIb0FRI2gp/Jn2msvm/rgGchPaY2HbWC2LA89uBH/pCPN8K f0ucJ219nZHjQYFpLXRWYK2DK7zl2Y5sSJljhpq6vTEFv4Kz6PYsJAgQ2oRtLagS9A 3dsuk9EJgaEMg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.4 at mail Date: Tue, 11 Aug 2020 03:07:40 +0200 Message-Id: In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 6/7] regulator: cleanup regulator_ena_gpio_free() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Dmitry Osipenko , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Vladimir Zapolskiy Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since only regulator_ena_gpio_request() allocates rdev->ena_pin, and it guarantees that same gpiod gets same pin structure, it is enough to compare just the pointers. Also we know there can be only one matching entry on the list. Rework the code take advantage of the facts. Signed-off-by: Michał Mirosław --- drivers/regulator/core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a9ff2ad55ee7..b85ec974944e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2260,19 +2260,19 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) /* Free the GPIO only in case of no use */ list_for_each_entry_safe(pin, n, ®ulator_ena_gpio_list, list) { - if (pin->gpiod == rdev->ena_pin->gpiod) { - if (pin->request_count <= 1) { - pin->request_count = 0; - gpiod_put(pin->gpiod); - list_del(&pin->list); - kfree(pin); - rdev->ena_pin = NULL; - return; - } else { - pin->request_count--; - } - } + if (pin != rdev->ena_pin) + continue; + + if (--pin->request_count) + break; + + gpiod_put(pin->gpiod); + list_del(&pin->list); + kfree(pin); + break; } + + rdev->ena_pin = NULL; } /** -- 2.20.1