Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3729194rdg; Wed, 18 Oct 2023 04:34:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3wPXr3980BwmENxfbzp2SRj1A6A9Ia2CyHm1z/ICklEnINNMfaDltx3CtnznT9KQWYqtU X-Received: by 2002:a17:902:ce84:b0:1ca:7f91:aa5b with SMTP id f4-20020a170902ce8400b001ca7f91aa5bmr5801918plg.18.1697628898832; Wed, 18 Oct 2023 04:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697628898; cv=none; d=google.com; s=arc-20160816; b=fngpoLckBqsib+WjcPwGvmJ8KTOCmnfMbm0VVsO6Gps4ahdio+RgTxSTGEPNuHR9e4 fJxPfWP8rtfjUOA/kJsoCvLEccidQT6LeKuDqdkORsbdVvSM72/0Qewk2QmWpxbgYxYi kxakA4SvJAVcmCte84ATIeOW56DqSvs9XJMJvrQW6U2p83djKr+qy6SGpgqnsPTl7PhK 6eWYFfibQiB/iXOY80X0Aqi/Fplqxnqxc7bAhkD4DOaSgIjQqmnYgMGZGUY2FQYxJXEv LMVfOPOFJ6rtvTR5jgKaTdFFm7799OCzxP75Y+lLgNvZkYTBhkLuriJYGiHDRs36areX 2OcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MUz+V/vK3jQGBPWYwa56pb1bYgCFPNI0WnqwcncbUU8=; fh=ZsL5PHfRx+JfHMsaMlEA4ElQmrf37aZ70df87YSzlQo=; b=ihMkjqoNex5KtjwyIwnGWCkPEUpqmO/ji+EnMxjJpSXUSDZRE282wnY7zW0WZgM5wT BXZ4mmX47ggmPiZ4Nykp1J8DDbSUiPz5D3QPgZGE9YzUJ3/K7XC447YS317WTihfw8UB 2H+glWGkrXw4P6C374W7c+Kfq8dkPzAsK761CU1oVGfjTJjhwcMaQxTeUR6VB671eFFQ 3wJwSoE+zG7TaFG33lZpMLPpM3ShgWIGgheGK6T3nZzM/vzKXQAF0AOfc/Y7LdGHIkV+ UN61Z4rsq7M6njpY4yKNbRVSFvMP5lLOqfYFoQ3uI2vDcV/tZoBDzvF/c2DpWM0swpBg mx4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fphr2OIX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id ba8-20020a170902720800b001bdd58f685fsi3687908plb.85.2023.10.18.04.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 04:34:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fphr2OIX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id E91EF8025835; Wed, 18 Oct 2023 04:34:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229605AbjJRLe1 (ORCPT + 99 others); Wed, 18 Oct 2023 07:34:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbjJRLeX (ORCPT ); Wed, 18 Oct 2023 07:34:23 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BABE110F; Wed, 18 Oct 2023 04:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697628861; x=1729164861; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MqRibY96VGUvi4t4Y8OdfajrD7rQssLGYBUaujkdMxs=; b=fphr2OIXahRYqsnweJgi7pKz8g0bpB5qr+uH3MXpZwhAqJs1ypwgZpKj ASH3xl5Kv3uWQCkQs6bUkokLRjpRmHqCqb5WzmGTcdsqgW/GWugaTJNgv Vy/Lnq5ugCgXf6J3v4FwhVANLb8fjfYWeT6EUZeMfY5Q+SvSr4LqFy/XC v8X0UCFlgjkE4bsFVXpuiKYUvA6jUxFaUiZdsGaWgfPSj3YoviRRNvZ5U KUILqUK+sa1Ws2Zy/P0rPGzSL/7BF0IZ3myge+mE8KruVUinTyOcKSbNV ty9z15VeZ60CDF03sOxIoF3JGB0oGRx/zNGcuCx0tqMnr3ofBq9T9otf4 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="371056786" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="371056786" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 04:34:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="930150816" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="930150816" Received: from suguccin-mobl1.amr.corp.intel.com (HELO localhost) ([10.252.44.63]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2023 04:34:02 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Bjorn Helgaas , linux-pci@vger.kernel.org, Lorenzo Pieralisi , Rob Herring , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Jonathan Cameron , Michael Ellerman , Nicholas Piggin , Christophe Leroy , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH 3/7] PCI: hotplug: Use FIELD_GET/PREP() Date: Wed, 18 Oct 2023 14:32:50 +0300 Message-Id: <20231018113254.17616-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231018113254.17616-1-ilpo.jarvinen@linux.intel.com> References: <20231018113254.17616-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 04:34:55 -0700 (PDT) Instead of handcrafted shifts to handle register fields, use FIELD_GET/FIELD_PREP(). Signed-off-by: Ilpo Järvinen --- drivers/pci/hotplug/pciehp_core.c | 3 ++- drivers/pci/hotplug/pciehp_hpc.c | 5 +++-- drivers/pci/hotplug/pnv_php.c | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c index 4042d87d539d..ddd55ad97a58 100644 --- a/drivers/pci/hotplug/pciehp_core.c +++ b/drivers/pci/hotplug/pciehp_core.c @@ -20,6 +20,7 @@ #define pr_fmt(fmt) "pciehp: " fmt #define dev_fmt pr_fmt +#include #include #include #include @@ -103,7 +104,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status) struct pci_dev *pdev = ctrl->pcie->port; if (status) - status <<= PCI_EXP_SLTCTL_ATTN_IND_SHIFT; + status = FIELD_PREP(PCI_EXP_SLTCTL_AIC, status); else status = PCI_EXP_SLTCTL_ATTN_IND_OFF; diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c index fd713abdfb9f..b1d0a1b3917d 100644 --- a/drivers/pci/hotplug/pciehp_hpc.c +++ b/drivers/pci/hotplug/pciehp_hpc.c @@ -14,6 +14,7 @@ #define dev_fmt(fmt) "pciehp: " fmt +#include #include #include #include @@ -484,7 +485,7 @@ int pciehp_set_raw_indicator_status(struct hotplug_slot *hotplug_slot, struct pci_dev *pdev = ctrl_dev(ctrl); pci_config_pm_runtime_get(pdev); - pcie_write_cmd_nowait(ctrl, status << 6, + pcie_write_cmd_nowait(ctrl, FIELD_PREP(PCI_EXP_SLTCTL_AIC, status), PCI_EXP_SLTCTL_AIC | PCI_EXP_SLTCTL_PIC); pci_config_pm_runtime_put(pdev); return 0; @@ -1028,7 +1029,7 @@ struct controller *pcie_init(struct pcie_device *dev) PCI_EXP_SLTSTA_DLLSC | PCI_EXP_SLTSTA_PDC); ctrl_info(ctrl, "Slot #%d AttnBtn%c PwrCtrl%c MRL%c AttnInd%c PwrInd%c HotPlug%c Surprise%c Interlock%c NoCompl%c IbPresDis%c LLActRep%c%s\n", - (slot_cap & PCI_EXP_SLTCAP_PSN) >> 19, + FIELD_GET(PCI_EXP_SLTCAP_PSN, slot_cap), FLAG(slot_cap, PCI_EXP_SLTCAP_ABP), FLAG(slot_cap, PCI_EXP_SLTCAP_PCP), FLAG(slot_cap, PCI_EXP_SLTCAP_MRLSP), diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c index 881d420637bf..694349be9d0a 100644 --- a/drivers/pci/hotplug/pnv_php.c +++ b/drivers/pci/hotplug/pnv_php.c @@ -5,6 +5,7 @@ * Copyright Gavin Shan, IBM Corporation 2016. */ +#include #include #include #include @@ -731,7 +732,7 @@ static int pnv_php_enable_msix(struct pnv_php_slot *php_slot) /* Check hotplug MSIx entry is in range */ pcie_capability_read_word(pdev, PCI_EXP_FLAGS, &pcie_flag); - entry.entry = (pcie_flag & PCI_EXP_FLAGS_IRQ) >> 9; + entry.entry = FIELD_GET(PCI_EXP_FLAGS_IRQ, pcie_flag); if (entry.entry >= nr_entries) return -ERANGE; -- 2.30.2