aboutsummaryrefslogtreecommitdiffstats
path: root/device_info_procfs.c
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2024-09-19 15:40:33 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2024-09-19 15:40:33 -0400
commit71be6bb5203e32caa2aaf90b77b7bdbc8abac8b8 (patch)
tree5ee5a4270c0b054eee1076e8c2c798753ec22048 /device_info_procfs.c
parent3653aee74ae8338b9da1f0304b0eaa1171dd640f (diff)
Return an error, rather than a flag value, from `nvdebug_reg32_read()`
This is used to back APIs like `num_gpcs`. Better to return an error to the caller, rather than -1 (which may be confused for an actual result).
Diffstat (limited to 'device_info_procfs.c')
-rw-r--r--device_info_procfs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/device_info_procfs.c b/device_info_procfs.c
index ce5843f..0229eec 100644
--- a/device_info_procfs.c
+++ b/device_info_procfs.c
@@ -12,13 +12,17 @@
12static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, loff_t *off) { 12static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, loff_t *off) {
13 char out[16]; 13 char out[16];
14 int chars_written; 14 int chars_written;
15 uint32_t read;
15 struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; 16 struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)];
16 if (size < 16 || *off != 0) 17 if (size < 16 || *off != 0)
17 return 0; 18 return 0;
19
20 if ((read = nvdebug_readl(g, (uintptr_t)pde_data(file_inode(f)))) == -1)
21 return -EOPNOTSUPP;
18 // 32 bit register will always take less than 16 characters to print 22 // 32 bit register will always take less than 16 characters to print
19 chars_written = scnprintf(out, 16, "%#0x\n", nvdebug_readl(g, (uintptr_t)pde_data(file_inode(f)))); 23 chars_written = scnprintf(out, 16, "%#0x\n", nvdebug_readl(g, read));
20 if (copy_to_user(buf, out, chars_written)) 24 if (copy_to_user(buf, out, chars_written))
21 printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name); 25 printk(KERN_WARNING "[nvdebug] %s: Unable to copy all data for %s\n", __func__, file_dentry(f)->d_name.name);
22 *off += chars_written; 26 *off += chars_written;
23 return chars_written; 27 return chars_written;
24} 28}