From patchwork Fri Nov 29 09:48:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 21858 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B2F5023FC4 for ; Fri, 29 Nov 2013 09:48:30 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id w8sf21050016vbj.6 for ; Fri, 29 Nov 2013 01:48:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=nj5QM58My5cOcyPFIlvg0mJNftxBoLUZpTZGmhMIpbs=; b=R9IDb0Dvu2czte90EqBCK9riUiA6nebPIpmpVPkyv/p/ivfihlugEE4T20yNcz3VXN RM34MkBEPVTa5VMvZLCR/yoJ9MnTUMCDjuKY0BB93tu3B4KXF2aSlqSTvnivhL9TmsbV 3OecUXvjWKuzhjIPsjItD0GztzvX4nUIse4cgW9JQbYvuEkYrGjy1pwEhas33y0OYAnt KOkMRPpmN3AESYf3n+rKh/NfuQjkxeR5vH9nkPBZn/2O1ooehSNug9kAnEvQsbklg2JO TA6upB3qzBVSNRGHvVgtldcC7SuRacVB+NttUkzU4s/sllbztUCVpFKaXB9P1fKmtgL6 s7/w== X-Gm-Message-State: ALoCoQkXIRO6/Id43WbQhihGYcqBFrDfLn6C6OcD3+4OztNa4Wvf1azJCq9iI48HD6e3ypBzeSRi X-Received: by 10.236.135.79 with SMTP id t55mr23313320yhi.39.1385718509655; Fri, 29 Nov 2013 01:48:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.3.165 with SMTP id d5ls2496235qed.77.gmail; Fri, 29 Nov 2013 01:48:29 -0800 (PST) X-Received: by 10.58.96.15 with SMTP id do15mr4368veb.56.1385718509522; Fri, 29 Nov 2013 01:48:29 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id at8si24594358vec.46.2013.11.29.01.48.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 01:48:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id oy12so7045265veb.1 for ; Fri, 29 Nov 2013 01:48:29 -0800 (PST) X-Received: by 10.58.228.231 with SMTP id sl7mr35478vec.49.1385718509286; Fri, 29 Nov 2013 01:48:29 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp77193vcz; Fri, 29 Nov 2013 01:48:28 -0800 (PST) X-Received: by 10.152.115.230 with SMTP id jr6mr554667lab.45.1385718508057; Fri, 29 Nov 2013 01:48:28 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx.google.com with ESMTPS id yg9si22144197lbb.53.2013.11.29.01.48.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 01:48:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.217.182 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id u14so6763409lbd.41 for ; Fri, 29 Nov 2013 01:48:27 -0800 (PST) X-Received: by 10.112.167.3 with SMTP id zk3mr17938922lbb.23.1385718507386; Fri, 29 Nov 2013 01:48:27 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id di11sm70571388lac.0.2013.11.29.01.48.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2013 01:48:26 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Thierry Reding , Lars Poeschel Cc: Alexandre Courbot , Linus Walleij Subject: [PATCH v3] gpio: lock adnp IRQs when starting them Date: Fri, 29 Nov 2013 10:48:18 +0100 Message-Id: <1385718498-28525-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This uses the new API for tagging GPIO lines as in use by IRQs. This enforces a few semantic checks on how the underlying GPIO line is used. Only compile tested on the lpc32xx. Cc: Lars Poeschel Cc: Thierry Reding Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Switch to using the startup()/shutdown() callbacks again. Still satisfy the mask/unmask semantics. ChangeLog v1->v2: - Use the .enable() callback from the irq_chip - Call .unmask() from the .enable() callback to satisfy semantics. --- drivers/gpio/gpio-adnp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index b204033acaeb..a7b471977dc5 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c @@ -408,6 +408,27 @@ static void adnp_irq_bus_unlock(struct irq_data *data) mutex_unlock(&adnp->irq_lock); } +static unsigned int adnp_irq_startup(struct irq_data *data) +{ + struct adnp *adnp = irq_data_get_irq_chip_data(data); + + if (gpio_lock_as_irq(&adnp->gpio, data->hwirq)) + dev_err(adnp->gpio.dev, + "unable to lock HW IRQ %lu for IRQ\n", + data->hwirq); + /* Satisfy the .enable semantics by unmasking the line */ + adnp_irq_unmask(data); + return 0; +} + +static void adnp_irq_shutdown(struct irq_data *data) +{ + struct adnp *adnp = irq_data_get_irq_chip_data(data); + + adnp_irq_mask(data); + gpio_unlock_as_irq(&adnp->gpio, data->hwirq); +} + static struct irq_chip adnp_irq_chip = { .name = "gpio-adnp", .irq_mask = adnp_irq_mask, @@ -415,6 +436,8 @@ static struct irq_chip adnp_irq_chip = { .irq_set_type = adnp_irq_set_type, .irq_bus_lock = adnp_irq_bus_lock, .irq_bus_sync_unlock = adnp_irq_bus_unlock, + .irq_startup = adnp_irq_startup, + .irq_shutdown = adnp_irq_shutdown, }; static int adnp_irq_map(struct irq_domain *domain, unsigned int irq,