From patchwork Mon Nov 5 15:10:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 1698411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id BECCBDF2AB for ; Mon, 5 Nov 2012 15:13:20 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TVOKQ-0005Zb-GB; Mon, 05 Nov 2012 15:11:07 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TVOKD-0005VX-9x for linux-arm-kernel@lists.infradead.org; Mon, 05 Nov 2012 15:10:54 +0000 Received: by mail-wg0-f49.google.com with SMTP id gg4so2667270wgb.18 for ; Mon, 05 Nov 2012 07:10:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=3T/uWALXUXWoRZOGtddJgNySm0nW1WoJC2PwA1dCJLs=; b=ahQWd6cZFiz0mKmJOAM4/XiFK/37aa0/v5pKdvRhDYB9PTBdcZYfR57n1R0hF/Hidd HfzX+PJdY7C1tNEl7jx+6vMUgT43plpWrz9/NokfYc74giuNAFYfdAQ/OS/0kwKjJyAl wv1hptE5n3bvhkpZ6VmaDO79IHixMZ5UBdeHDxRLeeHPSCk6NiTSuv7A1TW8M1JX4cmu isb7moxUfPv9s5wKC88kL+8ObhNXtC+MWQ5m3kO54/N5oRy3i/rtI6UZs9ASmV9+tlCb 70xguN22qAmua7cMyxoo281Fq5Q+mNBh05J/QjWYSRF5uqsVCwL9fmBFZ+s7DgKHfhxN o/8w== Received: by 10.180.100.97 with SMTP id ex1mr13657599wib.17.1352128252973; Mon, 05 Nov 2012 07:10:52 -0800 (PST) Received: from laptop.vlan14.pylonone.local (78.Red-88-2-49.staticIP.rima-tde.net. [88.2.49.78]) by mx.google.com with ESMTPS id ea9sm12275388wib.11.2012.11.05.07.10.51 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Nov 2012 07:10:52 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, sameo@linux.intel.com Subject: [PATCH 2/8] mfd: Prevent STMPE from abusing mfd_add_devices' irq_base parameter Date: Mon, 5 Nov 2012 16:10:30 +0100 Message-Id: <1352128236-11554-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352128236-11554-1-git-send-email-lee.jones@linaro.org> References: <1352128236-11554-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQm3VWNTrHJ5MLtMAyYuaIdjAeXCUYzf0mJ8lhL3Ckp+KMqxG/CayC7eV5K9sItiX1lMFnV0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121105_101053_514005_38C21B83 X-CRM114-Status: GOOD ( 14.08 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.49 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Lee Jones , linus.walleij@stericsson.com, arnd@arndb.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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: Arnd Bergmann 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; }