From patchwork Thu Apr 27 13:33:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Neukum X-Patchwork-Id: 88264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp273132vqo; Thu, 27 Apr 2023 06:36:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BCUv/MPIbI5MguncqpjQnjI8EnaJbc6qmPLKRf/iu+OYCsSKSrIkc5orwrL5EetkliIQV X-Received: by 2002:a17:90a:bd02:b0:237:ae7c:15be with SMTP id y2-20020a17090abd0200b00237ae7c15bemr1981675pjr.30.1682602564611; Thu, 27 Apr 2023 06:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682602564; cv=none; d=google.com; s=arc-20160816; b=r6Kp5MSIpL3JR5GXwLGS8SAHh2mfhtH0fT8U9pJ2gxar45jRWtoiLLveBfL1he4/2I Khx0kS1jkJkOKpiDWpFsv9aQXMQLf71NAKFiEWhsDCAlntAmydyz5Kf9kl46aq+aJe1J vWkidSTcSpn4UVP8rvoR8JfHARY2M06sAQvnL0xCu/US6d9zDSIPanpaffp048mku4Kg QvY2L7xiEct7JBdull2pLPcvFJUsFDUHSF9C80+qARud3SvLEi0utBXmfzgpoHeZ/fW/ BSQMkpVKHXqVVuSKyo72j2c3T3nvERm9yh4LlGWhEGWyHmobbmnZLoKsLwZrZcWobzax E+4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/rGz1l1uLq4Eq57pl2TyE1vJ2RUc3Gpmtm+3jwEAOK8=; b=N+CopjJWL8H4ejwgfVeoXcU/rDb7LtseEiBcf7hkFZDTfRyKVxTmfXzix0k7e0S65q E033DwDp15Cz20/hfqUIVyHNjmUr8QjgL1W1YGPdg6vbp2jjqqC42T4ElWKYoOdg+kvD HeFAd+gdYcrZcbpHS/HtQp2j62LaGOz2hAA5D+deEoFPFaZ8fJshaupskYa+TkgBez68 Wwu6GRdQnR1A3lH/bsKsFV0vKAYwErwRaK7WExeQtHbdkjithnFZdOcPE4DuLDh8Pi/4 1yEabUV5sVyVkJMKcHH/stSFjC8UOOUBoi5FXhavw1SrvpKdiHPRCInBEQ4hkmXFJV61 ziLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=uruuRKW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a63dd50000000b004dccf388f93si17862848pgj.522.2023.04.27.06.35.48; Thu, 27 Apr 2023 06:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=uruuRKW4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243820AbjD0NeN (ORCPT + 99 others); Thu, 27 Apr 2023 09:34:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243618AbjD0Nd5 (ORCPT ); Thu, 27 Apr 2023 09:33:57 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0F7E48; Thu, 27 Apr 2023 06:33:56 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4CB0521B40; Thu, 27 Apr 2023 13:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1682602435; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/rGz1l1uLq4Eq57pl2TyE1vJ2RUc3Gpmtm+3jwEAOK8=; b=uruuRKW4koGd2EIxG245KlByD6Z0p4TOVjH06eIK/3BFSDlMs3qxZN4henqSYK1V1ZWSLw PIKqzimQrPYWRnJHsY4z0PPAm3ASCqYxm5uktpUfu8poVS/FUULiBdCjazz9s8umGD3nIJ oc3iVuYN7KWsyBZlMcvwzqUQ/QRPTJo= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 09E93138F9; Thu, 27 Apr 2023 13:33:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yCO+AMN5SmSVeQAAMHmgww (envelope-from ); Thu, 27 Apr 2023 13:33:55 +0000 From: Oliver Neukum To: wim@linux-watchdog.org, linux@roeck-us.net, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Oliver Neukum Subject: [PATCH 5/8] pcwd_usb: usb_pcwd_ioctl: return IO errors Date: Thu, 27 Apr 2023 15:33:47 +0200 Message-Id: <20230427133350.31064-6-oneukum@suse.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230427133350.31064-1-oneukum@suse.com> References: <20230427133350.31064-1-oneukum@suse.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764336666585533604?= X-GMAIL-MSGID: =?utf-8?q?1764336666585533604?= 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 --- 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: