From patchwork Tue Nov 7 18:15:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 835401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N3gCNx2V"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yWd1m2gLLz9sRn for ; Wed, 8 Nov 2017 05:17:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932473AbdKGSQb (ORCPT ); Tue, 7 Nov 2017 13:16:31 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:55862 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757468AbdKGSQY (ORCPT ); Tue, 7 Nov 2017 13:16:24 -0500 Received: by mail-wr0-f193.google.com with SMTP id l8so79269wre.12; Tue, 07 Nov 2017 10:16:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4kTj5AbQM7gu8EqJ2OOHUa5VHpGYcr95rRrmuaRz+iE=; b=N3gCNx2VOtgpjs8psoJkGTNx/XfR0ZOqD2AQJOPPaqeglZdHER7TsqpRKnBT2uaGAk ycQ/2Ndv04EAUPx68b9cOBMuRgIS9ggMW98G1PEHRUGwouvVPX4bGupcOsQenzbuUNqp lkE/tu9Mw16CXmCuY30+4yWslU8gMAvFIz51kFnulN5U0RfouTTDHTpEAXX7VtK3a5hv LK4kxu8ehwJ1GExNGMw4liD9M14GVfqffJLFDl4AIaSFbiRurSBzXqPU2k6Kz2XJd0YG 43Ly+gPjRzpPOBPDJK2GAGvOGet1Wo8EljX0oGsotVTrfSkKDCOeUKdj1FrrTdz7VaJQ n4NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4kTj5AbQM7gu8EqJ2OOHUa5VHpGYcr95rRrmuaRz+iE=; b=N9WUCb+jf9ec5whlbdwFE5qKAqUHodEtULzVJehigNvCHywbQuyGKRS2a/AcxoGbuF XEVbgtz8Sfh1//j4IetCW/F9ZnPq63ieTrgF+0XVsjlEuQN2ACUdHPcjx36lPeI1xaz4 fU4BrIS9/MuJFQBma3WE/7GZV2Cg3im/vf08zy1VVLl+0f6jfOcuewriL1nFBdMsKSPa bMBgvayedvn6ASoFdnOXkOrZVvbgugtjw7wUqhPulwmxgcnDQYFE91zS03n/is6qfzfS lgxfAJ1LwvgI1HMJPYJz+kzgmL/GWYT3EbxhQeUB7dPJhNcxArb8K0YmkR5X0yjRCLui hQVQ== X-Gm-Message-State: AJaThX5JQjjLudCBAxfJrj1Sp2esXFpXY47mrU4aCDdeSxHQ9lJceGJi qvatUnqBal9Ite2LoY0tigk= X-Google-Smtp-Source: ABhQp+Sp/TaRSvqy46qjOGO1bFtClpZ/a+bFjKSxQ8wOOLmfxGkDN+a/PubQlL6R+sL1f6MCoTTzJQ== X-Received: by 10.223.160.217 with SMTP id n25mr7006538wrn.27.1510078582785; Tue, 07 Nov 2017 10:16:22 -0800 (PST) Received: from localhost (p200300E41BC8E9001FF851737372D2C2.dip0.t-ipconnect.de. [2003:e4:1bc8:e900:1ff8:5173:7372:d2c2]) by smtp.gmail.com with ESMTPSA id 55sm3020769wrw.60.2017.11.07.10.16.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Nov 2017 10:16:22 -0800 (PST) From: Thierry Reding To: Linus Walleij , Grygorii Strashko Cc: Jonathan Hunter , linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 14/15] gpio: Introduce struct gpio_irq_chip.first Date: Tue, 7 Nov 2017 19:15:58 +0100 Message-Id: <20171107181559.6318-15-thierry.reding@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171107181559.6318-1-thierry.reding@gmail.com> References: <20171107181559.6318-1-thierry.reding@gmail.com> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Thierry Reding Some GPIO chips cannot support sparse IRQ numbering and therefore need to manually allocate their interrupt descriptors statically. For these cases, a driver can pass the first allocated IRQ via the struct gpio_irq_chip's "first" field and thereby cause the IRQ domain to map all IRQs during initialization. Suggested-by: Grygorii Strashko Signed-off-by: Thierry Reding --- drivers/gpio/gpiolib.c | 3 ++- include/linux/gpio/driver.h | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 17f4b843f058..35fb13e98d84 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1778,7 +1778,8 @@ static int gpiochip_add_irqchip(struct gpio_chip *gpiochip) ops = &gpiochip_domain_ops; gpiochip->irq.domain = irq_domain_add_simple(np, gpiochip->ngpio, - 0, ops, gpiochip); + gpiochip->irq.first, + ops, gpiochip); if (!gpiochip->irq.domain) return -EINVAL; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 3fd7438f3596..241af05498f9 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -129,6 +129,14 @@ struct gpio_irq_chip { * in IRQ domain of the chip. */ unsigned long *valid_mask; + + /** + * @first: + * + * Required for static IRQ allocation. If set, irq_domain_add_simple() + * will allocate and map all IRQs during initialization. + */ + unsigned int first; }; static inline struct gpio_irq_chip *to_gpio_irq_chip(struct irq_chip *chip)