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
92807f31
Commit
92807f31
authored
Aug 11, 2003
by
Patrick Mochel
Browse files
Options
Browse Files
Download
Plain Diff
Merge osdl.org:/home/mochel/src/kernel/devel/linux-2.5-core
into osdl.org:/home/mochel/src/kernel/devel/linux-2.5-power
parents
86ccb795
65e5149b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
42 deletions
+61
-42
drivers/base/bus.c
drivers/base/bus.c
+19
-5
drivers/base/class.c
drivers/base/class.c
+4
-4
fs/sysfs/dir.c
fs/sysfs/dir.c
+3
-3
fs/sysfs/file.c
fs/sysfs/file.c
+4
-4
fs/sysfs/group.c
fs/sysfs/group.c
+15
-12
fs/sysfs/sysfs.h
fs/sysfs/sysfs.h
+3
-3
include/linux/device.h
include/linux/device.h
+6
-4
include/linux/sysfs.h
include/linux/sysfs.h
+7
-7
No files found.
drivers/base/bus.c
View file @
92807f31
...
...
@@ -287,6 +287,7 @@ static int device_attach(struct device * dev)
{
struct
bus_type
*
bus
=
dev
->
bus
;
struct
list_head
*
entry
;
int
error
;
if
(
dev
->
driver
)
{
device_bind_driver
(
dev
);
...
...
@@ -296,8 +297,15 @@ static int device_attach(struct device * dev)
if
(
bus
->
match
)
{
list_for_each
(
entry
,
&
bus
->
drivers
.
list
)
{
struct
device_driver
*
drv
=
to_drv
(
entry
);
if
(
!
bus_match
(
dev
,
drv
))
error
=
bus_match
(
dev
,
drv
);
if
(
!
error
)
/* success, driver matched */
return
1
;
if
(
error
!=
-
ENODEV
)
/* driver matched but the probe failed */
printk
(
KERN_WARNING
"%s: probe of %s failed with error %d
\n
"
,
drv
->
name
,
dev
->
bus_id
,
error
);
}
}
...
...
@@ -314,13 +322,14 @@ static int device_attach(struct device * dev)
* If bus_match() returns 0 and the @dev->driver is set, we've found
* a compatible pair.
*
* Note that we ignore the
error from bus_match(), since it's perfectly
* valid for a driver not to bind to any devices.
* Note that we ignore the
-ENODEV error from bus_match(), since it's
*
perfectly
valid for a driver not to bind to any devices.
*/
void
driver_attach
(
struct
device_driver
*
drv
)
{
struct
bus_type
*
bus
=
drv
->
bus
;
struct
list_head
*
entry
;
int
error
;
if
(
!
bus
->
match
)
return
;
...
...
@@ -328,7 +337,12 @@ void driver_attach(struct device_driver * drv)
list_for_each
(
entry
,
&
bus
->
devices
.
list
)
{
struct
device
*
dev
=
container_of
(
entry
,
struct
device
,
bus_list
);
if
(
!
dev
->
driver
)
{
bus_match
(
dev
,
drv
);
error
=
bus_match
(
dev
,
drv
);
if
(
error
&&
(
error
!=
-
ENODEV
))
/* driver matched but the probe failed */
printk
(
KERN_WARNING
"%s: probe of %s failed with error %d
\n
"
,
drv
->
name
,
dev
->
bus_id
,
error
);
}
}
}
...
...
drivers/base/class.c
View file @
92807f31
...
...
@@ -59,7 +59,7 @@ static struct kobj_type ktype_class = {
static
decl_subsys
(
class
,
&
ktype_class
,
NULL
);
int
class_create_file
(
struct
class
*
cls
,
struct
class_attribute
*
attr
)
int
class_create_file
(
struct
class
*
cls
,
const
struct
class_attribute
*
attr
)
{
int
error
;
if
(
cls
)
{
...
...
@@ -69,7 +69,7 @@ int class_create_file(struct class * cls, struct class_attribute * attr)
return
error
;
}
void
class_remove_file
(
struct
class
*
cls
,
struct
class_attribute
*
attr
)
void
class_remove_file
(
struct
class
*
cls
,
const
struct
class_attribute
*
attr
)
{
if
(
cls
)
sysfs_remove_file
(
&
cls
->
subsys
.
kset
.
kobj
,
&
attr
->
attr
);
...
...
@@ -110,7 +110,7 @@ void class_unregister(struct class * cls)
/* Class Device Stuff */
int
class_device_create_file
(
struct
class_device
*
class_dev
,
struct
class_device_attribute
*
attr
)
const
struct
class_device_attribute
*
attr
)
{
int
error
=
-
EINVAL
;
if
(
class_dev
)
...
...
@@ -119,7 +119,7 @@ int class_device_create_file(struct class_device * class_dev,
}
void
class_device_remove_file
(
struct
class_device
*
class_dev
,
struct
class_device_attribute
*
attr
)
const
struct
class_device_attribute
*
attr
)
{
if
(
class_dev
)
sysfs_remove_file
(
&
class_dev
->
kobj
,
&
attr
->
attr
);
...
...
fs/sysfs/dir.c
View file @
92807f31
...
...
@@ -22,7 +22,7 @@ static int init_dir(struct inode * inode)
static
struct
dentry
*
create_dir
(
struct
kobject
*
k
,
struct
dentry
*
p
,
char
*
n
)
create_dir
(
struct
kobject
*
k
,
struct
dentry
*
p
,
c
onst
c
har
*
n
)
{
struct
dentry
*
dentry
;
...
...
@@ -47,7 +47,7 @@ create_dir(struct kobject * k, struct dentry * p, char * n)
}
struct
dentry
*
sysfs_create_subdir
(
struct
kobject
*
k
,
char
*
n
)
struct
dentry
*
sysfs_create_subdir
(
struct
kobject
*
k
,
c
onst
c
har
*
n
)
{
return
create_dir
(
k
,
k
->
dentry
,
n
);
}
...
...
@@ -155,7 +155,7 @@ void sysfs_remove_dir(struct kobject * kobj)
dput
(
dentry
);
}
void
sysfs_rename_dir
(
struct
kobject
*
kobj
,
char
*
new_name
)
void
sysfs_rename_dir
(
struct
kobject
*
kobj
,
c
onst
c
har
*
new_name
)
{
struct
dentry
*
new_dentry
,
*
parent
;
...
...
fs/sysfs/file.c
View file @
92807f31
...
...
@@ -345,7 +345,7 @@ static struct file_operations sysfs_file_operations = {
};
int
sysfs_add_file
(
struct
dentry
*
dir
,
struct
attribute
*
attr
)
int
sysfs_add_file
(
struct
dentry
*
dir
,
const
struct
attribute
*
attr
)
{
struct
dentry
*
dentry
;
int
error
;
...
...
@@ -368,7 +368,7 @@ int sysfs_add_file(struct dentry * dir, struct attribute * attr)
* @attr: atrribute descriptor.
*/
int
sysfs_create_file
(
struct
kobject
*
kobj
,
struct
attribute
*
attr
)
int
sysfs_create_file
(
struct
kobject
*
kobj
,
const
struct
attribute
*
attr
)
{
if
(
kobj
&&
attr
)
return
sysfs_add_file
(
kobj
->
dentry
,
attr
);
...
...
@@ -384,7 +384,7 @@ int sysfs_create_file(struct kobject * kobj, struct attribute * attr)
* Also call dnotify for the dentry, which lots of userspace programs
* use.
*/
int
sysfs_update_file
(
struct
kobject
*
kobj
,
struct
attribute
*
attr
)
int
sysfs_update_file
(
struct
kobject
*
kobj
,
const
struct
attribute
*
attr
)
{
struct
dentry
*
dir
=
kobj
->
dentry
;
struct
dentry
*
victim
;
...
...
@@ -425,7 +425,7 @@ int sysfs_update_file(struct kobject * kobj, struct attribute * attr)
* Hash the attribute name and kill the victim.
*/
void
sysfs_remove_file
(
struct
kobject
*
kobj
,
struct
attribute
*
attr
)
void
sysfs_remove_file
(
struct
kobject
*
kobj
,
const
struct
attribute
*
attr
)
{
sysfs_hash_and_remove
(
kobj
->
dentry
,
attr
->
name
);
}
...
...
fs/sysfs/group.c
View file @
92807f31
...
...
@@ -15,22 +15,23 @@
#include "sysfs.h"
static
void
remove_files
(
struct
dentry
*
dir
,
struct
attribute_group
*
grp
)
static
void
remove_files
(
struct
dentry
*
dir
,
const
struct
attribute_group
*
grp
)
{
struct
attribute
*
attr
;
struct
attribute
*
const
*
attr
;
for
(
attr
=
grp
->
attrs
;
attr
->
name
;
attr
++
)
sysfs_hash_and_remove
(
dir
,
attr
->
name
);
for
(
attr
=
grp
->
attrs
;
*
attr
;
attr
++
)
sysfs_hash_and_remove
(
dir
,
(
*
attr
)
->
name
);
}
static
int
create_files
(
struct
kobject
*
kobj
,
struct
dentry
*
dir
,
struct
attribute_group
*
grp
)
static
int
create_files
(
struct
dentry
*
dir
,
const
struct
attribute_group
*
grp
)
{
struct
attribute
*
attr
;
struct
attribute
*
const
*
attr
;
int
error
=
0
;
for
(
attr
=
grp
->
attrs
;
attr
->
name
&&
!
error
;
attr
++
)
{
error
=
sysfs_add_file
(
dir
,
attr
);
for
(
attr
=
grp
->
attrs
;
*
attr
&&
!
error
;
attr
++
)
{
error
=
sysfs_add_file
(
dir
,
*
attr
);
}
if
(
error
)
remove_files
(
dir
,
grp
);
...
...
@@ -38,7 +39,8 @@ static int create_files(struct kobject * kobj, struct dentry * dir,
}
int
sysfs_create_group
(
struct
kobject
*
kobj
,
struct
attribute_group
*
grp
)
int
sysfs_create_group
(
struct
kobject
*
kobj
,
const
struct
attribute_group
*
grp
)
{
struct
dentry
*
dir
;
int
error
;
...
...
@@ -50,7 +52,7 @@ int sysfs_create_group(struct kobject * kobj, struct attribute_group * grp)
}
else
dir
=
kobj
->
dentry
;
dir
=
dget
(
dir
);
if
((
error
=
create_files
(
kobj
,
dir
,
grp
)))
{
if
((
error
=
create_files
(
dir
,
grp
)))
{
if
(
grp
->
name
)
sysfs_remove_subdir
(
dir
);
dput
(
dir
);
...
...
@@ -58,7 +60,8 @@ int sysfs_create_group(struct kobject * kobj, struct attribute_group * grp)
return
error
;
}
void
sysfs_remove_group
(
struct
kobject
*
kobj
,
struct
attribute_group
*
grp
)
void
sysfs_remove_group
(
struct
kobject
*
kobj
,
const
struct
attribute_group
*
grp
)
{
struct
dentry
*
dir
;
...
...
fs/sysfs/sysfs.h
View file @
92807f31
...
...
@@ -4,10 +4,10 @@ extern struct vfsmount * sysfs_mount;
extern
struct
inode
*
sysfs_new_inode
(
mode_t
mode
);
extern
int
sysfs_create
(
struct
dentry
*
,
int
mode
,
int
(
*
init
)(
struct
inode
*
));
extern
struct
dentry
*
sysfs_get_dentry
(
struct
dentry
*
,
char
*
);
extern
struct
dentry
*
sysfs_get_dentry
(
struct
dentry
*
,
c
onst
c
har
*
);
extern
int
sysfs_add_file
(
struct
dentry
*
dir
,
struct
attribute
*
attr
);
extern
int
sysfs_add_file
(
struct
dentry
*
dir
,
const
struct
attribute
*
attr
);
extern
void
sysfs_hash_and_remove
(
struct
dentry
*
dir
,
const
char
*
name
);
extern
struct
dentry
*
sysfs_create_subdir
(
struct
kobject
*
,
char
*
);
extern
struct
dentry
*
sysfs_create_subdir
(
struct
kobject
*
,
c
onst
c
har
*
);
extern
void
sysfs_remove_subdir
(
struct
dentry
*
);
include/linux/device.h
View file @
92807f31
...
...
@@ -176,8 +176,8 @@ struct class_attribute class_attr_##_name = { \
.store = _store, \
};
extern
int
class_create_file
(
struct
class
*
,
struct
class_attribute
*
);
extern
void
class_remove_file
(
struct
class
*
,
struct
class_attribute
*
);
extern
int
class_create_file
(
struct
class
*
,
const
struct
class_attribute
*
);
extern
void
class_remove_file
(
struct
class
*
,
const
struct
class_attribute
*
);
struct
class_device
{
...
...
@@ -228,8 +228,10 @@ struct class_device_attribute class_device_attr_##_name = { \
.store = _store, \
};
extern
int
class_device_create_file
(
struct
class_device
*
,
struct
class_device_attribute
*
);
extern
void
class_device_remove_file
(
struct
class_device
*
,
struct
class_device_attribute
*
);
extern
int
class_device_create_file
(
struct
class_device
*
,
const
struct
class_device_attribute
*
);
extern
void
class_device_remove_file
(
struct
class_device
*
,
const
struct
class_device_attribute
*
);
struct
class_interface
{
...
...
include/linux/sysfs.h
View file @
92807f31
...
...
@@ -40,16 +40,16 @@ extern void
sysfs_remove_dir
(
struct
kobject
*
);
extern
void
sysfs_rename_dir
(
struct
kobject
*
,
char
*
new_name
);
sysfs_rename_dir
(
struct
kobject
*
,
c
onst
c
har
*
new_name
);
extern
int
sysfs_create_file
(
struct
kobject
*
,
struct
attribute
*
);
sysfs_create_file
(
struct
kobject
*
,
const
struct
attribute
*
);
extern
int
sysfs_update_file
(
struct
kobject
*
,
struct
attribute
*
);
sysfs_update_file
(
struct
kobject
*
,
const
struct
attribute
*
);
extern
void
sysfs_remove_file
(
struct
kobject
*
,
struct
attribute
*
);
sysfs_remove_file
(
struct
kobject
*
,
const
struct
attribute
*
);
extern
int
sysfs_create_link
(
struct
kobject
*
kobj
,
struct
kobject
*
target
,
char
*
name
);
...
...
@@ -60,10 +60,10 @@ sysfs_remove_link(struct kobject *, char * name);
struct
attribute_group
{
char
*
name
;
struct
attribute
*
attrs
;
struct
attribute
*
*
attrs
;
};
int
sysfs_create_group
(
struct
kobject
*
,
struct
attribute_group
*
);
void
sysfs_remove_group
(
struct
kobject
*
,
struct
attribute_group
*
);
int
sysfs_create_group
(
struct
kobject
*
,
const
struct
attribute_group
*
);
void
sysfs_remove_group
(
struct
kobject
*
,
const
struct
attribute_group
*
);
#endif
/* _SYSFS_H_ */
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