linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: dmg@turingmachine.org
To: linux-usb@vger.kernel.org
Cc: gregkh@linuxfoundation.org, Daniel M German <dmg@turingmachine.org>
Subject: [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb
Date: Mon, 17 Jun 2019 16:30:50 -0700	[thread overview]
Message-ID: <20190617233050.21409-1-dmg@turingmachine.org> (raw)

From: Daniel M German <dmg@turingmachine.org>

Use min_t to find the minimum of two values instead of using the ?: operator.

This change does not alter functionality. It is merely cosmetic intended to
improve the readability of the code.

Signed-off-by: Daniel M German <dmg@turingmachine.org>
---
 drivers/usb/gadget/function/u_ether.c | 2 +-
 drivers/usb/misc/adutux.c             | 2 +-
 drivers/usb/storage/realtek_cr.c      | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 737bd77a575d..f6ba46684ddb 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -1006,7 +1006,7 @@ int gether_get_ifname(struct net_device *net, char *name, int len)
 	rtnl_lock();
 	ret = snprintf(name, len, "%s\n", netdev_name(net));
 	rtnl_unlock();
-	return ret < len ? ret : len;
+	return min_t(int, ret, len);
 }
 EXPORT_SYMBOL_GPL(gether_get_ifname);
 
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
index 9465fb95d70a..4a9fa3152f2a 100644
--- a/drivers/usb/misc/adutux.c
+++ b/drivers/usb/misc/adutux.c
@@ -379,7 +379,7 @@ static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
 
 		if (data_in_secondary) {
 			/* drain secondary buffer */
-			int amount = bytes_to_read < data_in_secondary ? bytes_to_read : data_in_secondary;
+			int amount = min_t(size_t, bytes_to_read, data_in_secondary);
 			i = copy_to_user(buffer, dev->read_buffer_secondary+dev->secondary_head, amount);
 			if (i) {
 				retval = -EFAULT;
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index cc794e25a0b6..15ce54bde600 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -260,7 +260,7 @@ static int rts51x_bulk_transport(struct us_data *us, u8 lun,
 	 * was really transferred and what the device tells us
 	 */
 	if (residue)
-		residue = residue < buf_len ? residue : buf_len;
+		residue = min_t(unsigned int, residue, buf_len);
 
 	if (act_len)
 		*act_len = buf_len - residue;
-- 
2.20.1


             reply	other threads:[~2019-06-17 23:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-17 23:30 dmg [this message]
2019-06-18  6:49 ` [PATCH] usb: Replace a < b ? a : b construct with min_t(type, a, b) in drivers/usb Greg KH
2019-06-18 15:00   ` dmg
2019-06-18 15:26     ` Greg KH
2019-06-18  7:15 ` Felipe Balbi
2019-06-18 10:03 ` David Laight

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=20190617233050.21409-1-dmg@turingmachine.org \
    --to=dmg@turingmachine.org \
    --cc=gregkh@linuxfoundation.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;
as well as URLs for NNTP newsgroup(s).