lkml.org 
[lkml]   [2023]   [Apr]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 5/8] pcwd_usb: usb_pcwd_ioctl: return IO errors
Date
Reporting back to user space that a watchdog
is disabled although it is not due to an IO error
is evil. Pass through errors.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/watchdog/pcwd_usb.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/pcwd_usb.c b/drivers/watchdog/pcwd_usb.c
index fe58ec84ce8c..b99b8fee2873 100644
--- a/drivers/watchdog/pcwd_usb.c
+++ b/drivers/watchdog/pcwd_usb.c
@@ -420,22 +420,30 @@ static long usb_pcwd_ioctl(struct file *file, unsigned int cmd,

case WDIOC_SETOPTIONS:
{
- int new_options, retval = -EINVAL;
+ int new_options, retval = 0;
+ int r;
+ bool specified_something = false;

if (get_user(new_options, p))
return -EFAULT;

if (new_options & WDIOS_DISABLECARD) {
- usb_pcwd_stop(usb_pcwd_device);
- retval = 0;
+ r = usb_pcwd_stop(usb_pcwd_device);
+ retval = r < 0 ? -EIO : 0;
+ specified_something = true;
}

+ /*
+ * technically both options are combinable
+ * that makes error reporting tricky
+ */
if (new_options & WDIOS_ENABLECARD) {
- usb_pcwd_start(usb_pcwd_device);
- retval = 0;
+ r = usb_pcwd_start(usb_pcwd_device);
+ retval = retval < 0 ? retval : (r < 0 ? -EIO : 0);
+ specified_something = true;
}

- return retval;
+ return specified_something ? retval : -EINVAL;
}

case WDIOC_KEEPALIVE:
--
2.40.0
\
 
 \ /
  Last update: 2023-04-27 15:35    [W:0.086 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site