Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Heiko Stuebner and committed by
Lee Jones
71f529e9 21c5ffb4

+9 -10
+9 -10
drivers/mfd/qnap-mcu.c
··· 150 150 size_t length = reply_data_size + QNAP_MCU_CHECKSUM_SIZE; 151 151 struct qnap_mcu_reply *reply = &mcu->reply; 152 152 int ret = 0; 153 + u8 crc; 153 154 154 155 if (length > sizeof(rx)) { 155 156 dev_err(&mcu->serdev->dev, "expected data too big for receive buffer"); ··· 173 172 if (!wait_for_completion_timeout(&reply->done, msecs_to_jiffies(QNAP_MCU_TIMEOUT_MS))) { 174 173 dev_err(&mcu->serdev->dev, "Command timeout\n"); 175 174 return -ETIMEDOUT; 176 - } else { 177 - u8 crc = qnap_mcu_csum(rx, reply_data_size); 178 - 179 - if (crc != rx[reply_data_size]) { 180 - dev_err(&mcu->serdev->dev, 181 - "Invalid Checksum received\n"); 182 - return -EIO; 183 - } else { 184 - memcpy(reply_data, rx, reply_data_size); 185 - } 186 175 } 176 + 177 + crc = qnap_mcu_csum(rx, reply_data_size); 178 + if (crc != rx[reply_data_size]) { 179 + dev_err(&mcu->serdev->dev, "Invalid Checksum received\n"); 180 + return -EIO; 181 + } 182 + 183 + memcpy(reply_data, rx, reply_data_size); 187 184 188 185 return 0; 189 186 }