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
8c61259d
Commit
8c61259d
authored
Apr 26, 2004
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
USB: switch struct urb to use a kref instead of it's own atomic_t
parent
c1c737a2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
drivers/usb/core/urb.c
drivers/usb/core/urb.c
+13
-8
include/linux/usb.h
include/linux/usb.h
+2
-1
No files found.
drivers/usb/core/urb.c
View file @
8c61259d
...
...
@@ -13,6 +13,14 @@
#include <linux/usb.h>
#include "hcd.h"
#define to_urb(d) container_of(d, struct urb, kref)
static
void
urb_destroy
(
struct
kref
*
kref
)
{
struct
urb
*
urb
=
to_urb
(
kref
);
kfree
(
urb
);
}
/**
* usb_init_urb - initializes a urb so that it can be used by a USB driver
* @urb: pointer to the urb to initialize
...
...
@@ -31,7 +39,7 @@ void usb_init_urb(struct urb *urb)
{
if
(
urb
)
{
memset
(
urb
,
0
,
sizeof
(
*
urb
));
urb
->
count
=
(
atomic_t
)
ATOMIC_INIT
(
1
);
kref_init
(
&
urb
->
kref
,
urb_destroy
);
spin_lock_init
(
&
urb
->
lock
);
}
}
...
...
@@ -80,8 +88,7 @@ struct urb *usb_alloc_urb(int iso_packets, int mem_flags)
void
usb_free_urb
(
struct
urb
*
urb
)
{
if
(
urb
)
if
(
atomic_dec_and_test
(
&
urb
->
count
))
kfree
(
urb
);
kref_put
(
&
urb
->
kref
);
}
/**
...
...
@@ -96,11 +103,9 @@ void usb_free_urb(struct urb *urb)
*/
struct
urb
*
usb_get_urb
(
struct
urb
*
urb
)
{
if
(
urb
)
{
atomic_inc
(
&
urb
->
count
);
if
(
urb
)
kref_get
(
&
urb
->
kref
);
return
urb
;
}
else
return
NULL
;
}
...
...
include/linux/usb.h
View file @
8c61259d
...
...
@@ -14,6 +14,7 @@
#include <linux/delay.h>
/* for mdelay() */
#include <linux/interrupt.h>
/* for in_interrupt() */
#include <linux/list.h>
/* for struct list_head */
#include <linux/kref.h>
/* for struct kref */
#include <linux/device.h>
/* for struct device */
#include <linux/fs.h>
/* for struct file_operations */
#include <linux/completion.h>
/* for struct completion */
...
...
@@ -731,8 +732,8 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *);
struct
urb
{
/* private, usb core and host controller only fields in the urb */
struct
kref
kref
;
/* reference count of the URB */
spinlock_t
lock
;
/* lock for the URB */
atomic_t
count
;
/* reference count of the URB */
void
*
hcpriv
;
/* private data for host controller */
struct
list_head
urb_list
;
/* list pointer to all active urbs */
int
bandwidth
;
/* bandwidth for INT/ISO request */
...
...
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