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@xxxxxxxx> --- 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