From: Thorsten Blum Date: Sat, 30 Aug 2025 11:04:20 +0000 (+0200) Subject: usb: ucsi: stm32: Use min() to improve ucsi_stm32g0_fw_cb() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=91709d2ce5cdf568b42fcc33473929843ed95cd3;p=users%2Fhch%2Fmisc.git 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 Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20250830110426.10007-2-thorsten.blum@linux.dev Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/typec/ucsi/ucsi_stm32g0.c b/drivers/usb/typec/ucsi/ucsi_stm32g0.c index 57ef7d83a412..838ac0185082 100644 --- a/drivers/usb/typec/ucsi/ucsi_stm32g0.c +++ b/drivers/usb/typec/ucsi/ucsi_stm32g0.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -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);