From 396c77d7f8c976b1c7e4af7284ea99d8fd968b5b Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Sat, 2 Oct 2021 13:09:39 +0530 Subject: [PATCH] gpu: nvgpu: fix the return type for power node read/write fops When error (negative value) with int type is returned from read/write fops (gk20a_power_node_ops) is read as ssize_t value as expected in userspace it will be seen as large non-negative number and will suppress the error. Make return type for these fops ssize_t. Also include power_ops.h in power_ops.c. This would have caught the type mismatch issue. Bug 3388725 Change-Id: Ie66b0178b31a1b7d147b4f441884bbba3bd2e4d8 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2604342 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/power_ops.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/power_ops.c b/drivers/gpu/nvgpu/os/linux/power_ops.c index cb8474ba9..366796c5e 100644 --- a/drivers/gpu/nvgpu/os/linux/power_ops.c +++ b/drivers/gpu/nvgpu/os/linux/power_ops.c @@ -32,6 +32,8 @@ #include "ioctl.h" +#include "power_ops.h" + #include "platform_gk20a.h" #include "os_linux.h" #include "module.h" @@ -56,7 +58,7 @@ int gk20a_power_open(struct inode *inode, struct file *filp) return 0; } -int gk20a_power_read(struct file *filp, char __user *buf, +ssize_t gk20a_power_read(struct file *filp, char __user *buf, size_t size, loff_t *off) { struct gk20a *g = filp->private_data; @@ -90,8 +92,7 @@ int gk20a_power_read(struct file *filp, char __user *buf, return size; } - -int gk20a_power_write(struct file *filp, const char __user *buf, +ssize_t gk20a_power_write(struct file *filp, const char __user *buf, size_t size, loff_t *off) { struct gk20a *g = filp->private_data;