Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2036288ybf; Mon, 2 Mar 2020 00:25:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwUrRe4Jsbtoqxax8YDlWsl9ddCJQBmkbiEEmpWIy1etSBGFJZAjZNccttqAINUxOq50vC9 X-Received: by 2002:aca:3189:: with SMTP id x131mr11007004oix.33.1583137533219; Mon, 02 Mar 2020 00:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583137533; cv=none; d=google.com; s=arc-20160816; b=Xbhw1Iv4jXmaVkMljYpYSUSi6rb/daumtiiPrOZUwcRmjA5LRMEwV6BQ2+dEx5JTgW FSqRo+slm1MUxJK3M2YzpKhOwAWxZr3Bh9/TsThv7xA/4yF/E/62wZMfyc1EGY/tOIXr dXz84S1nxSfoqAe4F6Gvk83nPbGBgYQoaK+blbXWpQhwj39tEgIWjk/83bbhrQk98RWv 9ohC0kRoSNTxjKmpyuYbx4OUwo+ofkqVcRVsU4qrWIePGBWfRCKSOznPO5L4ZdYifYr8 aQX0JOSmS6DJKIFdOy+3S81iueTtoSn5WAPigr/qG9KU1tQ/p2Ml5Rh2Xsd9yiviDeda ll/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=WO1BZaawujo6WSxtR/irXj5OrLdyeL8V5Zz/gOGvXU8=; b=Rrc6UffYVgKmeTBlZHI/kOOtHP2ThyfRXzgKQjUqXx0evi/oxSovOd/0uqazxWrrFf X+oO38qBCgr+FRpklSmM+DwNvx8+c1JyB69TyPC4WL4jeCsD7/ShGdHY3ubqJaJk6I5a 8ATt4Vb0RvY9s7OIu9jA682H2AEU/HDUYaTpO1atb8H/kqOyUj6dryFZjOZcdLMwoD1b 6w7rC5l4fUzEvt1t+UK9HAv6QfIV+/Ue5w1nd2REDauaYSGA5fKXLa7nunHji7KLvYSi 08yZ8e0teDpZdavY5fnDBqX8QvHlQ1qVh4edkvvOV4tujjFxOOH3a00WyknG9iZvqaRk +z1w== ARC-Authentication-Results: i=1; mx.google.com; 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 h17si6057423oib.234.2020.03.02.00.25.21; Mon, 02 Mar 2020 00:25:33 -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; 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 S1727357AbgCBIYw (ORCPT + 99 others); Mon, 2 Mar 2020 03:24:52 -0500 Received: from michel.telenet-ops.be ([195.130.137.88]:55554 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbgCBIYw (ORCPT ); Mon, 2 Mar 2020 03:24:52 -0500 Received: from ramsan ([84.195.182.253]) by michel.telenet-ops.be with bizsmtp id 9LQp220075USYZQ06LQpE9; Mon, 02 Mar 2020 09:24:49 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1j8gNd-0007XT-4J; Mon, 02 Mar 2020 09:24:49 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1j8gNd-0003EV-27; Mon, 02 Mar 2020 09:24:49 +0100 From: Geert Uytterhoeven To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] gpiolib: Fix inverted check in gpiochip_remove() Date: Mon, 2 Mar 2020 09:24:48 +0100 Message-Id: <20200302082448.11795-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The optimization to check for requested lines actually optimized for the uncomon error case, where one of the GPIO lines is still in use. Hence the error message must be printed when the loop is terminated early, not when it went through all available GPIO lines. Fixes: 869233f81337bfb3 ("gpiolib: Optimize gpiochip_remove() when check for requested line") Signed-off-by: Geert Uytterhoeven --- Noticed by review, tested by creating and destroying an otherwise unused GPIO aggregator, which triggers: gpio gpiochip8: REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4e78bdc2739693c3..6180cf84fab7ce5e 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1823,7 +1823,7 @@ void gpiochip_remove(struct gpio_chip *chip) } spin_unlock_irqrestore(&gpio_lock, flags); - if (i == gdev->ngpio) + if (i != gdev->ngpio) dev_crit(&gdev->dev, "REMOVING GPIOCHIP WITH GPIOS STILL REQUESTED\n"); -- 2.17.1