From patchwork Sun Nov 13 23:09:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 81985 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp764912qge; Sun, 13 Nov 2016 15:09:14 -0800 (PST) X-Received: by 10.98.158.90 with SMTP id s87mr29811171pfd.62.1479078554826; Sun, 13 Nov 2016 15:09:14 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ec5si16641968pad.330.2016.11.13.15.09.14; Sun, 13 Nov 2016 15:09:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753676AbcKMXJN (ORCPT + 4 others); Sun, 13 Nov 2016 18:09:13 -0500 Received: from mail-lf0-f47.google.com ([209.85.215.47]:35695 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752814AbcKMXJM (ORCPT ); Sun, 13 Nov 2016 18:09:12 -0500 Received: by mail-lf0-f47.google.com with SMTP id b14so46695720lfg.2 for ; Sun, 13 Nov 2016 15:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=GnykPu4nbZG5LZM9dkq7Q/JgRdSEBY1P1RFKHyIt/Fs=; b=WYdPIz7CU74wQG3yf7hQi8ZHtrLN9COINorvDv4V0FNEnoriBZq+ikOCE+d2f95aG5 j0YIfr8wXZcHUfkCjeoJblp4XxMm5jNpoqQYTtqeQSi0CZiL8yCkRcT3UPXg5Z6p4L9x 6lHUouj2Nm/Mdad4+4MBxwHVtk2lZtaot52YU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=GnykPu4nbZG5LZM9dkq7Q/JgRdSEBY1P1RFKHyIt/Fs=; b=SLHHsdaUaIbDtCGBWBUkoP7TUWgtzgzeWQElNXb7R+A8X0lQVXQos9uPlH1PlD/7sV ewnZrREpX7Qsd/Li7AD+5sYTR3MDNWNFmwZpZlPSr78l/GaaosFfFrPO6jef0sat6IdW rrDuVVMq9m+75eB0ITcEBpr3Y2sizDCvzU7OS6B1MGK32Iqe3zcIBFg+/tRPTBRnY1Ql MN/lB0pyFQsBIQq+aLSde19WuvOz9WS7TEmxriAe9Vbe9kBkLUXkYl2HxATVB7RSZT99 dt5bZZ7xCATa7sIN+JanQsA++ktK1wSfU3W/RJPgIiRAdqeaO+yeIyU+SDjL7qO0yQ2/ pa8g== X-Gm-Message-State: ABUngvdGKPCR6fkCsKNrunI0bhwcdU8YAszwceDMGtbxh0vTf0o8GQEP7k9VrIWCoRIQ4p7k X-Received: by 10.25.23.154 with SMTP id 26mr6811220lfx.86.1479078550826; Sun, 13 Nov 2016 15:09:10 -0800 (PST) Received: from fecusa.localdomain (c-357171d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.113.53]) by smtp.gmail.com with ESMTPSA id 125sm4532224ljj.26.2016.11.13.15.09.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Nov 2016 15:09:10 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Alexandre Courbot Cc: Linus Walleij Subject: [PATCH] gpio: tag line labels used for interrupts Date: Mon, 14 Nov 2016 00:09:07 +0100 Message-Id: <1479078547-20069-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When a GPIO line is marked as used for an interrupt, it is helpful to set the label to "interrupt" so we know what is going on when inspecting the lines. If a GPIO is already properly named by gpiod_get*() we don't need to do this. It only happens when a line is used from the irqchip side of a GPIO driver without communicating with the GPIO side, such as when gpiochip is used as interrupt provider in the device tree. If the line is still marked as used by "interrupt" when we unmark it as used by an interrupt, also remove this label from the descriptor. Also shape up the code around unmarking IRQ lines. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 26ce0743adae..865bca880bd7 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2688,6 +2688,15 @@ int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset) } set_bit(FLAG_USED_AS_IRQ, &desc->flags); + + /* + * If the consumer has not set up a label (such as when the + * IRQ is referenced from .to_irq()) we set up a label here + * so it is clear this is used as an interrupt. + */ + if (!desc->label) + desc_set_label(desc, "interrupt"); + return 0; } EXPORT_SYMBOL_GPL(gpiochip_lock_as_irq); @@ -2702,10 +2711,17 @@ EXPORT_SYMBOL_GPL(gpiochip_lock_as_irq); */ void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset) { - if (offset >= chip->ngpio) + struct gpio_desc *desc; + + desc = gpiochip_get_desc(chip, offset); + if (IS_ERR(desc)) return; - clear_bit(FLAG_USED_AS_IRQ, &chip->gpiodev->descs[offset].flags); + clear_bit(FLAG_USED_AS_IRQ, &desc->flags); + + /* If we only had this marking, erase it */ + if (desc->label && !strcmp(desc->label, "interrupt")) + desc_set_label(desc, NULL); } EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq);