diff options
| author | Heiko Stuebner <heiko@sntech.de> | 2025-08-04 15:07:26 +0200 |
|---|---|---|
| committer | Lee Jones <lee@kernel.org> | 2025-10-01 10:28:16 +0100 |
| commit | 71f529e9fedc377b43b73ec9d28ec59d9a3a2792 (patch) | |
| tree | 420a43b6a4e7002930e0b5ae0ccdb839c31cdac9 | |
| parent | 21c5ffb4211203de0a91de8a1c4a329e508a2ffb (diff) | |
| download | linux-71f529e9fedc377b43b73ec9d28ec59d9a3a2792.tar.gz linux-71f529e9fedc377b43b73ec9d28ec59d9a3a2792.zip | |
mfd: qnap-mcu: Improve structure in qnap_mcu_exec
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 <heiko@sntech.de>
Link: https://lore.kernel.org/r/20250804130726.3180806-5-heiko@sntech.de
Signed-off-by: Lee Jones <lee@kernel.org>
| -rw-r--r-- | drivers/mfd/qnap-mcu.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/mfd/qnap-mcu.c b/drivers/mfd/qnap-mcu.c index 6875f27151e9..4ec1f4cf902f 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 = reply_data_size + QNAP_MCU_CHECKSUM_SIZE; struct qnap_mcu_reply *reply = &mcu->reply; int ret = 0; + u8 crc; 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 = qnap_mcu_csum(rx, reply_data_size); - - if (crc != rx[reply_data_size]) { - dev_err(&mcu->serdev->dev, - "Invalid Checksum received\n"); - return -EIO; - } else { - memcpy(reply_data, rx, reply_data_size); - } } + crc = qnap_mcu_csum(rx, reply_data_size); + if (crc != 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); |
