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
3ee1e2b7
Commit
3ee1e2b7
authored
Oct 08, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Plain Diff
Merge
bk://kernel.bkbits.net//home/mochel/linux-2.5-core
into home.osdl.org:/home/torvalds/v2.5/linux
parents
27e21142
4d384024
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
9 deletions
+43
-9
drivers/base/bus.c
drivers/base/bus.c
+0
-4
drivers/base/core.c
drivers/base/core.c
+25
-0
include/linux/device.h
include/linux/device.h
+2
-0
lib/kobject.c
lib/kobject.c
+16
-5
No files found.
drivers/base/bus.c
View file @
3ee1e2b7
...
...
@@ -459,10 +459,6 @@ int bus_add_driver(struct device_driver * drv)
driver_attach
(
drv
);
up_write
(
&
bus
->
subsys
.
rwsem
);
if
(
error
)
{
kobject_unregister
(
&
drv
->
kobj
);
put_bus
(
bus
);
}
}
return
error
;
}
...
...
drivers/base/core.c
View file @
3ee1e2b7
...
...
@@ -76,6 +76,8 @@ static struct sysfs_ops dev_sysfs_ops = {
static
void
device_release
(
struct
kobject
*
kobj
)
{
struct
device
*
dev
=
to_dev
(
kobj
);
struct
completion
*
c
=
dev
->
complete
;
if
(
dev
->
release
)
dev
->
release
(
dev
);
else
{
...
...
@@ -84,6 +86,8 @@ static void device_release(struct kobject * kobj)
dev
->
bus_id
);
WARN_ON
(
1
);
}
if
(
c
)
complete
(
c
);
}
static
struct
kobj_type
ktype_device
=
{
...
...
@@ -349,6 +353,26 @@ void device_unregister(struct device * dev)
put_device
(
dev
);
}
/**
* device_unregister_wait - Unregister device and wait for it to be freed.
* @dev: Device to unregister.
*
* For the cases where the caller needs to wait for all references to
* be dropped from the device before continuing (e.g. modules with
* statically allocated devices), this function uses a completion struct
* to wait, along with a matching complete() in device_release() above.
*/
void
device_unregister_wait
(
struct
device
*
dev
)
{
struct
completion
c
;
init_completion
(
&
c
);
dev
->
complete
=
&
c
;
device_unregister
(
dev
);
wait_for_completion
(
&
c
);
}
/**
* device_for_each_child - device child iterator.
* @dev: parent struct device.
...
...
@@ -389,6 +413,7 @@ EXPORT_SYMBOL(device_register);
EXPORT_SYMBOL
(
device_del
);
EXPORT_SYMBOL
(
device_unregister
);
EXPORT_SYMBOL
(
device_unregister_wait
);
EXPORT_SYMBOL
(
get_device
);
EXPORT_SYMBOL
(
put_device
);
...
...
include/linux/device.h
View file @
3ee1e2b7
...
...
@@ -254,6 +254,7 @@ struct device {
struct
list_head
children
;
struct
device
*
parent
;
struct
completion
*
complete
;
/* Notification for freeing device. */
struct
kobject
kobj
;
char
bus_id
[
BUS_ID_SIZE
];
/* position on parent bus */
...
...
@@ -301,6 +302,7 @@ dev_set_drvdata (struct device *dev, void *data)
*/
extern
int
device_register
(
struct
device
*
dev
);
extern
void
device_unregister
(
struct
device
*
dev
);
extern
void
device_unregister_wait
(
struct
device
*
dev
);
extern
void
device_initialize
(
struct
device
*
dev
);
extern
int
device_add
(
struct
device
*
dev
);
extern
void
device_del
(
struct
device
*
dev
);
...
...
lib/kobject.c
View file @
3ee1e2b7
...
...
@@ -331,6 +331,7 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
int
limit
=
KOBJ_NAME_LEN
;
int
need
;
va_list
args
;
char
*
name
;
va_start
(
args
,
fmt
);
/*
...
...
@@ -338,25 +339,33 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
*/
need
=
vsnprintf
(
kobj
->
name
,
limit
,
fmt
,
args
);
if
(
need
<
limit
)
kobj
->
k_
name
=
kobj
->
name
;
name
=
kobj
->
name
;
else
{
/*
* Need more space? Allocate it and try again
*/
kobj
->
k_
name
=
kmalloc
(
need
,
GFP_KERNEL
);
if
(
!
kobj
->
k_
name
)
{
name
=
kmalloc
(
need
,
GFP_KERNEL
);
if
(
!
name
)
{
error
=
-
ENOMEM
;
goto
Done
;
}
limit
=
need
;
need
=
vsnprintf
(
kobj
->
k_
name
,
limit
,
fmt
,
args
);
need
=
vsnprintf
(
name
,
limit
,
fmt
,
args
);
/* Still? Give up. */
if
(
need
>
limit
)
{
kfree
(
kobj
->
k_
name
);
kfree
(
name
);
error
=
-
EFAULT
;
goto
Done
;
}
}
/* Free the old name, if necessary. */
if
(
kobj
->
k_name
&&
kobj
->
k_name
!=
kobj
->
name
)
kfree
(
kobj
->
k_name
);
/* Now, set the new name */
kobj
->
k_name
=
name
;
Done:
va_end
(
args
);
return
error
;
...
...
@@ -627,6 +636,8 @@ EXPORT_SYMBOL(kobject_unregister);
EXPORT_SYMBOL
(
kobject_get
);
EXPORT_SYMBOL
(
kobject_put
);
EXPORT_SYMBOL
(
kset_register
);
EXPORT_SYMBOL
(
kset_unregister
);
EXPORT_SYMBOL
(
kset_find_obj
);
EXPORT_SYMBOL
(
subsystem_init
);
...
...
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