提交 9e7ce8d2 编写于 作者: A Andy Shevchenko 提交者: Yang Yingliang

Intel:PCI/AER: Use for_each_set_bit() to simplify code

mainline inclusion
from mainline-v5.5-rc1
commit 6a8c9734
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I47H3V
CVE: NA

--------------------------------

commit 6a8c9734 upstream.
Backport summary: for 4.19 kernel ICX PCIe Gen4 support.

Simplify error counting code by using for_each_set_bit() library function.

Link: https://lore.kernel.org/r/20190827151823.75312-1-andriy.shevchenko@linux.intel.comSigned-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
Reviewed-by: NKuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
(cherry picked from commit 6a8c9734)
Signed-off-by: NEthan Zhao <haifeng.zhao@intel.com>
Signed-off-by: NJackie Liu <liuyun01@kylinos.cn>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 614ce6e9
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#define pr_fmt(fmt) "AER: " fmt #define pr_fmt(fmt) "AER: " fmt
#define dev_fmt pr_fmt #define dev_fmt pr_fmt
#include <linux/bitops.h>
#include <linux/cper.h> #include <linux/cper.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pci-acpi.h> #include <linux/pci-acpi.h>
...@@ -715,7 +716,8 @@ const struct attribute_group aer_stats_attr_group = { ...@@ -715,7 +716,8 @@ const struct attribute_group aer_stats_attr_group = {
static void pci_dev_aer_stats_incr(struct pci_dev *pdev, static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
struct aer_err_info *info) struct aer_err_info *info)
{ {
int status, i, max = -1; unsigned long status = info->status & ~info->mask;
int i, max = -1;
u64 *counter = NULL; u64 *counter = NULL;
struct aer_stats *aer_stats = pdev->aer_stats; struct aer_stats *aer_stats = pdev->aer_stats;
...@@ -740,9 +742,7 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev, ...@@ -740,9 +742,7 @@ static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
break; break;
} }
status = (info->status & ~info->mask); for_each_set_bit(i, &status, max)
for (i = 0; i < max; i++)
if (status & (1 << i))
counter[i]++; counter[i]++;
} }
...@@ -775,14 +775,11 @@ static void __print_tlp_header(struct pci_dev *dev, ...@@ -775,14 +775,11 @@ static void __print_tlp_header(struct pci_dev *dev,
static void __aer_print_error(struct pci_dev *dev, static void __aer_print_error(struct pci_dev *dev,
struct aer_err_info *info) struct aer_err_info *info)
{ {
int i, status; unsigned long status = info->status & ~info->mask;
const char *errmsg = NULL; const char *errmsg = NULL;
status = (info->status & ~info->mask); int i;
for (i = 0; i < 32; i++) {
if (!(status & (1 << i)))
continue;
for_each_set_bit(i, &status, 32) {
if (info->severity == AER_CORRECTABLE) if (info->severity == AER_CORRECTABLE)
errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ? errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
aer_correctable_error_string[i] : NULL; aer_correctable_error_string[i] : NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册