From patchwork Thu Feb 26 07:41:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sonic Zhang X-Patchwork-Id: 443838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D69DC14007D for ; Thu, 26 Feb 2015 19:17:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932082AbbBZIRe (ORCPT ); Thu, 26 Feb 2015 03:17:34 -0500 Received: from mail-by2on0065.outbound.protection.outlook.com ([207.46.100.65]:20352 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932090AbbBZIRc (ORCPT ); Thu, 26 Feb 2015 03:17:32 -0500 X-Greylist: delayed 1105 seconds by postgrey-1.27 at vger.kernel.org; Thu, 26 Feb 2015 03:17:31 EST Received: from BY2PR03CA062.namprd03.prod.outlook.com (10.141.249.35) by BLUPR03MB589.namprd03.prod.outlook.com (10.255.124.35) with Microsoft SMTP Server (TLS) id 15.1.93.16; Thu, 26 Feb 2015 07:44:34 +0000 Received: from BY2FFO11FD001.protection.gbl (2a01:111:f400:7c0c::114) by BY2PR03CA062.outlook.office365.com (2a01:111:e400:2c5d::35) with Microsoft SMTP Server (TLS) id 15.1.99.9 via Frontend Transport; Thu, 26 Feb 2015 07:44:33 +0000 Received: from nwd2mta2.analog.com (137.71.25.57) by BY2FFO11FD001.mail.protection.outlook.com (10.1.14.123) with Microsoft SMTP Server (TLS) id 15.1.99.6 via Frontend Transport; Thu, 26 Feb 2015 07:44:33 +0000 Received: from NWD2HUBCAS8.ad.analog.com (nwd2hubcas8.ad.analog.com [10.64.72.141]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id t1QAtYaN031409 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 26 Feb 2015 05:55:34 -0500 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS8.ad.analog.com (10.64.72.141) with Microsoft SMTP Server id 14.3.210.2; Thu, 26 Feb 2015 02:43:20 -0500 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.6/8.14.6) with ESMTP id t1Q7hIKo004203; Thu, 26 Feb 2015 02:43:19 -0500 Received: from nine.ad.analog.com (unknown [10.99.24.95]) by linux.site (Postfix) with ESMTP id 648A33B01067; Wed, 25 Feb 2015 16:47:30 -0700 (MST) From: Sonic Zhang To: Linus Walleij , Grant Likely CC: , , Sonic Zhang Subject: [PATCH] pinmux: 1 pin is not allowed to be configured for both GPIO and peripheral funtion Date: Thu, 26 Feb 2015 15:41:44 +0800 Message-ID: <1424936504-32662-1-git-send-email-sonic.adi@gmail.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130694102735261899; (52f37747-95c3-483a-bd05-08d153b03fac); () Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 137.71.25.57 as permitted sender) Authentication-Results: spf=softfail (sender IP is 137.71.25.57) smtp.mailfrom=sonic.adi@gmail.com; lists.sourceforge.net; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:137.71.25.57; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(105596002)(106466001)(50466002)(229853001)(73392002)(46102003)(50226001)(86362001)(77096005)(82202001)(76482003)(36756003)(62966003)(92566002)(77156002)(19580395003)(19580405001)(87572001)(6806004)(55446002)(87936001)(64706001)(50986999)(83322999)(33646002)(61266001)(73972006)(48376002)(47776003)(81442002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB589; H:nwd2mta2.analog.com; FPR:; SPF:SoftFail; PTR:nwd2mail11.analog.com; MX:1; A:1; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB589; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006); SRVR:BLUPR03MB589; X-Forefront-PRVS: 0499DAF22A X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(400005)(401004); SRVR:BLUPR03MB589; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2015 07:44:33.0893 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[137.71.25.57] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB589 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Sonic Zhang The blackfin pinmux and gpio controller doesn't allow user to set up 1 pin for both GPIO and peripheral function. So, check both gpio_owner and mux_owner before approving the pin request. Signed-off-by: Sonic Zhang --- drivers/pinctrl/pinmux.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index b874458..b58b97c 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -99,24 +99,24 @@ static int pin_request(struct pinctrl_dev *pctldev, dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n", pin, desc->name, owner); + if (desc->gpio_owner) { + dev_err(pctldev->dev, + "pin %s already requested by %s; cannot claim for %s\n", + desc->name, desc->gpio_owner, owner); + goto out; + } + + if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) { + dev_err(pctldev->dev, + "pin %s already requested by %s; cannot claim for %s\n", + desc->name, desc->mux_owner, owner); + goto out; + } + if (gpio_range) { /* There's no need to support multiple GPIO requests */ - if (desc->gpio_owner) { - dev_err(pctldev->dev, - "pin %s already requested by %s; cannot claim for %s\n", - desc->name, desc->gpio_owner, owner); - goto out; - } - desc->gpio_owner = owner; } else { - if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) { - dev_err(pctldev->dev, - "pin %s already requested by %s; cannot claim for %s\n", - desc->name, desc->mux_owner, owner); - goto out; - } - desc->mux_usecount++; if (desc->mux_usecount > 1) return 0;