From 71be6bb5203e32caa2aaf90b77b7bdbc8abac8b8 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Thu, 19 Sep 2024 15:40:33 -0400 Subject: 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). --- device_info_procfs.c | 8 ++++++-- 1 file 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 @@ static ssize_t nvdebug_reg32_read(struct file *f, char __user *buf, size_t size, loff_t *off) { char out[16]; int chars_written; + uint32_t read; struct nvdebug_state *g = &g_nvdebug_state[file2parentgpuidx(f)]; if (size < 16 || *off != 0) return 0; + + if ((read = nvdebug_readl(g, (uintptr_t)pde_data(file_inode(f)))) == -1) + return -EOPNOTSUPP; // 32 bit register will always take less than 16 characters to print - chars_written = scnprintf(out, 16, "%#0x\n", nvdebug_readl(g, (uintptr_t)pde_data(file_inode(f)))); + chars_written = scnprintf(out, 16, "%#0x\n", nvdebug_readl(g, read)); if (copy_to_user(buf, out, chars_written)) - printk(KERN_WARNING "Unable to copy all data for %s\n", file_dentry(f)->d_name.name); + printk(KERN_WARNING "[nvdebug] %s: Unable to copy all data for %s\n", __func__, file_dentry(f)->d_name.name); *off += chars_written; return chars_written; } -- cgit v1.2.2