From patchwork Fri Oct 5 15:31:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 12020 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DDF1124156 for ; Fri, 5 Oct 2012 15:32:03 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 703B2A1889F for ; Fri, 5 Oct 2012 15:32:03 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so3999235iej.11 for ; Fri, 05 Oct 2012 08:32:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=AwmHKxDvBMj3qxOWx0u+M8RuD0gpjC7G3e7d7E2VV5U=; b=L8DWbY9miPARgorz5+stKokaM8irE6GRoK9d2LVPFvBtL12upasq0kdeHFoAIFf3sx 11R+EZ0IjWTIh4fAcb3AVG15M5LKdOm1lKGCH3OoTeR2UDQDnVYRqt2+W7Krd7FoQ+Nk ACIojJUB28DhSYuIF8b1tJ/jLYH2VTZCb2cErle3EyXt6kqQ1W32NN3fYFbVMBypqWaE e0Nj2hKe/AmseUVFpE7aXZ8BPWyrLfp7paZKC3T0qsVXInxjvrlLHumqio8EN5s2ISj4 DnwASlYc4gaLTYsXfXybUdfHIrftidm2sgW46AWjwtJ8qeKhDqUHs4/HCUgcY9lj2WXS mjKA== Received: by 10.42.84.69 with SMTP id k5mr7409894icl.5.1349451122742; Fri, 05 Oct 2012 08:32:02 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp132539igc; Fri, 5 Oct 2012 08:32:01 -0700 (PDT) Received: by 10.216.218.105 with SMTP id j83mr1052560wep.164.1349451120768; Fri, 05 Oct 2012 08:32:00 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id y49si12177936wen.33.2012.10.05.08.32.00 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Oct 2012 08:32:00 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-we0-f178.google.com with SMTP id r6so1331115wey.37 for ; Fri, 05 Oct 2012 08:32:00 -0700 (PDT) Received: by 10.180.88.130 with SMTP id bg2mr4053162wib.22.1349451120240; Fri, 05 Oct 2012 08:32:00 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id w8sm2906148wif.4.2012.10.05.08.31.58 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 05 Oct 2012 08:31:59 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones , Samuel Ortiz Subject: [PATCH 01/10] mfd: Prevent STMPE from abusing mfd_add_devices' irq_base parameter Date: Fri, 5 Oct 2012 16:31:37 +0100 Message-Id: <1349451107-8009-2-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349451107-8009-1-git-send-email-lee.jones@linaro.org> References: <1349451107-8009-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkcsHaC5f5XsIkHiQDD6OuN4BELFnG+DqTCQYCv6Z4/Q2LL7ILHuJ0ZC9SFNUusrUWj8qgO Originally IRQ incrementers were provided in some template resource structures for keypad and touchscreen devices. These were passed as IORESOURCE_IRQs to MFD core in the usual way. The true device IRQs were instead added to the irq_base when mfd_add_devices was invoked. This is clearly an abuse of the call, and does not scale when IRQ Domains are brought into play. Before we can provide the STMPE with its own IRQ Domain we must first fix this. This patche keeps most of the driver's structure, keeping the template strategy. However, instead of providing the IRQ as an increment to irq_base, we dynamically populate the IORESOURCE_IRQ with the correct device IRQ. Cc: Samuel Ortiz Acked-by: Linus Walleij Signed-off-by: Lee Jones --- drivers/mfd/stmpe.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index c94f521..ad13cb0 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -310,14 +310,10 @@ static struct mfd_cell stmpe_gpio_cell_noirq = { static struct resource stmpe_keypad_resources[] = { { .name = "KEYPAD", - .start = 0, - .end = 0, .flags = IORESOURCE_IRQ, }, { .name = "KEYPAD_OVER", - .start = 1, - .end = 1, .flags = IORESOURCE_IRQ, }, }; @@ -397,14 +393,10 @@ static struct stmpe_variant_info stmpe801_noirq = { static struct resource stmpe_ts_resources[] = { { .name = "TOUCH_DET", - .start = 0, - .end = 0, .flags = IORESOURCE_IRQ, }, { .name = "FIFO_TH", - .start = 1, - .end = 1, .flags = IORESOURCE_IRQ, }, }; @@ -959,10 +951,10 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe) } static int __devinit stmpe_add_device(struct stmpe *stmpe, - struct mfd_cell *cell, int irq) + struct mfd_cell *cell) { return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, - NULL, stmpe->irq_base + irq, NULL); + NULL, stmpe->irq_base, NULL); } static int __devinit stmpe_devices_init(struct stmpe *stmpe) @@ -970,7 +962,7 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe) struct stmpe_variant_info *variant = stmpe->variant; unsigned int platform_blocks = stmpe->pdata->blocks; int ret = -EINVAL; - int i; + int i, j; for (i = 0; i < variant->num_blocks; i++) { struct stmpe_variant_block *block = &variant->blocks[i]; @@ -978,8 +970,17 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe) if (!(platform_blocks & block->block)) continue; + for (j = 0; j < block->cell->num_resources; j++) { + struct resource *res = + (struct resource *) &block->cell->resources[j]; + + /* Dynamically fill in a variant's IRQ. */ + if (res->flags & IORESOURCE_IRQ) + res->start = res->end = block->irq + j; + } + platform_blocks &= ~block->block; - ret = stmpe_add_device(stmpe, block->cell, block->irq); + ret = stmpe_add_device(stmpe, block->cell); if (ret) return ret; }