aboutsummaryrefslogtreecommitdiffstats
path: root/device_info_procfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'device_info_procfs.c')
-rw-r--r--device_info_procfs.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/device_info_procfs.c b/device_info_procfs.c
index efef41a..b2bcd1a 100644
--- a/device_info_procfs.c
+++ b/device_info_procfs.c
@@ -40,13 +40,13 @@ typedef struct {
40static void* device_info_file_seq_start(struct seq_file *s, loff_t *pos) { 40static void* device_info_file_seq_start(struct seq_file *s, loff_t *pos) {
41 static device_info_iter idx; 41 static device_info_iter idx;
42 struct nvdebug_state *g = &g_nvdebug_state[seq2gpuidx(s)]; 42 struct nvdebug_state *g = &g_nvdebug_state[seq2gpuidx(s)];
43 int is_ampere = g->chip_id == NV_CHIP_ID_AMPERE; 43 int is_ampere = g->chip_id >= NV_CHIP_ID_AMPERE;
44 // If start of sequence, reset `idx` 44 // If start of sequence, reset `idx`
45 if (*pos == 0) { 45 if (*pos == 0) {
46 idx.index = 0; 46 idx.index = 0;
47 idx.type_of_next_entry = is_ampere ? 0 : -1; 47 idx.type_of_next_entry = is_ampere ? 0 : -1;
48 } 48 }
49 idx.total_entries = is_ampere ? NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS : NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g); 49 idx.total_entries = is_ampere ? NV_PTOP_DEVICE_INFO__SIZE_1_AMPERE(g) : NV_PTOP_DEVICE_INFO__SIZE_1_PREVIOUS;
50 // Number of possible info entries is fixed, and list is sparse 50 // Number of possible info entries is fixed, and list is sparse
51 if (idx.index >= idx.total_entries) 51 if (idx.index >= idx.total_entries)
52 return NULL; 52 return NULL;
@@ -163,16 +163,22 @@ static void device_info_file_seq_stop(struct seq_file *s, void *idx) {
163 // No cleanup needed 163 // No cleanup needed
164} 164}
165 165
166static struct seq_operations device_info_file_seq_ops = { 166static const struct seq_operations device_info_file_seq_ops = {
167 .start = device_info_file_seq_start, 167 .start = device_info_file_seq_start,
168 .next = device_info_file_seq_next, 168 .next = device_info_file_seq_next,
169 .stop = device_info_file_seq_stop 169 .stop = device_info_file_seq_stop
170}; 170};
171 171
172static int device_info_file_open(struct inode *inode, struct file *f) { 172static int device_info_file_open(struct inode *inode, struct file *f) {
173 struct seq_operations file_seq_ops = device_info_file_seq_ops; 173 if(g_nvdebug_state[file2parentgpuidx(f)].chip_id >= NV_CHIP_ID_AMPERE) {
174 file_seq_ops.show = (g_nvdebug_state[file2parentgpuidx(f)].chip_id == NV_CHIP_ID_AMPERE) ? device_info_file_seq_show_ampere : device_info_file_seq_show_previous; 174 static struct seq_operations file_seq_ops_ampere = device_info_file_seq_ops;
175 return seq_open(f, &file_seq_ops); 175 file_seq_ops_ampere.show = device_info_file_seq_show_ampere;
176 return seq_open(f, &file_seq_ops_ampere);
177 } else {
178 static struct seq_operations file_seq_ops_previous = device_info_file_seq_ops;
179 file_seq_ops_previous.show = device_info_file_seq_show_previous;
180 return seq_open(f, &file_seq_ops_previous);
181 }
176} 182}
177 183
178struct file_operations device_info_file_ops = { 184struct file_operations device_info_file_ops = {