From patchwork Tue Nov 26 10:16: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: 21772 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1C5A7202DA for ; Tue, 26 Nov 2013 10:16:31 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf18504231oag.4 for ; Tue, 26 Nov 2013 02:16:31 -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=JYHT0vvugQsTpJamq3FuimR+przZK6D4UWGwHnklZCE=; b=WhOh16Cn5m1R6H/NIcY1MO29ZBqfsuvQndVp+QsgOa9AXP1dwR3VqXNOulaiUe2vcF XEYRSucGeh6YBAECwr316aL5GeYgsFG9MJGYUKjVAlwyPG9Z2H3GWL0QwJFEufjTrScy Ioe51hVa4CsP5mRHm5dAWy0PNJqZ4gLvjb2wwa/TssnDBg0CN1p1RYk0gVHcGsd22HlQ ulNgOKdXFem5zBA5wP7WNOfu5KhGt8KHNJJq4TDn07jtZaXhKOFFw//KkB1b40U/ebac byveGrq/Vc2Pzt/vfDZfBpCKb+zNe+49CsxbxtWfeIarLTK4amgWSQeLg42uU2qzOfim Fj6A== X-Gm-Message-State: ALoCoQm1EHB7R5PvOqpd18c5ul9fulQhsNoQdZ8zOfg2eAIm7eF36CfiopVF1go8t3QSi00Bdweh X-Received: by 10.42.247.68 with SMTP id mb4mr9095098icb.14.1385460991125; Tue, 26 Nov 2013 02:16:31 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.40 with SMTP id h8ls2569256qeo.28.gmail; Tue, 26 Nov 2013 02:16:31 -0800 (PST) X-Received: by 10.58.144.168 with SMTP id sn8mr1699638veb.33.1385460991025; Tue, 26 Nov 2013 02:16:31 -0800 (PST) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id gs2si4794703vdc.5.2013.11.26.02.16.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 02:16:31 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ia6so3590659vcb.4 for ; Tue, 26 Nov 2013 02:16:31 -0800 (PST) X-Received: by 10.52.65.228 with SMTP id a4mr21451535vdt.16.1385460990919; Tue, 26 Nov 2013 02:16:30 -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 u4csp200840vcz; Tue, 26 Nov 2013 02:16:30 -0800 (PST) X-Received: by 10.112.155.70 with SMTP id vu6mr3874857lbb.41.1385460989754; Tue, 26 Nov 2013 02:16:29 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com [209.85.215.47]) by mx.google.com with ESMTPS id 9si17202235las.129.2013.11.26.02.16.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 02:16:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.47 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id ep20so3985809lab.6 for ; Tue, 26 Nov 2013 02:16:26 -0800 (PST) X-Received: by 10.112.135.67 with SMTP id pq3mr396293lbb.65.1385460986592; Tue, 26 Nov 2013 02:16:26 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id dv8sm30682183lbc.15.2013.11.26.02.16.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Nov 2013 02:16:25 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Magnus Damm , Ian Molton , Simon Horman Cc: Alexandre Courbot , Linus Walleij Subject: [PATCH v2] gpio: em: lock IRQs when starting them Date: Tue, 26 Nov 2013 11:16:18 +0100 Message-Id: <1385460978-4122-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.220.173 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. Also assign the gpio_chip.dev pointer to be used for error messages. Cc: Magnus Damm Cc: Ian Molton Cc: Simon Horman Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Satisfy implicit semantics by calling .enable and .disable callbacks in the startup/shutdown callbacks. --- drivers/gpio/gpio-em.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index ec190361bf2e..1cc53516e8b4 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -99,6 +99,27 @@ static void em_gio_irq_enable(struct irq_data *d) em_gio_write(p, GIO_IEN, BIT(irqd_to_hwirq(d))); } +static unsigned int em_gio_irq_startup(struct irq_data *d) +{ + struct em_gio_priv *p = irq_data_get_irq_chip_data(d); + + if (gpio_lock_as_irq(&p->gpio_chip, irqd_to_hwirq(d))) + dev_err(p->gpio_chip.dev, + "unable to lock HW IRQ %lu for IRQ\n", + irqd_to_hwirq(d)); + em_gio_irq_enable(d); + return 0; +} + +static void em_gio_irq_shutdown(struct irq_data *d) +{ + struct em_gio_priv *p = irq_data_get_irq_chip_data(d); + + em_gio_irq_disable(d); + gpio_unlock_as_irq(&p->gpio_chip, irqd_to_hwirq(d)); +} + + #define GIO_ASYNC(x) (x + 8) static unsigned char em_gio_sense_table[IRQ_TYPE_SENSE_MASK + 1] = { @@ -328,6 +349,7 @@ static int em_gio_probe(struct platform_device *pdev) gpio_chip->request = em_gio_request; gpio_chip->free = em_gio_free; gpio_chip->label = name; + gpio_chip->dev = &pdev->dev; gpio_chip->owner = THIS_MODULE; gpio_chip->base = pdata->gpio_base; gpio_chip->ngpio = pdata->number_of_pins; @@ -339,6 +361,8 @@ static int em_gio_probe(struct platform_device *pdev) irq_chip->irq_enable = em_gio_irq_enable; irq_chip->irq_disable = em_gio_irq_disable; irq_chip->irq_set_type = em_gio_irq_set_type; + irq_chip->irq_startup = em_gio_irq_startup; + irq_chip->irq_shutdown = em_gio_irq_shutdown; irq_chip->flags = IRQCHIP_SKIP_SET_WAKE; p->irq_domain = irq_domain_add_simple(pdev->dev.of_node,