From patchwork Thu Nov 23 14:02:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 168953 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp466522vqx; Thu, 23 Nov 2023 06:02:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGK9qS4SPpq/vTdohuaOPGAkhZ62hb7uzGapIJLhypqaW97wCTAuAjjhbzrLciQUMsvQkuQ X-Received: by 2002:a4a:6256:0:b0:57b:de27:28ed with SMTP id y22-20020a4a6256000000b0057bde2728edmr5314508oog.6.1700748169269; Thu, 23 Nov 2023 06:02:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700748169; cv=none; d=google.com; s=arc-20160816; b=e/rcRCxOCHS6F+qlS8rkzKNIVJOqznHFVmnA2HIqn6l2mYw192E4luUwgF8AwcxJFE NaZYxli5WCxT6RJJNi5/vkqW2KDR/PK9POIUkbNtaErEpIG+8TNYPkkjkZ26n1hYpiOk l25Upt2/SmtQw3KOWg99m0oLSlvMKdTskXKjJD44o6yxuDt+bKIX9q/28PEVKptXkLPw 7r/15yR5hwt9p+ldRxhVOK9atTKob52F6NHSjNUuMnp/+VRle1Bj1rLh6gracM7DkFiX FA1XZkCdBhisbd0qZTwY8d4cZmDnIjwvLzk59nW5hcZgyqAzP5Wwly7lIvWlLDbyVR+V QI8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=afghaqC9SCNHcBTD6U2wWKupHE6hw9Xi8HnforF6aAg=; fh=ZSJZwaGQgZrvOMxldwIip3MoOAHW4PS3iIJ8X4wG1BY=; b=kriSIEDREeCO3yAxnh7avwbZh0HjrURLeYKHTqVbh6+aTMgP8P7f2I/HHVyyq11mH0 Vfe/UaZG96coBqBPCYKtTdTnNno4B52ec5diWp7Ue+U0ApPsC3gW32BrxVS2kAa4UGGM js8xSkBuCAI0Jq7dguIUUNH51JpXYTnjJc5HUwrINpTx3wIEiC7dy8OYE8tJkCShqDZk ZBb/iw8prrgKhd5+VYeXI5+uoruxgatkgGQ/QdmohOk5XKQ1G3wEnCyngbm2qMoIScxv 5fWTpI3Vj+rxDUSYSmIUYWY/yxbuGWItdVlKLWtJP1sDpgmOTAsBL/3tXOJ19Muudfyj HQkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e7ZSSgH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s25-20020a4a7319000000b00589cf6a4740si440908ooc.64.2023.11.23.06.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 06:02:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=e7ZSSgH6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 530D683134ED; Thu, 23 Nov 2023 06:02:45 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345665AbjKWOCg (ORCPT + 99 others); Thu, 23 Nov 2023 09:02:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345636AbjKWOCf (ORCPT ); Thu, 23 Nov 2023 09:02:35 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36D679F; Thu, 23 Nov 2023 06:02:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700748162; x=1732284162; h=from:to:cc:subject:date:message-id; bh=/aSaJpluUpfz8zIYINYmmKw/+Sgyp3i8cMgmajwYojc=; b=e7ZSSgH6pl9GeaEj0TsJmUvcrfwV1CIf4PBOH1B1fau3xU/enbQNuSy+ fL/tuGxOfIRLew0OAdK/UTbu7ZiS9C8W0Nj2KkxxrFKg3xUjn2gTiJniJ PNAHPyo2qlGE7FBvtxKdfWz8anMcTi1i4XnEFaImScb6MZlU5I1kemmuv 6hi9N6Iie6iXyV4+6vVFDT3BPnWrBnw0eLNsDt8S8IIe2aWsbSYOwz75j h+t+k+Piwz6sBVd8+cdtj8ksqUcupqwKIupBeh7dlYeNUz5kgErv8fcgg nngbnbAn35QdhWRhF2UlkE1I22Pjra6/YeaJbfwym/hlofAE3NsHq3bQV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="423401635" X-IronPort-AV: E=Sophos;i="6.04,221,1695711600"; d="scan'208";a="423401635" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Nov 2023 06:02:33 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="771004938" X-IronPort-AV: E=Sophos;i="6.04,221,1695711600"; d="scan'208";a="771004938" Received: from inlubt0316.iind.intel.com ([10.191.20.213]) by fmsmga007.fm.intel.com with ESMTP; 23 Nov 2023 06:02:26 -0800 From: Raag Jadav To: mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com, linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Raag Jadav Subject: [PATCH v1] pinctrl: tangier: simplify locking using cleanup helpers Date: Thu, 23 Nov 2023 19:32:12 +0530 Message-Id: <20231123140212.12135-1-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 23 Nov 2023 06:02:45 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783363711890129651 X-GMAIL-MSGID: 1783363711890129651 Use lock guards from cleanup.h to simplify locking. Signed-off-by: Raag Jadav Acked-by: Mika Westerberg --- drivers/pinctrl/intel/pinctrl-tangier.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) base-commit: e58e519b80ba79cd73abb1d631d429b7322ac9cb diff --git a/drivers/pinctrl/intel/pinctrl-tangier.c b/drivers/pinctrl/intel/pinctrl-tangier.c index 26e34ec0a972..2cb0b4758269 100644 --- a/drivers/pinctrl/intel/pinctrl-tangier.c +++ b/drivers/pinctrl/intel/pinctrl-tangier.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -220,7 +221,6 @@ static int tng_pinmux_set_mux(struct pinctrl_dev *pctldev, const struct intel_pingroup *grp = &tp->groups[group]; u32 bits = grp->mode << BUFCFG_PINMODE_SHIFT; u32 mask = BUFCFG_PINMODE_MASK; - unsigned long flags; unsigned int i; /* @@ -232,11 +232,11 @@ static int tng_pinmux_set_mux(struct pinctrl_dev *pctldev, return -EBUSY; } + guard(raw_spinlock_irqsave)(&tp->lock); + /* Now enable the mux setting for each pin in the group */ - raw_spin_lock_irqsave(&tp->lock, flags); for (i = 0; i < grp->grp.npins; i++) tng_update_bufcfg(tp, grp->grp.pins[i], bits, mask); - raw_spin_unlock_irqrestore(&tp->lock, flags); return 0; } @@ -248,14 +248,13 @@ static int tng_gpio_request_enable(struct pinctrl_dev *pctldev, struct tng_pinctrl *tp = pinctrl_dev_get_drvdata(pctldev); u32 bits = BUFCFG_PINMODE_GPIO << BUFCFG_PINMODE_SHIFT; u32 mask = BUFCFG_PINMODE_MASK; - unsigned long flags; if (!tng_buf_available(tp, pin)) return -EBUSY; - raw_spin_lock_irqsave(&tp->lock, flags); + guard(raw_spinlock_irqsave)(&tp->lock); + tng_update_bufcfg(tp, pin, bits, mask); - raw_spin_unlock_irqrestore(&tp->lock, flags); return 0; } @@ -360,7 +359,6 @@ static int tng_config_set_pin(struct tng_pinctrl *tp, unsigned int pin, unsigned int param = pinconf_to_config_param(config); unsigned int arg = pinconf_to_config_argument(config); u32 mask, term, value = 0; - unsigned long flags; switch (param) { case PIN_CONFIG_BIAS_DISABLE: @@ -432,9 +430,9 @@ static int tng_config_set_pin(struct tng_pinctrl *tp, unsigned int pin, return -EINVAL; } - raw_spin_lock_irqsave(&tp->lock, flags); + guard(raw_spinlock_irqsave)(&tp->lock); + tng_update_bufcfg(tp, pin, value, mask); - raw_spin_unlock_irqrestore(&tp->lock, flags); return 0; }