From patchwork Wed Nov 20 09:39:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 21649 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 97C3623FDC for ; Wed, 20 Nov 2013 09:39:13 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id f12sf16522887vbg.10 for ; Wed, 20 Nov 2013 01:39:12 -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=8DhgoZje3TKe1QpzoRZN/6P5zzDLnzs2vBWJcrQeO7M=; b=hM2gT9wb8JhSibApWhtnerqwHUQMVxNIe4/VlkT1VKo6J6k1dEOT6QMj8UpMz0YgBF HT2+yZFNvmNIgnqrJbDadVvdP68Q14y7xxy+DAMVyrHSo7CigdTBj/a9xhZod864ypAs QInhxGTPaXLySHkC/WnOM6hKretYC8vAljHaA0SaIdWm6RFgQnIqSQunSIQyCulVya8E XgbRd1SxHcJJMMeAgjp4nHOanJkzOYyf4Hu+xohwjWkIwrarVR33lBvSPgdA7F4UoudV Hz+O4vbdTM+gLqOxycnYlMukWlRIIIM8UswoZJJ3ggyKX9uk2DPTXFC/EfALtKb/N/R3 9q1g== X-Gm-Message-State: ALoCoQkVfLoWycWk6mA/20rNHrKm496KozyCVRWwpL0662EWatMysvfw2fmQCRXFZAtXOvzyLJpQ X-Received: by 10.58.201.36 with SMTP id jx4mr287033vec.35.1384940352595; Wed, 20 Nov 2013 01:39:12 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.196 with SMTP id kw4ls220793qeb.90.gmail; Wed, 20 Nov 2013 01:39:12 -0800 (PST) X-Received: by 10.52.64.143 with SMTP id o15mr21721193vds.16.1384940352465; Wed, 20 Nov 2013 01:39:12 -0800 (PST) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id v5si9234757ves.118.2013.11.20.01.39.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Nov 2013 01:39:12 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id i12so707474vbh.19 for ; Wed, 20 Nov 2013 01:39:12 -0800 (PST) X-Received: by 10.52.119.228 with SMTP id kx4mr21649179vdb.12.1384940352344; Wed, 20 Nov 2013 01:39:12 -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 u4csp341041vcz; Wed, 20 Nov 2013 01:39:11 -0800 (PST) X-Received: by 10.180.211.49 with SMTP id mz17mr455264wic.54.1384940351319; Wed, 20 Nov 2013 01:39:11 -0800 (PST) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by mx.google.com with ESMTPS id fv15si9100617wjc.70.2013.11.20.01.39.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Nov 2013 01:39:11 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.173 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=209.85.212.173; Received: by mail-wi0-f173.google.com with SMTP id hm4so1183993wib.0 for ; Wed, 20 Nov 2013 01:39:10 -0800 (PST) X-Received: by 10.194.23.8 with SMTP id i8mr373323wjf.68.1384940350518; Wed, 20 Nov 2013 01:39:10 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id s2sm14247920wiy.7.2013.11.20.01.39.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Nov 2013 01:39:09 -0800 (PST) From: Linus Walleij To: linux-gpio@vger.kernel.org, Magnus Damm , Ian Molton , Simon Horman Cc: Alexandre Courbot , Linus Walleij Subject: [PATCH] gpio: em: lock IRQs when starting them Date: Wed, 20 Nov 2013 10:39:04 +0100 Message-Id: <1384940344-19708-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.212.46 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 --- drivers/gpio/gpio-em.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index ec190361bf2e..bbf242312bda 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -99,6 +99,25 @@ 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)); + return 0; +} + +static void em_gio_irq_shutdown(struct irq_data *d) +{ + struct em_gio_priv *p = irq_data_get_irq_chip_data(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 +347,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 +359,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,