From patchwork Tue Sep 30 08:45:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 38130 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1ABEF202DB for ; Tue, 30 Sep 2014 08:45:44 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf5289872eek.0 for ; Tue, 30 Sep 2014 01:45:43 -0700 (PDT) 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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=P+sAIV9/jycjDg23BF203RYDBT7NiAOIXMKl+4v3Bow=; b=jy+D1ZO4oUXihrtorRrbVFCH1za/BkzQj3+SFHsz5IE7BEXmVZhz9FSNVncTtsU6an r0eTxdJuJrH0pUm9ryCpMzkx2Q8TD3O4EYaTxckNjMy0STEu9i+NW6ZFuapvEs/5qBB2 wwgMcJe1nbMTufCL4w4lSlDLkTtJC2D2UCOW/WgdY41ZRQHL+3qn/WjhL7hGIbycXX3N BiuFSVinf1KO1h8NodNyoWocdXw/5YWnJ2lKkumPzd3IlVlN5rbxrKwYI7vd7+DGdmZL 5iwBTrBy2XkzLZxl80L16Z/6Ycr1gOt8p+0fStez5yZ4uJSS1LqKjyQfYftzk/yEBtzb 58wg== X-Gm-Message-State: ALoCoQn83rrEK/M9nOMsDiCPmurQcnAtiFPzOlax5n8wipQr6Or0kELHoAgMAafxu5wIwulNRFRf X-Received: by 10.180.74.14 with SMTP id p14mr595534wiv.6.1412066742993; Tue, 30 Sep 2014 01:45:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.230 with SMTP id r6ls11659lal.92.gmail; Tue, 30 Sep 2014 01:45:42 -0700 (PDT) X-Received: by 10.112.130.129 with SMTP id oe1mr42504929lbb.4.1412066742841; Tue, 30 Sep 2014 01:45:42 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com [209.85.215.52]) by mx.google.com with ESMTPS id s1si21561396lag.123.2014.09.30.01.45.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Sep 2014 01:45:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id hz20so3092485lab.25 for ; Tue, 30 Sep 2014 01:45:42 -0700 (PDT) X-Received: by 10.112.4.33 with SMTP id h1mr42094478lbh.67.1412066742727; Tue, 30 Sep 2014 01:45:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp308820lbb; Tue, 30 Sep 2014 01:45:41 -0700 (PDT) X-Received: by 10.68.143.226 with SMTP id sh2mr39673835pbb.60.1412066740368; Tue, 30 Sep 2014 01:45:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gr5si26248089pbc.131.2014.09.30.01.45.39 for ; Tue, 30 Sep 2014 01:45:40 -0700 (PDT) Received-SPF: none (google.com: linux-gpio-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752695AbaI3Ipi (ORCPT ); Tue, 30 Sep 2014 04:45:38 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:34677 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753403AbaI3IpO (ORCPT ); Tue, 30 Sep 2014 04:45:14 -0400 Received: by mail-wg0-f50.google.com with SMTP id l18so13614942wgh.21 for ; Tue, 30 Sep 2014 01:45:12 -0700 (PDT) X-Received: by 10.194.8.232 with SMTP id u8mr52461908wja.64.1412066712454; Tue, 30 Sep 2014 01:45:12 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id ba3sm14386256wib.10.2014.09.30.01.45.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Sep 2014 01:45:11 -0700 (PDT) From: Linus Walleij To: linux-kernel@vger.kernel.org, Barry Song , Barry Song Cc: linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH] RESEND RFT: pinctrl: sirf: move sgpio lock into state container Date: Tue, 30 Sep 2014 10:45:04 +0200 Message-Id: <1412066704-28633-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-gpio-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-gpio@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Instead of referring to a global static variable for the sgpio locking, use the state container to contain the lock. Signed-off-by: Linus Walleij --- Barry, did you get around to testing this patch? --- drivers/pinctrl/sirf/pinctrl-sirf.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index 4c1d7c68666d..3ac7848a8551 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c @@ -40,10 +40,9 @@ struct sirfsoc_gpio_chip { struct of_mm_gpio_chip chip; bool is_marco; /* for marco, some registers are different with prima2 */ struct sirfsoc_gpio_bank sgpio_bank[SIRFSOC_GPIO_NO_OF_BANKS]; + spinlock_t lock; }; -static DEFINE_SPINLOCK(sgpio_lock); - static struct sirfsoc_pin_group *sirfsoc_pin_groups; static int sirfsoc_pingrp_cnt; @@ -440,13 +439,13 @@ static void sirfsoc_gpio_irq_ack(struct irq_data *d) offset = SIRFSOC_GPIO_CTRL(bank->id, idx); - spin_lock_irqsave(&sgpio_lock, flags); + spin_lock_irqsave(&sgpio->lock, flags); val = readl(sgpio->chip.regs + offset); writel(val, sgpio->chip.regs + offset); - spin_unlock_irqrestore(&sgpio_lock, flags); + spin_unlock_irqrestore(&sgpio->lock, flags); } static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_chip *sgpio, @@ -458,14 +457,14 @@ static void __sirfsoc_gpio_irq_mask(struct sirfsoc_gpio_chip *sgpio, offset = SIRFSOC_GPIO_CTRL(bank->id, idx); - spin_lock_irqsave(&sgpio_lock, flags); + spin_lock_irqsave(&sgpio->lock, flags); val = readl(sgpio->chip.regs + offset); val &= ~SIRFSOC_GPIO_CTL_INTR_EN_MASK; val &= ~SIRFSOC_GPIO_CTL_INTR_STS_MASK; writel(val, sgpio->chip.regs + offset); - spin_unlock_irqrestore(&sgpio_lock, flags); + spin_unlock_irqrestore(&sgpio->lock, flags); } static void sirfsoc_gpio_irq_mask(struct irq_data *d) @@ -488,14 +487,14 @@ static void sirfsoc_gpio_irq_unmask(struct irq_data *d) offset = SIRFSOC_GPIO_CTRL(bank->id, idx); - spin_lock_irqsave(&sgpio_lock, flags); + spin_lock_irqsave(&sgpio->lock, flags); val = readl(sgpio->chip.regs + offset); val &= ~SIRFSOC_GPIO_CTL_INTR_STS_MASK; val |= SIRFSOC_GPIO_CTL_INTR_EN_MASK; writel(val, sgpio->chip.regs + offset); - spin_unlock_irqrestore(&sgpio_lock, flags); + spin_unlock_irqrestore(&sgpio->lock, flags); } static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) @@ -509,7 +508,7 @@ static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) offset = SIRFSOC_GPIO_CTRL(bank->id, idx); - spin_lock_irqsave(&sgpio_lock, flags); + spin_lock_irqsave(&sgpio->lock, flags); val = readl(sgpio->chip.regs + offset); val &= ~(SIRFSOC_GPIO_CTL_INTR_STS_MASK | SIRFSOC_GPIO_CTL_OUT_EN_MASK); @@ -541,7 +540,7 @@ static int sirfsoc_gpio_irq_type(struct irq_data *d, unsigned type) writel(val, sgpio->chip.regs + offset); - spin_unlock_irqrestore(&sgpio_lock, flags); + spin_unlock_irqrestore(&sgpio->lock, flags); return 0; } @@ -704,11 +703,11 @@ static int sirfsoc_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, offset = SIRFSOC_GPIO_CTRL(bank->id, idx); - spin_lock_irqsave(&sgpio_lock, flags); + spin_lock_irqsave(&sgpio->lock, flags); sirfsoc_gpio_set_output(sgpio, bank, offset, value); - spin_unlock_irqrestore(&sgpio_lock, flags); + spin_unlock_irqrestore(&sgpio->lock, flags); return 0; } @@ -801,6 +800,7 @@ static int sirfsoc_gpio_probe(struct device_node *np) sgpio = devm_kzalloc(&pdev->dev, sizeof(*sgpio), GFP_KERNEL); if (!sgpio) return -ENOMEM; + spin_lock_init(&sgpio->lock); regs = of_iomap(np, 0); if (!regs)