Discussion:
[ORLinux] [PATCH 2/2] ohs900: Use min_t() instead of explicit casts
Geert Uytterhoeven
2013-11-13 09:30:14 UTC
Permalink
This also fixes a compiler warning, as one cast was missing:

drivers/usb/host/ohs900-hcd.c: In function ?out_packet?:
drivers/usb/host/ohs900-hcd.c:256:200: warning: comparison of distinct pointer types lacks a cast [enabled by default]

Signed-off-by: Geert Uytterhoeven <geert at linux-m68k.org>
---
drivers/usb/host/ohs900-hcd.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/host/ohs900-hcd.c b/drivers/usb/host/ohs900-hcd.c
index fbc88378446d..2ec53aa0e46c 100644
--- a/drivers/usb/host/ohs900-hcd.c
+++ b/drivers/usb/host/ohs900-hcd.c
@@ -229,9 +229,8 @@ static void in_packet(struct ohs900 *ohs900,
{
u8 len;
len = ep->maxpacket;
- ep->length =
- min((int)len,
- (int)(urb->transfer_buffer_length - urb->actual_length));
+ ep->length = min_t(int, len,
+ urb->transfer_buffer_length - urb->actual_length);

ohs900_write(ohs900, OHS900_RXFIFOCONTROLREG, OHS900_FIFO_FORCE_EMPTY);
ohs900_write(ohs900, OHS900_TXTRANSTYPEREG, OHS900_IN);
@@ -253,8 +252,8 @@ static void out_packet(struct ohs900 *ohs900,
buf = urb->transfer_buffer + urb->actual_length;
prefetch(buf);

- len = min((int)ep->maxpacket,
- urb->transfer_buffer_length - urb->actual_length);
+ len = min_t(int, ep->maxpacket,
+ urb->transfer_buffer_length - urb->actual_length);

ohs900_write(ohs900, OHS900_TXFIFOCONTROLREG, OHS900_FIFO_FORCE_EMPTY);
if (!(control & OHS900_HCTLMASK_ISO_EN)
--
1.7.9.5
Loading...