From patchwork Mon May 27 19:12:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 2621381 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id E92BFDF215 for ; Mon, 27 May 2013 19:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756866Ab3E0TNQ (ORCPT ); Mon, 27 May 2013 15:13:16 -0400 Received: from www.linutronix.de ([62.245.132.108]:48440 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754068Ab3E0TNP (ORCPT ); Mon, 27 May 2013 15:13:15 -0400 Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by Galois.linutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Uh2qK-0008KD-Ia; Mon, 27 May 2013 21:12:28 +0200 From: Sebastian Andrzej Siewior To: linux-input@vger.kernel.org, linux-iio@vger.kernel.org Cc: Samuel Ortiz , Jonathan Cameron , Dmitry Torokhov , Felipe Balbi , Sebastian Andrzej Siewior , Mark Brown Subject: [PATCH 19/19] mfd/ti_am335x_tscadc: add private lock/unlock function for regmap read/write Date: Mon, 27 May 2013 21:12:06 +0200 Message-Id: <1369681926-22185-20-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369681926-22185-1-git-send-email-bigeasy@linutronix.de> References: <1369681926-22185-1-git-send-email-bigeasy@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Without this, devm_regmap_init_mmio() creates & uses a simple spin_lock() and this should be enough. Within the probe function the registers are read and written in process context. Later they are accessed from the ISR and lockdep complains because now the lock is taken suddenly with IRQs enabled. Currently I don't see any other way to keep lockdep quiet than doing this. Cc: Mark Brown Signed-off-by: Sebastian Andrzej Siewior --- drivers/mfd/ti_am335x_tscadc.c | 17 +++++++++++++++++ include/linux/mfd/ti_am335x_tscadc.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c index 5e4076f..04ed630 100644 --- a/drivers/mfd/ti_am335x_tscadc.c +++ b/drivers/mfd/ti_am335x_tscadc.c @@ -42,11 +42,27 @@ static void tscadc_writel(struct ti_tscadc_dev *tsadc, unsigned int reg, regmap_write(tsadc->regmap_tscadc, reg, val); } +static void tscadc_lock_spinlock(void *__map) +{ + struct ti_tscadc_dev *tsadc = __map; + + spin_lock_irqsave(&tsadc->reg_map_lock, tsadc->reg_map_flags); +} + +static void tscadc_unlock_spinlock(void *__map) +{ + struct ti_tscadc_dev *tsadc = __map; + + spin_unlock_irqrestore(&tsadc->reg_map_lock, tsadc->reg_map_flags); +} + static const struct regmap_config tscadc_regmap_config = { .name = "ti_tscadc", .reg_bits = 32, .reg_stride = 4, .val_bits = 32, + .lock = tscadc_lock_spinlock, + .unlock = tscadc_unlock_spinlock, }; static void tscadc_idle_config(struct ti_tscadc_dev *config) @@ -110,6 +126,7 @@ static int ti_tscadc_probe(struct platform_device *pdev) } else tscadc->irq = err; + spin_lock_init(&tscadc->reg_map_lock); res = devm_request_mem_region(&pdev->dev, res->start, resource_size(res), pdev->name); if (!res) { diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h index c985262..284e482 100644 --- a/include/linux/mfd/ti_am335x_tscadc.h +++ b/include/linux/mfd/ti_am335x_tscadc.h @@ -129,6 +129,8 @@ #define TSCADC_CELLS 2 struct ti_tscadc_dev { + spinlock_t reg_map_lock; + unsigned long reg_map_flags; struct device *dev; struct regmap *regmap_tscadc; void __iomem *tscadc_base;