From nobody Sun Feb 8 09:29:53 2026 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 916FC22D4C0 for ; Mon, 4 Aug 2025 13:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312859; cv=none; b=I3pTU+tyetkWL+PVvR/VQqU5/sS7oR+i5ZXCvLnklGZ9VzHk+fGKkMMgD8qD2i6ephK5zhdBR76jFqZvDO2POOYqZApH5IPbqLzryCn3rjdV1vmCWgPgQP/19SE+IhxdV1P8spQzIC8MUIglcOtb2gy3ZzTXB4A69XT5NvsCeIs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312859; c=relaxed/simple; bh=tXY0UG9dEPlaD0d+syf1G87HcAD/g5qfseSBwhr/oVk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uTCgUHFXW8LyOK3d5yB1vAetp++XhkbhVBfudorL5mChdXexNAY6KqCKZBg7PVHOeZtlPeUs+wbpX5qkL3SqmRMJc5JUUs+jEbEiytLJWNhNU8gQAqmCcIi5TVp7Y+mDYmYMrpujF5ARwE9RaNc8Ak72we6aXSCpcuf7iuLLGkc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b=IflIlvJU; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b="IflIlvJU" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To; bh=DaP0ayMeGByY0ROe63H0HewzgwwoiTuHUzxlFsQn5vc=; b=IflIlvJUMBjYUqWkKpmBSRGQje 9XylnDnR5Mh8AdUow0Na6XIoAJAsqVJLLQWsZh5Z0wDxL9D5FXoTBYlabqMwmxu+smUPdqsf9BJ5p Yz7blE9zN1iUmCVuvJnq1795mrTqcSl7za3HsEVo+3ve6aUnFB2skJDcF1rjx9IeOjuuFIxcrAIOu 6BBxc5MNY8A2GddppSbHWXdXMrSygvWKPbg0IQf/tZ2Fnn3QLyNF3u0Y2rHRe2RllH70QP/gSapt+ cZpTK/bWrNu4hAovvxfD57OXtPRFS+t4Xq4a+sK9YJ00BnEKVjYFiKHmat5yksZrpsPgbSizdeov/ 9XIjQOaQ==; Received: from [194.95.143.137] (helo=phil.dip.tu-dresden.de) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uiuuc-0004Ov-LV; Mon, 04 Aug 2025 15:07:34 +0200 From: Heiko Stuebner To: lee@kernel.org Cc: heiko@sntech.de, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mfd: qnap-mcu: include linux/types.h in qnap-mcu.h shared header Date: Mon, 4 Aug 2025 15:07:23 +0200 Message-ID: <20250804130726.3180806-2-heiko@sntech.de> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250804130726.3180806-1-heiko@sntech.de> References: <20250804130726.3180806-1-heiko@sntech.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Relying on other components to include those basic types is unrelyable and may cause compile errors like: ../include/linux/mfd/qnap-mcu.h:13:9: error: unknown type name =E2=80=98u32= =E2=80=99 13 | u32 baud_rate; | ^~~ ../include/linux/mfd/qnap-mcu.h:17:9: error: unknown type name =E2=80=98boo= l=E2=80=99 17 | bool usb_led; | ^~~~ So make sure, the types used in the header are available. Signed-off-by: Heiko Stuebner --- include/linux/mfd/qnap-mcu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/mfd/qnap-mcu.h b/include/linux/mfd/qnap-mcu.h index 8d48c212fd44..42bf523f9a5b 100644 --- a/include/linux/mfd/qnap-mcu.h +++ b/include/linux/mfd/qnap-mcu.h @@ -7,6 +7,8 @@ #ifndef _LINUX_QNAP_MCU_H_ #define _LINUX_QNAP_MCU_H_ =20 +#include + struct qnap_mcu; =20 struct qnap_mcu_variant { --=20 2.47.2 From nobody Sun Feb 8 09:29:53 2026 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9162838D for ; Mon, 4 Aug 2025 13:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312859; cv=none; b=I2o0q+hNeT++HtDxLAKLhenCdQWPjnqsuuJ/zih5sYM/7QL6IxePJmk4Pc537KYYh7VeKarx/5RybPeAbZOHswzPbaGK+If/HqBD17kyEH+cUoP+sf4pMMiY+TdqgKE/vcqeqWW8vKA2P/9n+YflnFVOmvaVkAGysxYB831gCJI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312859; c=relaxed/simple; bh=t1VVDq5gsgWO4hJuz6Bueawo6Sfhw2PRg1m+lLHu2eg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KA8VVClPv4w8RfxvBMuL71SaJyLk454pRrTF+d2gHlBHtprByB/oKi4bLYe02AJ07dvFU1ZWzCAg1QpsXOMvUHdsvkt+d2bKnGfvYIM1zNts4UCliUpS/X6xAfv3ZVkbr79OigJhzAQQVFiHmwMiwn+GkJkUsoLA2n90KkoI9hI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b=nBXMycAZ; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b="nBXMycAZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type; bh=99LrBt/odIJurv9nnoEhYRVaTFqvbrSDf57BXnFddig=; b=nBXMycAZg9wxYuKJpGlOHaojA5 2oMn4OBjXtxKdxDgrP5p5Skr/weeWm0KStj7mvIAK5DKkfuVUIVTteOTZYlUlpVVWL4F21+Sg3eOj 4a5/0RhNyWVFeTwSDyUNr16oEX9B1GNphrpghXOFg+3E4y/OTF5BFfd1MW4vIEJYD255hqs06PRdY 4IRU7GjsDee+BTT85AWSMATKeThylmNJy7KFdjAPkTwwJXI31hr919y3mQuUNIoaZJuHQCoXUHFcc 8QO4+3xED0XCOHqCL0WT38zhNSy4AmiVdHWVIjOSQcHJdfgvGVmIGHSNfyBTskRkxk5jfgly5nFLK el1kKWIw==; Received: from [194.95.143.137] (helo=phil.dip.tu-dresden.de) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uiuuc-0004Ov-Pn; Mon, 04 Aug 2025 15:07:34 +0200 From: Heiko Stuebner To: lee@kernel.org Cc: heiko@sntech.de, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mfd: qnap-mcu: handle errors returned from qnap_mcu_write Date: Mon, 4 Aug 2025 15:07:24 +0200 Message-ID: <20250804130726.3180806-3-heiko@sntech.de> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250804130726.3180806-1-heiko@sntech.de> References: <20250804130726.3180806-1-heiko@sntech.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" qnap_mcu_write can return errors and those were not checked before. So do that now. Signed-off-by: Heiko Stuebner --- drivers/mfd/qnap-mcu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mfd/qnap-mcu.c b/drivers/mfd/qnap-mcu.c index e340e9337b98..6448237c4c35 100644 --- a/drivers/mfd/qnap-mcu.c +++ b/drivers/mfd/qnap-mcu.c @@ -163,7 +163,11 @@ int qnap_mcu_exec(struct qnap_mcu *mcu, reply->received =3D 0; reinit_completion(&reply->done); =20 - qnap_mcu_write(mcu, cmd_data, cmd_data_size); + ret =3D qnap_mcu_write(mcu, cmd_data, cmd_data_size); + if (ret < 0) { + mutex_unlock(&mcu->bus_lock); + return ret; + } =20 serdev_device_wait_until_sent(mcu->serdev, msecs_to_jiffies(QNAP_MCU_TIME= OUT_MS)); =20 --=20 2.47.2 From nobody Sun Feb 8 09:29:53 2026 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9176324BCE8 for ; Mon, 4 Aug 2025 13:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312859; cv=none; b=M/1QfCw0YbHHCpN3HBUbdD8U6Uycgp49JRjjZ3l6PfYbCSLoLDVIfSR6C61pBfstcs6ECrygkJyD4VjYDDogRIRlyuC4lSwewEg2P6IGlfTqtaP2g7XVVPGl6Bm5tSuSPk8ktpTdvMOXw3/pCiPbV3b8bdMzqtTcrG6fv2GcdN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312859; c=relaxed/simple; bh=c2KCw+7/JubXkEWrkrjGSF3igBfPYanRA/j2cUU0QLM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aXYZFhOx5yFi7IR62dIiAwf3mKjaR5rDdwecMz8DOs8PdopW4QW7FaH6dZCbRrt2ZIGCYkzhMcyHXMzhJmY6oNX8uLaDkXItBXpCzYcvnKm/XtjMZuR3nZgm7yM39dVlForJgLb4K9A9RvSiTq2avsfPReAM+fB2DdoTKyM+kJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b=gKxRH/5Y; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b="gKxRH/5Y" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type; bh=QUVGRAbMjoz729uEHckqeaG16KmrbTwZ75S0p71sw8s=; b=gKxRH/5YmFOaKDRkJ6PLVzYFRx NtuUiI6Xe+s7TLB+wJs8HvGg0YUxxM0wKn0Tlwdoi4UkkdL9jSY/1Rper2bJ0WC8ddEVqUKOrRkPs FBaIrwXJV976wR9aiRLmkq3RGmaEIS9kurnJcv0IDcxbfEiaBQ8sZGNkuLwBnK+WABWXuA2S98rjR S/bUTq2zGjAQ1Rv8sGzCBXdvN+Q0iKxddNtGp9abBCNmHUoAGyzz6dTqbkZJmqmJQzEzcOdJLLZa5 CpiqVRZOpa/AB4NvtIEskpLj7xttxZhRkJ4WA6BdvXZVz/p4h3TIsdojse6k1l7Wi3cmxM55UTR91 o0InBXSw==; Received: from [194.95.143.137] (helo=phil.dip.tu-dresden.de) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uiuuc-0004Ov-U1; Mon, 04 Aug 2025 15:07:34 +0200 From: Heiko Stuebner To: lee@kernel.org Cc: heiko@sntech.de, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] mfd: qnap-mcu: convert to guard(mutex) in qnap_mcu_exec Date: Mon, 4 Aug 2025 15:07:25 +0200 Message-ID: <20250804130726.3180806-4-heiko@sntech.de> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250804130726.3180806-1-heiko@sntech.de> References: <20250804130726.3180806-1-heiko@sntech.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" guard() makes sure that the mutex gets unlocked when the function returns and thus removes the need for unlock gotos or similar mechanisms and therefore allows for a simpler function structure. So convert the qnap_mcu_exec function to use it. Signed-off-by: Heiko Stuebner --- drivers/mfd/qnap-mcu.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/qnap-mcu.c b/drivers/mfd/qnap-mcu.c index 6448237c4c35..7bc44c64b7fd 100644 --- a/drivers/mfd/qnap-mcu.c +++ b/drivers/mfd/qnap-mcu.c @@ -156,7 +156,7 @@ int qnap_mcu_exec(struct qnap_mcu *mcu, return -EINVAL; } =20 - mutex_lock(&mcu->bus_lock); + guard(mutex)(&mcu->bus_lock); =20 reply->data =3D rx; reply->length =3D length; @@ -164,30 +164,27 @@ int qnap_mcu_exec(struct qnap_mcu *mcu, reinit_completion(&reply->done); =20 ret =3D qnap_mcu_write(mcu, cmd_data, cmd_data_size); - if (ret < 0) { - mutex_unlock(&mcu->bus_lock); + if (ret < 0) return ret; - } =20 serdev_device_wait_until_sent(mcu->serdev, msecs_to_jiffies(QNAP_MCU_TIME= OUT_MS)); =20 if (!wait_for_completion_timeout(&reply->done, msecs_to_jiffies(QNAP_MCU_= TIMEOUT_MS))) { dev_err(&mcu->serdev->dev, "Command timeout\n"); - ret =3D -ETIMEDOUT; + return -ETIMEDOUT; } else { u8 crc =3D qnap_mcu_csum(rx, reply_data_size); =20 if (crc !=3D rx[reply_data_size]) { dev_err(&mcu->serdev->dev, "Invalid Checksum received\n"); - ret =3D -EIO; + return -EIO; } else { memcpy(reply_data, rx, reply_data_size); } } =20 - mutex_unlock(&mcu->bus_lock); - return ret; + return 0; } EXPORT_SYMBOL_GPL(qnap_mcu_exec); =20 --=20 2.47.2 From nobody Sun Feb 8 09:29:53 2026 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAAF52561DD for ; Mon, 4 Aug 2025 13:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.11.138.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312860; cv=none; b=brMg4PYCSQgyxxa8fPGAi+Q7ARHLXgoPCZUFML2VqR7p9Ov1CIQNANbRKw1L2/nMBFOJX5M7urOaKoGf24D/3UpC5VhKexD0JQfl+2EUGhhRCWPLpWcJlh/8Gd3NbVV2q3GM+B/vuYybNs4zkV/y/hCCYiXx95ScmORgT4P+1po= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754312860; c=relaxed/simple; bh=gszgmE3egusp73Kl9T+BXMe1xCZq6NJI1lDr6hNEKtw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IY1nmzMvyVSxcIvNelOhYveQxLQCsBMh44q+LENaRI5wzwE3VZ2icDZK6CXpkhX+Bxx0E5EOqEpJAQwOpWcUHCBFDgR/a7hyIkwDQ9/mE/WGAwCGW8FE2aUsAIvwBXsOSakzKXQCb5DzYPpWwYCwYnGru56fCal5sDyIZw/tBJ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b=koG0dxPH; arc=none smtp.client-ip=185.11.138.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.b="koG0dxPH" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type; bh=PlsxJs5jBRnnm3qO38nHT7pYaFCNT0nICADm4nW+Jvg=; b=koG0dxPH2MJYIICwEd60WRb0so W50Y5uMuo4mvDCpLc7587LcLKpemA8pjnA2Ew5rAt3yeECUQ3xCVVOxeCVoJLQQIxEcK5syv+0e/M VTb84itU/h4THY7ElrPxAdFfXX0tinCl4SsheIlMCcxoN70teY9jco8l6IbMx6S46DpxULA1wCafB jhpXY3L50u8yr9LtSCP/gyJfEoDvOmWXor108mhPtEh3kedN7u0a6lLsf9CZFPGINeY1jdftlZiEy kvh3pMLIId3bQ0xiryHd+aB4FSOehoGB90ZOI7YXmNsJSvSIjj2oXz6mU1lr8LaGI5zMWCdcdfqTo m/13w01w==; Received: from [194.95.143.137] (helo=phil.dip.tu-dresden.de) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uiuud-0004Ov-27; Mon, 04 Aug 2025 15:07:35 +0200 From: Heiko Stuebner To: lee@kernel.org Cc: heiko@sntech.de, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mfd: qnap-mcu: improve structure in qnap_mcu_exec Date: Mon, 4 Aug 2025 15:07:26 +0200 Message-ID: <20250804130726.3180806-5-heiko@sntech.de> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250804130726.3180806-1-heiko@sntech.de> References: <20250804130726.3180806-1-heiko@sntech.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now with guard(mutex) in place, we can make the function's structure a bit easier to read, by removing the nested if-else-clauses. Signed-off-by: Heiko Stuebner --- drivers/mfd/qnap-mcu.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/mfd/qnap-mcu.c b/drivers/mfd/qnap-mcu.c index 7bc44c64b7fd..2be429a50611 100644 --- a/drivers/mfd/qnap-mcu.c +++ b/drivers/mfd/qnap-mcu.c @@ -150,6 +150,7 @@ int qnap_mcu_exec(struct qnap_mcu *mcu, size_t length =3D reply_data_size + QNAP_MCU_CHECKSUM_SIZE; struct qnap_mcu_reply *reply =3D &mcu->reply; int ret =3D 0; + u8 crc; =20 if (length > sizeof(rx)) { dev_err(&mcu->serdev->dev, "expected data too big for receive buffer"); @@ -172,18 +173,16 @@ int qnap_mcu_exec(struct qnap_mcu *mcu, if (!wait_for_completion_timeout(&reply->done, msecs_to_jiffies(QNAP_MCU_= TIMEOUT_MS))) { dev_err(&mcu->serdev->dev, "Command timeout\n"); return -ETIMEDOUT; - } else { - u8 crc =3D qnap_mcu_csum(rx, reply_data_size); - - if (crc !=3D rx[reply_data_size]) { - dev_err(&mcu->serdev->dev, - "Invalid Checksum received\n"); - return -EIO; - } else { - memcpy(reply_data, rx, reply_data_size); - } } =20 + crc =3D qnap_mcu_csum(rx, reply_data_size); + if (crc !=3D rx[reply_data_size]) { + dev_err(&mcu->serdev->dev, "Invalid Checksum received\n"); + return -EIO; + } + + memcpy(reply_data, rx, reply_data_size); + return 0; } EXPORT_SYMBOL_GPL(qnap_mcu_exec); --=20 2.47.2