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
Kirill Smelkov
linux
Commits
d745be1e
Commit
d745be1e
authored
Oct 08, 2002
by
Patrick Mochel
Browse files
Options
Browse Files
Download
Plain Diff
Merge osdl.org:/home/mochel/src/kernel/devel/linux-2.5-virgin
into osdl.org:/home/mochel/src/kernel/devel/linux-2.5-core
parents
8e12e1f9
3c0405be
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
13 deletions
+37
-13
drivers/base/core.c
drivers/base/core.c
+31
-7
drivers/base/fs/device.c
drivers/base/fs/device.c
+1
-2
drivers/ide/ide-disk.c
drivers/ide/ide-disk.c
+1
-1
drivers/usb/core/usb.c
drivers/usb/core/usb.c
+2
-2
include/linux/device.h
include/linux/device.h
+2
-1
No files found.
drivers/base/core.c
View file @
d745be1e
...
...
@@ -175,7 +175,7 @@ int device_register(struct device *dev)
INIT_LIST_HEAD
(
&
dev
->
intf_list
);
spin_lock_init
(
&
dev
->
lock
);
atomic_set
(
&
dev
->
refcount
,
2
);
dev
->
present
=
1
;
spin_lock
(
&
device_lock
);
if
(
dev
->
parent
)
{
get_device_locked
(
dev
->
parent
);
...
...
@@ -219,7 +219,7 @@ int device_register(struct device *dev)
struct
device
*
get_device_locked
(
struct
device
*
dev
)
{
struct
device
*
ret
=
dev
;
if
(
dev
&&
atomic_read
(
&
dev
->
refcount
)
>
0
)
if
(
dev
&&
dev
->
present
&&
atomic_read
(
&
dev
->
refcount
)
>
0
)
atomic_inc
(
&
dev
->
refcount
);
else
ret
=
NULL
;
...
...
@@ -241,8 +241,35 @@ struct device * get_device(struct device * dev)
*/
void
put_device
(
struct
device
*
dev
)
{
struct
device
*
parent
;
if
(
!
atomic_dec_and_lock
(
&
dev
->
refcount
,
&
device_lock
))
return
;
parent
=
dev
->
parent
;
dev
->
parent
=
NULL
;
spin_unlock
(
&
device_lock
);
BUG_ON
(
dev
->
present
);
if
(
dev
->
release
)
dev
->
release
(
dev
);
if
(
parent
)
put_device
(
parent
);
}
/**
* device_unregister - unlink device
* @dev: device going away
*
* The device has been removed from the system, so we disavow knowledge
* of it. It might not be the final reference to the device, so we mark
* it as !present, so no more references to it can be acquired.
* In the end, we decrement the final reference count for it.
*/
void
device_unregister
(
struct
device
*
dev
)
{
spin_lock
(
&
device_lock
);
dev
->
present
=
0
;
list_del_init
(
&
dev
->
node
);
list_del_init
(
&
dev
->
g_list
);
list_del_init
(
&
dev
->
bus_list
);
...
...
@@ -267,11 +294,7 @@ void put_device(struct device * dev)
/* remove the driverfs directory */
device_remove_dir
(
dev
);
if
(
dev
->
release
)
dev
->
release
(
dev
);
if
(
dev
->
parent
)
put_device
(
dev
->
parent
);
put_device
(
dev
);
}
static
int
__init
device_init
(
void
)
...
...
@@ -287,5 +310,6 @@ static int __init device_init(void)
core_initcall
(
device_init
);
EXPORT_SYMBOL
(
device_register
);
EXPORT_SYMBOL
(
device_unregister
);
EXPORT_SYMBOL
(
get_device
);
EXPORT_SYMBOL
(
put_device
);
drivers/base/fs/device.c
View file @
d745be1e
...
...
@@ -90,8 +90,7 @@ int device_create_file(struct device * dev, struct device_attribute * entry)
{
int
error
=
-
EINVAL
;
if
(
dev
)
{
get_device
(
dev
);
if
(
get_device
(
dev
))
{
error
=
driverfs_create_file
(
&
entry
->
attr
,
&
dev
->
dir
);
put_device
(
dev
);
}
...
...
drivers/ide/ide-disk.c
View file @
d745be1e
...
...
@@ -1802,7 +1802,7 @@ static int idedisk_cleanup (ide_drive_t *drive)
{
struct
gendisk
*
g
=
drive
->
disk
;
put_device
(
&
drive
->
disk
->
disk_dev
);
device_unregister
(
&
drive
->
disk
->
disk_dev
);
if
((
drive
->
id
->
cfs_enable_2
&
0x3000
)
&&
drive
->
wcache
)
if
(
do_idedisk_flushcache
(
drive
))
printk
(
KERN_INFO
"%s: Write Cache FAILED Flushing!
\n
"
,
...
...
drivers/usb/core/usb.c
View file @
d745be1e
...
...
@@ -789,7 +789,7 @@ void usb_disconnect(struct usb_device **pdev)
struct
usb_interface
*
interface
=
&
dev
->
actconfig
->
interface
[
i
];
/* remove this interface */
put_device
(
&
interface
->
dev
);
device_unregister
(
&
interface
->
dev
);
}
}
...
...
@@ -797,7 +797,7 @@ void usb_disconnect(struct usb_device **pdev)
if
(
dev
->
devnum
>
0
)
{
clear_bit
(
dev
->
devnum
,
dev
->
bus
->
devmap
.
devicemap
);
usbfs_remove_device
(
dev
);
put_device
(
&
dev
->
dev
);
device_unregister
(
&
dev
->
dev
);
}
/* Decrement the reference count, it'll auto free everything when */
...
...
include/linux/device.h
View file @
d745be1e
...
...
@@ -289,6 +289,7 @@ struct device {
void
*
platform_data
;
/* Platform specific data (e.g. ACPI,
BIOS data relevant to device) */
u32
present
;
u32
current_state
;
/* Current operating state. In
ACPI-speak, this is D0-D3, D0
being fully functional, and D3
...
...
@@ -327,7 +328,7 @@ dev_set_drvdata (struct device *dev, void *data)
* High level routines for use by the bus drivers
*/
extern
int
device_register
(
struct
device
*
dev
);
extern
void
device_unregister
(
struct
device
*
dev
);
/* driverfs interface for exporting device attributes */
...
...
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