Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
622d3e6b
Commit
622d3e6b
authored
Mar 30, 2004
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
USB: add usb_get_intf() and usb_put_intf() functions as they will be needed.
parent
4bf49ce4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
drivers/usb/core/usb.c
drivers/usb/core/usb.c
+35
-1
include/linux/usb.h
include/linux/usb.h
+3
-0
No files found.
drivers/usb/core/usb.c
View file @
622d3e6b
...
...
@@ -768,7 +768,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port)
*
* A pointer to the device with the incremented reference counter is returned.
*/
struct
usb_device
*
usb_get_dev
(
struct
usb_device
*
dev
)
struct
usb_device
*
usb_get_dev
(
struct
usb_device
*
dev
)
{
if
(
dev
)
get_device
(
&
dev
->
dev
);
...
...
@@ -788,6 +788,40 @@ void usb_put_dev(struct usb_device *dev)
put_device
(
&
dev
->
dev
);
}
/**
* usb_get_intf - increments the reference count of the usb interface structure
* @intf: the interface being referenced
*
* Each live reference to a interface must be refcounted.
*
* Drivers for USB interfaces should normally record such references in
* their probe() methods, when they bind to an interface, and release
* them by calling usb_put_intf(), in their disconnect() methods.
*
* A pointer to the interface with the incremented reference counter is
* returned.
*/
struct
usb_interface
*
usb_get_intf
(
struct
usb_interface
*
intf
)
{
if
(
intf
)
get_device
(
&
intf
->
dev
);
return
intf
;
}
/**
* usb_put_intf - release a use of the usb interface structure
* @intf: interface that's been decremented
*
* Must be called when a user of an interface is finished with it. When the
* last user of the interface calls this function, the memory of the interface
* is freed.
*/
void
usb_put_intf
(
struct
usb_interface
*
intf
)
{
if
(
intf
)
put_device
(
&
intf
->
dev
);
}
static
struct
usb_device
*
match_device
(
struct
usb_device
*
dev
,
u16
vendor_id
,
u16
product_id
)
{
...
...
include/linux/usb.h
View file @
622d3e6b
...
...
@@ -140,6 +140,9 @@ static inline void usb_set_intfdata (struct usb_interface *intf, void *data)
dev_set_drvdata
(
&
intf
->
dev
,
data
);
}
struct
usb_interface
*
usb_get_intf
(
struct
usb_interface
*
intf
);
void
usb_put_intf
(
struct
usb_interface
*
intf
);
/* this maximum is arbitrary */
#define USB_MAXINTERFACES 32
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment