The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Javier Carrasco <javier.carrasco@wolfvision.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [PATCH 3/3] usb: typec: tipd: use min() to set tps6598x firmware packet size
Date: Thu, 6 Jun 2024 12:35:32 +0300	[thread overview]
Message-ID: <ZmGC5MGJEGh32Vrp@kuha.fi.intel.com> (raw)
In-Reply-To: <20240606-tps6598x_fw_update_log-v1-3-2b5b8369a0ba@wolfvision.net>

On Thu, Jun 06, 2024 at 11:03:57AM +0200, Javier Carrasco wrote:
> Simplify the current firmware packet size check in the tps6598x
> implementation by means of a single call to min(), which is what the
> current code does in a more verbose, less elegant way.
> 
> This patch fixes a cocci warning ("WARNING opportunity for min()").
> 
> Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> Signed-off-by: Javier Carrasco <javier.carrasco@wolfvision.net>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tipd/core.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index 58f6eeffd070..ea768b19a7f1 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -1165,10 +1165,7 @@ static int tps6598x_apply_patch(struct tps6598x *tps)
>  
>  	bytes_left = fw->size;
>  	while (bytes_left) {
> -		if (bytes_left < TPS_MAX_LEN)
> -			in_len = bytes_left;
> -		else
> -			in_len = TPS_MAX_LEN;
> +		in_len = min(bytes_left, TPS_MAX_LEN);
>  		ret = tps6598x_exec_cmd(tps, "PTCd", in_len,
>  					fw->data + copied_bytes,
>  					TPS_PTCD_OUT_BYTES, out);
> 
> -- 
> 2.40.1

-- 
heikki

      reply	other threads:[~2024-06-06  9:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06  9:03 [PATCH 0/3] usb: typec: tipd: minor improvements in the firmware update code Javier Carrasco
2024-06-06  9:03 ` [PATCH 1/3] usb: typec: tipd: drop second firmware name read Javier Carrasco
2024-06-06  9:34   ` Heikki Krogerus
2024-06-06  9:03 ` [PATCH 2/3] usb: typec: tipd: add error log to provide firmware name and size Javier Carrasco
2024-06-06  9:35   ` Heikki Krogerus
2024-06-06  9:03 ` [PATCH 3/3] usb: typec: tipd: use min() to set tps6598x firmware packet size Javier Carrasco
2024-06-06  9:35   ` 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=ZmGC5MGJEGh32Vrp@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=javier.carrasco@wolfvision.net \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /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