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
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)
...
@@ -459,10 +459,6 @@ int bus_add_driver(struct device_driver * drv)
driver_attach
(
drv
);
driver_attach
(
drv
);
up_write
(
&
bus
->
subsys
.
rwsem
);
up_write
(
&
bus
->
subsys
.
rwsem
);
if
(
error
)
{
kobject_unregister
(
&
drv
->
kobj
);
put_bus
(
bus
);
}
}
}
return
error
;
return
error
;
}
}
...
...
drivers/base/core.c
View file @
3ee1e2b7
...
@@ -76,6 +76,8 @@ static struct sysfs_ops dev_sysfs_ops = {
...
@@ -76,6 +76,8 @@ static struct sysfs_ops dev_sysfs_ops = {
static
void
device_release
(
struct
kobject
*
kobj
)
static
void
device_release
(
struct
kobject
*
kobj
)
{
{
struct
device
*
dev
=
to_dev
(
kobj
);
struct
device
*
dev
=
to_dev
(
kobj
);
struct
completion
*
c
=
dev
->
complete
;
if
(
dev
->
release
)
if
(
dev
->
release
)
dev
->
release
(
dev
);
dev
->
release
(
dev
);
else
{
else
{
...
@@ -84,6 +86,8 @@ static void device_release(struct kobject * kobj)
...
@@ -84,6 +86,8 @@ static void device_release(struct kobject * kobj)
dev
->
bus_id
);
dev
->
bus_id
);
WARN_ON
(
1
);
WARN_ON
(
1
);
}
}
if
(
c
)
complete
(
c
);
}
}
static
struct
kobj_type
ktype_device
=
{
static
struct
kobj_type
ktype_device
=
{
...
@@ -349,6 +353,26 @@ void device_unregister(struct device * dev)
...
@@ -349,6 +353,26 @@ void device_unregister(struct device * dev)
put_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.
* device_for_each_child - device child iterator.
* @dev: parent struct device.
* @dev: parent struct device.
...
@@ -389,6 +413,7 @@ EXPORT_SYMBOL(device_register);
...
@@ -389,6 +413,7 @@ EXPORT_SYMBOL(device_register);
EXPORT_SYMBOL
(
device_del
);
EXPORT_SYMBOL
(
device_del
);
EXPORT_SYMBOL
(
device_unregister
);
EXPORT_SYMBOL
(
device_unregister
);
EXPORT_SYMBOL
(
device_unregister_wait
);
EXPORT_SYMBOL
(
get_device
);
EXPORT_SYMBOL
(
get_device
);
EXPORT_SYMBOL
(
put_device
);
EXPORT_SYMBOL
(
put_device
);
...
...
include/linux/device.h
View file @
3ee1e2b7
...
@@ -254,6 +254,7 @@ struct device {
...
@@ -254,6 +254,7 @@ struct device {
struct
list_head
children
;
struct
list_head
children
;
struct
device
*
parent
;
struct
device
*
parent
;
struct
completion
*
complete
;
/* Notification for freeing device. */
struct
kobject
kobj
;
struct
kobject
kobj
;
char
bus_id
[
BUS_ID_SIZE
];
/* position on parent bus */
char
bus_id
[
BUS_ID_SIZE
];
/* position on parent bus */
...
@@ -301,6 +302,7 @@ dev_set_drvdata (struct device *dev, void *data)
...
@@ -301,6 +302,7 @@ dev_set_drvdata (struct device *dev, void *data)
*/
*/
extern
int
device_register
(
struct
device
*
dev
);
extern
int
device_register
(
struct
device
*
dev
);
extern
void
device_unregister
(
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
void
device_initialize
(
struct
device
*
dev
);
extern
int
device_add
(
struct
device
*
dev
);
extern
int
device_add
(
struct
device
*
dev
);
extern
void
device_del
(
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, ...)
...
@@ -331,6 +331,7 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
int
limit
=
KOBJ_NAME_LEN
;
int
limit
=
KOBJ_NAME_LEN
;
int
need
;
int
need
;
va_list
args
;
va_list
args
;
char
*
name
;
va_start
(
args
,
fmt
);
va_start
(
args
,
fmt
);
/*
/*
...
@@ -338,25 +339,33 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
...
@@ -338,25 +339,33 @@ int kobject_set_name(struct kobject * kobj, const char * fmt, ...)
*/
*/
need
=
vsnprintf
(
kobj
->
name
,
limit
,
fmt
,
args
);
need
=
vsnprintf
(
kobj
->
name
,
limit
,
fmt
,
args
);
if
(
need
<
limit
)
if
(
need
<
limit
)
kobj
->
k_
name
=
kobj
->
name
;
name
=
kobj
->
name
;
else
{
else
{
/*
/*
* Need more space? Allocate it and try again
* Need more space? Allocate it and try again
*/
*/
kobj
->
k_
name
=
kmalloc
(
need
,
GFP_KERNEL
);
name
=
kmalloc
(
need
,
GFP_KERNEL
);
if
(
!
kobj
->
k_
name
)
{
if
(
!
name
)
{
error
=
-
ENOMEM
;
error
=
-
ENOMEM
;
goto
Done
;
goto
Done
;
}
}
limit
=
need
;
limit
=
need
;
need
=
vsnprintf
(
kobj
->
k_
name
,
limit
,
fmt
,
args
);
need
=
vsnprintf
(
name
,
limit
,
fmt
,
args
);
/* Still? Give up. */
/* Still? Give up. */
if
(
need
>
limit
)
{
if
(
need
>
limit
)
{
kfree
(
kobj
->
k_
name
);
kfree
(
name
);
error
=
-
EFAULT
;
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:
Done:
va_end
(
args
);
va_end
(
args
);
return
error
;
return
error
;
...
@@ -627,6 +636,8 @@ EXPORT_SYMBOL(kobject_unregister);
...
@@ -627,6 +636,8 @@ EXPORT_SYMBOL(kobject_unregister);
EXPORT_SYMBOL
(
kobject_get
);
EXPORT_SYMBOL
(
kobject_get
);
EXPORT_SYMBOL
(
kobject_put
);
EXPORT_SYMBOL
(
kobject_put
);
EXPORT_SYMBOL
(
kset_register
);
EXPORT_SYMBOL
(
kset_unregister
);
EXPORT_SYMBOL
(
kset_find_obj
);
EXPORT_SYMBOL
(
kset_find_obj
);
EXPORT_SYMBOL
(
subsystem_init
);
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