aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>2006-08-26 22:48:11 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-27 14:58:55 -0400
commit095bc335360a51623dd8571839bbf465851a7f4b (patch)
treee28c101dd9665b67b137e3e21a8161c1bcf4b898
parent83a07196735dbf371b61d6dffbb7e6a696c633c2 (diff)
USB core: Use const where possible.
This patch marks some USB core's functions parameters as const. This improves the design (we're saying to the caller that its parameter is not going to be modified) and may help in compiler's optimisation work. Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/core/usb.c21
-rw-r--r--drivers/usb/core/usb.h4
-rw-r--r--include/linux/usb.h18
3 files changed, 22 insertions, 21 deletions
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 82837d45b484..4eb98eb3804f 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -67,7 +67,8 @@ static int nousb; /* Disable USB when built into kernel image */
67 * Don't call this function unless you are bound to one of the interfaces 67 * Don't call this function unless you are bound to one of the interfaces
68 * on this device or you have locked the device! 68 * on this device or you have locked the device!
69 */ 69 */
70struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum) 70struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
71 unsigned ifnum)
71{ 72{
72 struct usb_host_config *config = dev->actconfig; 73 struct usb_host_config *config = dev->actconfig;
73 int i; 74 int i;
@@ -100,8 +101,8 @@ struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
100 * Don't call this function unless you are bound to the intf interface 101 * Don't call this function unless you are bound to the intf interface
101 * or you have locked the device! 102 * or you have locked the device!
102 */ 103 */
103struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf, 104struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface *intf,
104 unsigned int altnum) 105 unsigned int altnum)
105{ 106{
106 int i; 107 int i;
107 108
@@ -356,7 +357,7 @@ void usb_put_intf(struct usb_interface *intf)
356 * case the driver already owns the device lock.) 357 * case the driver already owns the device lock.)
357 */ 358 */
358int usb_lock_device_for_reset(struct usb_device *udev, 359int usb_lock_device_for_reset(struct usb_device *udev,
359 struct usb_interface *iface) 360 const struct usb_interface *iface)
360{ 361{
361 unsigned long jiffies_expire = jiffies + HZ; 362 unsigned long jiffies_expire = jiffies + HZ;
362 363
@@ -852,8 +853,8 @@ void usb_buffer_unmap (struct urb *urb)
852 * 853 *
853 * Reverse the effect of this call with usb_buffer_unmap_sg(). 854 * Reverse the effect of this call with usb_buffer_unmap_sg().
854 */ 855 */
855int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, 856int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
856 struct scatterlist *sg, int nents) 857 struct scatterlist *sg, int nents)
857{ 858{
858 struct usb_bus *bus; 859 struct usb_bus *bus;
859 struct device *controller; 860 struct device *controller;
@@ -887,8 +888,8 @@ int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
887 * Use this when you are re-using a scatterlist's data buffers for 888 * Use this when you are re-using a scatterlist's data buffers for
888 * another USB request. 889 * another USB request.
889 */ 890 */
890void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, 891void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe,
891 struct scatterlist *sg, int n_hw_ents) 892 struct scatterlist *sg, int n_hw_ents)
892{ 893{
893 struct usb_bus *bus; 894 struct usb_bus *bus;
894 struct device *controller; 895 struct device *controller;
@@ -913,8 +914,8 @@ void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
913 * 914 *
914 * Reverses the effect of usb_buffer_map_sg(). 915 * Reverses the effect of usb_buffer_map_sg().
915 */ 916 */
916void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, 917void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe,
917 struct scatterlist *sg, int n_hw_ents) 918 struct scatterlist *sg, int n_hw_ents)
918{ 919{
919 struct usb_bus *bus; 920 struct usb_bus *bus;
920 struct device *controller; 921 struct device *controller;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 6096ead2758c..67da6d0b316f 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -53,7 +53,7 @@ extern struct usb_device_driver usb_generic_driver;
53 * no such thing as a platform USB device, so we can steal the use 53 * no such thing as a platform USB device, so we can steal the use
54 * of the platform_data field. */ 54 * of the platform_data field. */
55 55
56static inline int is_usb_device(struct device *dev) 56static inline int is_usb_device(const struct device *dev)
57{ 57{
58 return dev->platform_data == &usb_generic_driver; 58 return dev->platform_data == &usb_generic_driver;
59} 59}
@@ -78,7 +78,7 @@ static inline void mark_quiesced(struct usb_interface *f)
78 f->is_active = 0; 78 f->is_active = 0;
79} 79}
80 80
81static inline int is_active(struct usb_interface *f) 81static inline int is_active(const struct usb_interface *f)
82{ 82{
83 return f->is_active; 83 return f->is_active;
84} 84}
diff --git a/include/linux/usb.h b/include/linux/usb.h
index f807479ef65b..26d8a5f36896 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -387,7 +387,7 @@ extern void usb_put_dev(struct usb_device *dev);
387#define usb_unlock_device(udev) up(&(udev)->dev.sem) 387#define usb_unlock_device(udev) up(&(udev)->dev.sem)
388#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) 388#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem)
389extern int usb_lock_device_for_reset(struct usb_device *udev, 389extern int usb_lock_device_for_reset(struct usb_device *udev,
390 struct usb_interface *iface); 390 const struct usb_interface *iface);
391 391
392/* USB port reset for device reinitialization */ 392/* USB port reset for device reinitialization */
393extern int usb_reset_device(struct usb_device *dev); 393extern int usb_reset_device(struct usb_device *dev);
@@ -426,10 +426,10 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
426 426
427extern struct usb_interface *usb_find_interface(struct usb_driver *drv, 427extern struct usb_interface *usb_find_interface(struct usb_driver *drv,
428 int minor); 428 int minor);
429extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, 429extern struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
430 unsigned ifnum); 430 unsigned ifnum);
431extern struct usb_host_interface *usb_altnum_to_altsetting( 431extern struct usb_host_interface *usb_altnum_to_altsetting(
432 struct usb_interface *intf, unsigned int altnum); 432 const struct usb_interface *intf, unsigned int altnum);
433 433
434 434
435/** 435/**
@@ -1064,14 +1064,14 @@ void usb_buffer_unmap (struct urb *urb);
1064#endif 1064#endif
1065 1065
1066struct scatterlist; 1066struct scatterlist;
1067int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, 1067int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
1068 struct scatterlist *sg, int nents); 1068 struct scatterlist *sg, int nents);
1069#if 0 1069#if 0
1070void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, 1070void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe,
1071 struct scatterlist *sg, int n_hw_ents); 1071 struct scatterlist *sg, int n_hw_ents);
1072#endif 1072#endif
1073void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, 1073void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe,
1074 struct scatterlist *sg, int n_hw_ents); 1074 struct scatterlist *sg, int n_hw_ents);
1075 1075
1076/*-------------------------------------------------------------------* 1076/*-------------------------------------------------------------------*
1077 * SYNCHRONOUS CALL SUPPORT * 1077 * SYNCHRONOUS CALL SUPPORT *