Skip to content

Commit

Permalink
USB core: Use const where possible.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Luiz Fernando N. Capitulino authored and Greg Kroah-Hartman committed Sep 27, 2006
1 parent 83a0719 commit 095bc33
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
21 changes: 11 additions & 10 deletions drivers/usb/core/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ static int nousb; /* Disable USB when built into kernel image */
* Don't call this function unless you are bound to one of the interfaces
* on this device or you have locked the device!
*/
struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
unsigned ifnum)
{
struct usb_host_config *config = dev->actconfig;
int i;
Expand Down Expand Up @@ -100,8 +101,8 @@ struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
* Don't call this function unless you are bound to the intf interface
* or you have locked the device!
*/
struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf,
unsigned int altnum)
struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface *intf,
unsigned int altnum)
{
int i;

Expand Down Expand Up @@ -356,7 +357,7 @@ void usb_put_intf(struct usb_interface *intf)
* case the driver already owns the device lock.)
*/
int usb_lock_device_for_reset(struct usb_device *udev,
struct usb_interface *iface)
const struct usb_interface *iface)
{
unsigned long jiffies_expire = jiffies + HZ;

Expand Down Expand Up @@ -852,8 +853,8 @@ void usb_buffer_unmap (struct urb *urb)
*
* Reverse the effect of this call with usb_buffer_unmap_sg().
*/
int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int nents)
int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int nents)
{
struct usb_bus *bus;
struct device *controller;
Expand Down Expand Up @@ -887,8 +888,8 @@ int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
* Use this when you are re-using a scatterlist's data buffers for
* another USB request.
*/
void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents)
void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents)
{
struct usb_bus *bus;
struct device *controller;
Expand All @@ -913,8 +914,8 @@ void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
*
* Reverses the effect of usb_buffer_map_sg().
*/
void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents)
void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents)
{
struct usb_bus *bus;
struct device *controller;
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/core/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern struct usb_device_driver usb_generic_driver;
* no such thing as a platform USB device, so we can steal the use
* of the platform_data field. */

static inline int is_usb_device(struct device *dev)
static inline int is_usb_device(const struct device *dev)
{
return dev->platform_data == &usb_generic_driver;
}
Expand All @@ -78,7 +78,7 @@ static inline void mark_quiesced(struct usb_interface *f)
f->is_active = 0;
}

static inline int is_active(struct usb_interface *f)
static inline int is_active(const struct usb_interface *f)
{
return f->is_active;
}
Expand Down
18 changes: 9 additions & 9 deletions include/linux/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ extern void usb_put_dev(struct usb_device *dev);
#define usb_unlock_device(udev) up(&(udev)->dev.sem)
#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem)
extern int usb_lock_device_for_reset(struct usb_device *udev,
struct usb_interface *iface);
const struct usb_interface *iface);

/* USB port reset for device reinitialization */
extern int usb_reset_device(struct usb_device *dev);
Expand Down Expand Up @@ -426,10 +426,10 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,

extern struct usb_interface *usb_find_interface(struct usb_driver *drv,
int minor);
extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev,
extern struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
unsigned ifnum);
extern struct usb_host_interface *usb_altnum_to_altsetting(
struct usb_interface *intf, unsigned int altnum);
const struct usb_interface *intf, unsigned int altnum);


/**
Expand Down Expand Up @@ -1064,14 +1064,14 @@ void usb_buffer_unmap (struct urb *urb);
#endif

struct scatterlist;
int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int nents);
int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int nents);
#if 0
void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents);
void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents);
#endif
void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents);
void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe,
struct scatterlist *sg, int n_hw_ents);

/*-------------------------------------------------------------------*
* SYNCHRONOUS CALL SUPPORT *
Expand Down

0 comments on commit 095bc33

Please sign in to comment.