Re: [PATCH] usb:gadget: use min_t() macro instead of min()

2011-06-13 Thread Felipe Balbi
Hi,


On Sun, Jun 12, 2011 at 02:14:46PM +0300, Tatyana Brokhman wrote:
 Signed-off-by: Tatyana Brokhman tlin...@codeaurora.org

I need a sensible commit log for this. Why do we need to change all
min() to min_t() ?

-- 
balbi


signature.asc
Description: Digital signature


RE: [PATCH] usb:gadget: use min_t() macro instead of min()

2011-06-13 Thread Alan Stern
On Mon, 13 Jun 2011, Tanya Brokhman wrote:

  
  On Sun, Jun 12, 2011 at 02:14:46PM +0300, Tatyana Brokhman wrote:
   Signed-off-by: Tatyana Brokhman tlin...@codeaurora.org
  
  I need a sensible commit log for this. Why do we need to change all
  min() to min_t() ?
  
 
 Actually, Alan asked me to make this change in one place in dummy_hcd. I
 wasn't aware of the min_t macro before that. So when I searched the code for
 other places I found quite a few and just thought that it would be nicer
 to use min_t() instead of min() with casting. 
 So we don't need to make this change. Everything works as is. This patch
 only makes the code look nicer, nothing more.
 I can elaborate the above in the commit log if you want.

The change I suggested involved replacing two typecasts with a single 
min_t.  All (or almost all) the places this patch touches currently 
contain only one typecast, so the motivation for changing them is a lot 
weaker.

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] usb:gadget: use min_t() macro instead of min()

2011-06-13 Thread Tanya Brokhman
 
 The change I suggested involved replacing two typecasts with a single
 min_t.  All (or almost all) the places this patch touches currently
 contain only one typecast, so the motivation for changing them is a lot
 weaker.
 
You're right. So what's the final call on this one? Do you think it can be
merged or you prefer not change anything? I personally think the code looks
nicer using min_t instead of min with casting but that's just my opinion and
of course there are arguments against this patch.


Thanks,
Tanya Brokhman
---
Sent by an consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.





--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH] usb:gadget: use min_t() macro instead of min()

2011-06-13 Thread Alan Stern
On Mon, 13 Jun 2011, Tanya Brokhman wrote:

  
  The change I suggested involved replacing two typecasts with a single
  min_t.  All (or almost all) the places this patch touches currently
  contain only one typecast, so the motivation for changing them is a lot
  weaker.
  
 You're right. So what's the final call on this one? Do you think it can be
 merged or you prefer not change anything? I personally think the code looks
 nicer using min_t instead of min with casting but that's just my opinion and
 of course there are arguments against this patch.

I don't care either way.  It's up to you and Felipe.

Alan Stern

--
To unsubscribe from this list: send the line unsubscribe linux-arm-msm in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb:gadget: use min_t() macro instead of min()

2011-06-12 Thread Tatyana Brokhman
Signed-off-by: Tatyana Brokhman tlin...@codeaurora.org

---
 drivers/usb/gadget/composite.c  |   16 
 drivers/usb/gadget/dummy_hcd.c  |2 +-
 drivers/usb/gadget/f_fs.c   |6 +++---
 drivers/usb/gadget/f_mass_storage.c |   20 ++--
 drivers/usb/gadget/file_storage.c   |   22 +++---
 drivers/usb/gadget/fsl_udc_core.c   |4 ++--
 drivers/usb/gadget/gmidi.c  |   10 +-
 drivers/usb/gadget/inode.c  |   12 ++--
 drivers/usb/gadget/mv_udc_core.c|4 ++--
 drivers/usb/gadget/omap_udc.c   |6 +++---
 drivers/usb/gadget/printer.c|   16 
 drivers/usb/gadget/usbstring.c  |2 +-
 drivers/usb/gadget/uvc_video.c  |4 ++--
 13 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index d825dbc..aa2db3f 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1085,7 +1085,7 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
cdev-desc.bcdUSB = cpu_to_le16(0x0210);
}
 
-   value = min(w_length, (u16) sizeof cdev-desc);
+   value = min_t(u16, w_length, sizeof(cdev-desc));
memcpy(req-buf, cdev-desc, value);
break;
case USB_DT_DEVICE_QUALIFIER:
@@ -1104,18 +1104,18 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
case USB_DT_CONFIG:
value = config_desc(cdev, w_value);
if (value = 0)
-   value = min(w_length, (u16) value);
+   value = min_t(u16, w_length, value);
break;
case USB_DT_STRING:
value = get_string(cdev, req-buf,
w_index, w_value  0xff);
if (value = 0)
-   value = min(w_length, (u16) value);
+   value = min_t(u16, w_length, value);
break;
case USB_DT_BOS:
if (gadget_is_superspeed(gadget)) {
value = bos_desc(cdev);
-   value = min(w_length, (u16) value);
+   value = min_t(u16, w_length, value);
}
break;
}
@@ -1144,7 +1144,7 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
*(u8 *)req-buf = cdev-config-bConfigurationValue;
else
*(u8 *)req-buf = 0;
-   value = min(w_length, (u16) 1);
+   value = min_t(u16, w_length, 1);
break;
 
/* function drivers must handle get/set altsetting; if there's
@@ -1183,7 +1183,7 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
if (value  0)
break;
*((u8 *)req-buf) = value;
-   value = min(w_length, (u16) 1);
+   value = min_t(u16, w_length, 1);
break;
 
/*
@@ -1607,8 +1607,8 @@ int usb_composite_probe(struct usb_composite_driver 
*driver,
driver-iProduct = driver-name;
composite_driver.function =  (char *) driver-name;
composite_driver.driver.name = driver-name;
-   composite_driver.speed = min((u8)composite_driver.speed,
-(u8)driver-max_speed);
+   composite_driver.speed = min_t(u8, composite_driver.speed,
+  driver-max_speed);
composite = driver;
composite_gadget_bind = bind;
 
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 74b7655..e134ea8 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -1213,7 +1213,7 @@ top:
/* not enough bandwidth left? */
if (limit  ep-ep.maxpacket  limit  len)
break;
-   len = min (len, (unsigned) limit);
+   len = min_t(unsigned, len, limit);
if (len == 0)
break;
 
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index c161a9a..468e935 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -502,7 +502,7 @@ static ssize_t ffs_ep0_write(struct file *file, const char 
__user *buf,
}
 
/* FFS_SETUP_PENDING and not stall */
-   len = min(len, (size_t)le16_to_cpu(ffs-ev.setup.wLength));
+   len = min_t(size_t, len,