mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Fedor Pchelkin <boddah8794@gmail.com>,
	"Christian A. Ehrhardt" <lk@c--e.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-usb@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: ucsi: stm32: Use min() to improve ucsi_stm32g0_fw_cb()
Date: Fri, 5 Sep 2025 13:59:57 +0300	[thread overview]
Message-ID: <aLrCrQOdLsqq0U37@kuha.fi.intel.com> (raw)
In-Reply-To: <20250830110426.10007-2-thorsten.blum@linux.dev>

On Sat, Aug 30, 2025 at 01:04:20PM +0200, Thorsten Blum wrote:
> 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>

> ---
>  drivers/usb/typec/ucsi/ucsi_stm32g0.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> 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 <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);
> -- 
> 2.50.1

-- 
heikki

      reply	other threads:[~2025-09-05 11:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-30 11:04 Thorsten Blum
2025-09-05 10:59 ` Heikki Krogerus [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aLrCrQOdLsqq0U37@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=boddah8794@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=lk@c--e.de \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=thorsten.blum@linux.dev \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®