usb: ucsi: stm32: Use min() to improve ucsi_stm32g0_fw_cb()
Use min() to improve ucsi_stm32g0_fw_cb() and avoid calculating 'end - data' twice. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20250830110426.10007-2-thorsten.blum@linux.dev Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3474a19736
commit
91709d2ce5
@@ -10,6 +10,7 @@
|
||||
#include <linux/firmware.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/minmax.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/unaligned.h>
|
||||
@@ -523,11 +524,7 @@ static void ucsi_stm32g0_fw_cb(const struct firmware *fw, void *context)
|
||||
data = fw->data;
|
||||
end = fw->data + fw->size;
|
||||
while (data < end) {
|
||||
if ((end - data) < STM32G0_I2C_BL_SZ)
|
||||
size = end - data;
|
||||
else
|
||||
size = STM32G0_I2C_BL_SZ;
|
||||
|
||||
size = min(end - data, STM32G0_I2C_BL_SZ);
|
||||
ret = ucsi_stm32g0_bl_write(g0->ucsi, addr, data, size);
|
||||
if (ret) {
|
||||
dev_err(g0->dev, "Write failed %d\n", ret);
|
||||
|
||||
Reference in New Issue
Block a user