Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp482063ybl; Fri, 24 Jan 2020 04:07:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxEgexFQi4Qbk4TskAAHvaWbrr0iFeReeY5NmxEmzyjI+f0YEfhw2F946geDd5x6PgeJWym X-Received: by 2002:aca:72d0:: with SMTP id p199mr1870908oic.40.1579867631074; Fri, 24 Jan 2020 04:07:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579867631; cv=none; d=google.com; s=arc-20160816; b=fvHVBvpyYBpDFkf//aMYtbcGKiyP7zSIMCzdqyB8GyV5vUTmjELyeVf9vz+BdyK1Lk v2kTjlmg9n4/2ajpzStZogc8kLmiXS161zcZvWjaYh9Q0hh7s7hNN5HcOoGFcVfx0EfV p7cvrX+wc97gTltiGeX5FFW7FYdKUueUWXBsIYRdHLJMP3TpgDXEJ7p+ZRGWH6QncfdG C5kxIsJvFY2HM0OSvRGOVnEm3WCS2lbNg5L3uK7XU10pr+0SP33J1ugzfdxHKTE3yBZY iqfVyxk5NzVTFCeQWuBlEiGEkhKNKz0wP+lFAcG5+mDu7wyMOjC1CUyC0gayMMAddo6i tWUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3DMrnUHjuwmN6PWKbW4l7SlZhYRmYN8XLbAyVu3OQ+U=; b=xUdw782As8pEN6XjVQ/akxhY7EZ48e+VbKX359YxkW6dFTicUcDroDq9SkXgNaGz/I EUks6nV2NSvem43jnjrJeUCxonWD4R1yeTNx7ouPK9SjJKBibTQV0ZSpvLsILRA5UDd4 DHVDE8w2c53T3+R6X+CGy82/vem1m8IcgM3w2ox3L86Sgur1AyM3qcmt9fn13rZEKrJk dThsYvzbKLRCAPE7PIVgw/nbJmUu92NjXkXSkX8on7N2gm3qMVEKzkNlmpcXKCcKkojf LzCqdblWK0j6rUwkIF6S0sk1rPK1vkYDnxTrcuzaOfp+dIdykFS1viPgHQCWhAKALNAA uWJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Exai8LaW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si2204302oic.153.2020.01.24.04.06.58; Fri, 24 Jan 2020 04:07:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Exai8LaW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731615AbgAXJjV (ORCPT + 99 others); Fri, 24 Jan 2020 04:39:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:36440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731589AbgAXJjQ (ORCPT ); Fri, 24 Jan 2020 04:39:16 -0500 Received: from localhost (unknown [145.15.244.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF6F120838; Fri, 24 Jan 2020 09:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579858755; bh=ejhYGlJz29qxxXkISQoQ1D5EU/HBA6lMprgq1m3Zw8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Exai8LaWVl5cCsTHlt8HlyGM1b4evtisH2b7KiH1DxCfDIh08D/wTeEPFhEN9hpOV /uJOsiWUnZ4ONLyXKHmOsU57FtTycPX8Yhwq5ACSxjpwPUSOcwjuebGD/JYbjIQ7X5 dbujnhfBbA2xCU2urKkQWxyzq399eVzZMiY/SMIg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Andy Shevchenko , Linus Walleij Subject: [PATCH 5.4 048/102] gpiolib: No need to call gpiochip_remove_pin_ranges() twice Date: Fri, 24 Jan 2020 10:30:49 +0100 Message-Id: <20200124092813.549446778@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124092806.004582306@linuxfoundation.org> References: <20200124092806.004582306@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andy Shevchenko commit 2f4133bb5f14f49a99acf0cc55b84996dbfb4dff upstream. of_gpiochip_add(), when fails, calls gpiochip_remove_pin_ranges(). ADD: gpiochip_add_data_with_key() -> of_gpiochip_add() -> (ERROR path) gpiochip_remove_pin_ranges() At the same time of_gpiochip_remove() calls exactly the above mentioned function unconditionally and so does gpiochip_remove(). REMOVE: gpiochip_remove() -> gpiochip_remove_pin_ranges() of_gpiochip_remove() -> gpiochip_remove_pin_ranges() Since gpiochip_remove() calls gpiochip_remove_pin_ranges() unconditionally, we have duplicate call to the same function when it's not necessary. Move gpiochip_remove_pin_ranges() from of_gpiochip_add() to gpiochip_add() to avoid duplicate calls and be consistent with the explicit call in gpiochip_remove(). Fixes: e93fa3f24353 ("gpiolib: remove duplicate pin range code") Depends-on: f7299d441a4d ("gpio: of: Fix of_gpiochip_add() error path") Cc: Geert Uytterhoeven Signed-off-by: Andy Shevchenko Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib-of.c | 5 +---- drivers/gpio/gpiolib.c | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-) --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -909,16 +909,13 @@ int of_gpiochip_add(struct gpio_chip *ch of_node_get(chip->of_node); ret = of_gpiochip_scan_gpios(chip); - if (ret) { + if (ret) of_node_put(chip->of_node); - gpiochip_remove_pin_ranges(chip); - } return ret; } void of_gpiochip_remove(struct gpio_chip *chip) { - gpiochip_remove_pin_ranges(chip); of_node_put(chip->of_node); } --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1452,6 +1452,7 @@ err_remove_of_chip: gpiochip_free_hogs(chip); of_gpiochip_remove(chip); err_free_gpiochip_mask: + gpiochip_remove_pin_ranges(chip); gpiochip_free_valid_mask(chip); err_remove_from_list: spin_lock_irqsave(&gpio_lock, flags); @@ -1507,8 +1508,8 @@ void gpiochip_remove(struct gpio_chip *c gdev->chip = NULL; gpiochip_irqchip_remove(chip); acpi_gpiochip_remove(chip); - gpiochip_remove_pin_ranges(chip); of_gpiochip_remove(chip); + gpiochip_remove_pin_ranges(chip); gpiochip_free_valid_mask(chip); /* * We accept no more calls into the driver from this point, so