treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / misc / mic / host / mic_debugfs.c
blobab0db7a2ac8c2e984a512e1557343d9139388bb0
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Intel MIC Platform Software Stack (MPSS)
5 * Copyright(c) 2013 Intel Corporation.
7 * Intel MIC Host driver.
8 */
9 #include <linux/debugfs.h>
10 #include <linux/pci.h>
11 #include <linux/seq_file.h>
13 #include <linux/mic_common.h>
14 #include "../common/mic_dev.h"
15 #include "mic_device.h"
16 #include "mic_smpt.h"
18 /* Debugfs parent dir */
19 static struct dentry *mic_dbg;
21 static int mic_smpt_show(struct seq_file *s, void *pos)
23 int i;
24 struct mic_device *mdev = s->private;
25 unsigned long flags;
27 seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
28 mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
29 seq_puts(s, "====================================================\n");
31 if (mdev->smpt) {
32 struct mic_smpt_info *smpt_info = mdev->smpt;
33 spin_lock_irqsave(&smpt_info->smpt_lock, flags);
34 for (i = 0; i < smpt_info->info.num_reg; i++) {
35 seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n",
36 " ", i, smpt_info->entry[i].dma_addr,
37 smpt_info->entry[i].ref_count);
39 spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
41 seq_puts(s, "====================================================\n");
42 return 0;
45 DEFINE_SHOW_ATTRIBUTE(mic_smpt);
47 static int mic_post_code_show(struct seq_file *s, void *pos)
49 struct mic_device *mdev = s->private;
50 u32 reg = mdev->ops->get_postcode(mdev);
52 seq_printf(s, "%c%c", reg & 0xff, (reg >> 8) & 0xff);
53 return 0;
56 DEFINE_SHOW_ATTRIBUTE(mic_post_code);
58 static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
60 struct mic_device *mdev = s->private;
61 int reg;
62 int i, j;
63 u16 entry;
64 u16 vector;
65 struct pci_dev *pdev = mdev->pdev;
67 if (pci_dev_msi_enabled(pdev)) {
68 for (i = 0; i < mdev->irq_info.num_vectors; i++) {
69 if (pdev->msix_enabled) {
70 entry = mdev->irq_info.msix_entries[i].entry;
71 vector = mdev->irq_info.msix_entries[i].vector;
72 } else {
73 entry = 0;
74 vector = pdev->irq;
77 reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
79 seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
80 "IRQ:", vector, "Entry:", entry, i, reg);
82 seq_printf(s, "%-10s", "offset:");
83 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
84 seq_printf(s, "%4d ", j);
85 seq_puts(s, "\n");
88 seq_printf(s, "%-10s", "count:");
89 for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
90 seq_printf(s, "%4d ",
91 (mdev->irq_info.mic_msi_map[i] &
92 BIT(j)) ? 1 : 0);
93 seq_puts(s, "\n\n");
95 } else {
96 seq_puts(s, "MSI/MSIx interrupts not enabled\n");
99 return 0;
102 DEFINE_SHOW_ATTRIBUTE(mic_msi_irq_info);
105 * mic_create_debug_dir - Initialize MIC debugfs entries.
107 void mic_create_debug_dir(struct mic_device *mdev)
109 char name[16];
111 if (!mic_dbg)
112 return;
114 scnprintf(name, sizeof(name), "mic%d", mdev->id);
115 mdev->dbg_dir = debugfs_create_dir(name, mic_dbg);
117 debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev,
118 &mic_smpt_fops);
120 debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev,
121 &mic_post_code_fops);
123 debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev,
124 &mic_msi_irq_info_fops);
128 * mic_delete_debug_dir - Uninitialize MIC debugfs entries.
130 void mic_delete_debug_dir(struct mic_device *mdev)
132 debugfs_remove_recursive(mdev->dbg_dir);
136 * mic_init_debugfs - Initialize global debugfs entry.
138 void __init mic_init_debugfs(void)
140 mic_dbg = debugfs_create_dir(KBUILD_MODNAME, NULL);
144 * mic_exit_debugfs - Uninitialize global debugfs entry
146 void mic_exit_debugfs(void)
148 debugfs_remove(mic_dbg);