From patchwork Tue Aug 8 08:49:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 132905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2416326vqr; Tue, 8 Aug 2023 14:55:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwoh7ev2J325al+m2M4819p+uAanyFlsUrrgdtAUW7i9G/ugMa3hdX0/2PBQOTuYugmqzX X-Received: by 2002:a17:907:762e:b0:99b:4d3d:c9b7 with SMTP id jy14-20020a170907762e00b0099b4d3dc9b7mr1248141ejc.31.1691531735743; Tue, 08 Aug 2023 14:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691531735; cv=none; d=google.com; s=arc-20160816; b=XGotJE00qYFaIW++hjYI8ZNWrMdq8rWx+fMM8ZksWWw5JF3BfWJIVq1LnvUpT4D8+o ICntx4o34ODu6xaws2LhXwcoszxeV3EOujUHNgXiPpC7Rm6ZpZWzkEVfhddGvFfzhJIU 5IJnKJDrwrhMtZh4CpiArz24BynqiTDo0GPkB5z2PR/dOkFkvBTEvddc2bK6yfK5uKmH GHMOjF1IBAyzgRkceLk+qNEuD/+NcxVSVzSoaCdBi4Vx3mC6iNYITFCDaUZ5OE/FVtRu TkfYWHbx2uvZX7drtvJJcG9H6eJBNZ/+uQz3H+KmmlGzIQQshwVG5+EUfYkda6YYzF0g FkXg== 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=kb20HnaTN7GAh+ows82fn9VneVJRKDJiodhFSs0Hebw=; fh=ITb4zGKkWO3T0WmJnSV0Z0twUZ/f73yiIOUT0grFSAs=; b=hilt8hQ6Eh60CfplTJlJaDG1soTzOaHp3/q80nIISxWyHC1eTwlbbdJP4zSMDNz+ap 1L99tEpweKoYwPKZXPHHm6e4pzJT/OR/XRzdMZVSf011eJkRrMLFPqWqUUP8d/uCpLAw DFNUwSLuXxuZQUz7vSActIrq2aLU0NkH7PjpkkjJ6CgciJQGF0O96SOfYkPcvKDSa0Dr OadMnQ48ZWuyya52f8FcFRLKGfoobUKhO/CU1D7O8qaaI5Z+8Y0n/MutRry6iOUVGVus mvVRrle3rlRdt8X3SA9kRssXMImgKaltlSgXFqzrHoPWoqYW0dM87OGJJzhCf/M309Tg B7fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YH6Zi0bG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u27-20020a17090617db00b0099329251046si6456863eje.14.2023.08.08.14.55.11; Tue, 08 Aug 2023 14:55:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YH6Zi0bG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234092AbjHHUnq (ORCPT + 99 others); Tue, 8 Aug 2023 16:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233994AbjHHUn3 (ORCPT ); Tue, 8 Aug 2023 16:43:29 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03443208B; Tue, 8 Aug 2023 09:30:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691512248; x=1723048248; h=from:to:cc:subject:date:message-id; bh=FHiTNDUCzaH3CxhFl0M+eCf/lVRDrPXo5yOGv54eeZQ=; b=YH6Zi0bGvGGNQyhYAnDp66gA22iieQyeNuwt1WxGB4kdYkpaeIbt25Hc Qmwn4ubKsKuIIfEkwTNe/RHElPVU9A0uxWzOUvRVLpoTQni4z7f1hxyaJ 7VNqahDHPl0D/HZCiyD17sDp+cb4lhF2ZaJgUHtyynztM8AmGTsxyU8Ll 7zuWErGjNKS+qsSsVPEfeBa/0udgRrQcnoPbOmeeI9dA82T8g8cKOs+t5 /q+cVR2K9fas2Flif+qxiHhEsjjmwgV/eIWGxATcYHvBFd/bf7elKK3l3 Z6OtLnp+ouLeOfT0jmXJTMppu2E0DXV+nUt7kQNqZ7fsdu9RyHPxBdLfF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="401725840" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="401725840" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2023 01:49:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="760827832" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="760827832" Received: from inlubt0316.iind.intel.com ([10.191.20.213]) by orsmga008.jf.intel.com with ESMTP; 08 Aug 2023 01:49:10 -0700 From: Raag Jadav To: linus.walleij@linaro.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com, Raag Jadav Subject: [PATCH v1] pinctrl: baytrail: consolidate common mask operation Date: Tue, 8 Aug 2023 14:19:01 +0530 Message-Id: <20230808084901.18927-1-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773687471948267430 X-GMAIL-MSGID: 1773699581391936395 Consolidate common mask operation outside of switch cases and limit IO operations to positive cases. Signed-off-by: Raag Jadav --- drivers/pinctrl/intel/pinctrl-baytrail.c | 34 +++++++++++------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index 27aef62fc7c0..02ab5fd7cbd5 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -995,8 +995,8 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev, void __iomem *conf_reg = byt_gpio_reg(vg, offset, BYT_CONF0_REG); void __iomem *val_reg = byt_gpio_reg(vg, offset, BYT_VAL_REG); void __iomem *db_reg = byt_gpio_reg(vg, offset, BYT_DEBOUNCE_REG); + u32 conf, val, db_pulse, debounce; unsigned long flags; - u32 conf, val, debounce; int i, ret = 0; raw_spin_lock_irqsave(&byt_lock, flags); @@ -1053,8 +1053,6 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev, break; case PIN_CONFIG_INPUT_DEBOUNCE: - debounce = readl(db_reg); - if (arg) conf |= BYT_DEBOUNCE_EN; else @@ -1062,32 +1060,25 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev, switch (arg) { case 375: - debounce &= ~BYT_DEBOUNCE_PULSE_MASK; - debounce |= BYT_DEBOUNCE_PULSE_375US; + db_pulse = BYT_DEBOUNCE_PULSE_375US; break; case 750: - debounce &= ~BYT_DEBOUNCE_PULSE_MASK; - debounce |= BYT_DEBOUNCE_PULSE_750US; + db_pulse = BYT_DEBOUNCE_PULSE_750US; break; case 1500: - debounce &= ~BYT_DEBOUNCE_PULSE_MASK; - debounce |= BYT_DEBOUNCE_PULSE_1500US; + db_pulse = BYT_DEBOUNCE_PULSE_1500US; break; case 3000: - debounce &= ~BYT_DEBOUNCE_PULSE_MASK; - debounce |= BYT_DEBOUNCE_PULSE_3MS; + db_pulse = BYT_DEBOUNCE_PULSE_3MS; break; case 6000: - debounce &= ~BYT_DEBOUNCE_PULSE_MASK; - debounce |= BYT_DEBOUNCE_PULSE_6MS; + db_pulse = BYT_DEBOUNCE_PULSE_6MS; break; case 12000: - debounce &= ~BYT_DEBOUNCE_PULSE_MASK; - debounce |= BYT_DEBOUNCE_PULSE_12MS; + db_pulse = BYT_DEBOUNCE_PULSE_12MS; break; case 24000: - debounce &= ~BYT_DEBOUNCE_PULSE_MASK; - debounce |= BYT_DEBOUNCE_PULSE_24MS; + db_pulse = BYT_DEBOUNCE_PULSE_24MS; break; default: if (arg) @@ -1095,8 +1086,13 @@ static int byt_pin_config_set(struct pinctrl_dev *pctl_dev, break; } - if (!ret) - writel(debounce, db_reg); + if (ret) + break; + + debounce = readl(db_reg); + debounce = (debounce & ~BYT_DEBOUNCE_PULSE_MASK) | db_pulse; + writel(debounce, db_reg); + break; default: ret = -ENOTSUPP;