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
99af1a94
Commit
99af1a94
authored
Oct 30, 2002
by
Patrick Mochel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
driver model: convert interfaces to use kobject and sysfs.
parent
9cd52d59
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
35 deletions
+28
-35
drivers/base/fs/intf.c
drivers/base/fs/intf.c
+0
-35
drivers/base/intf.c
drivers/base/intf.c
+27
-0
include/linux/device.h
include/linux/device.h
+1
-0
No files found.
drivers/base/fs/intf.c
View file @
99af1a94
...
@@ -6,41 +6,6 @@
...
@@ -6,41 +6,6 @@
#include <linux/slab.h>
#include <linux/slab.h>
#include "fs.h"
#include "fs.h"
/**
* intf_dev_link - symlink from interface's directory to device's directory
*
*/
int
intf_dev_link
(
struct
intf_data
*
data
)
{
char
linkname
[
16
];
char
*
path
;
int
length
;
int
error
;
length
=
get_devpath_length
(
data
->
dev
);
length
+=
strlen
(
"../../../root"
);
if
(
length
>
PATH_MAX
)
return
-
ENAMETOOLONG
;
if
(
!
(
path
=
kmalloc
(
length
,
GFP_KERNEL
)))
return
-
ENOMEM
;
memset
(
path
,
0
,
length
);
strcpy
(
path
,
"../../../root"
);
fill_devpath
(
data
->
dev
,
path
,
length
);
snprintf
(
linkname
,
16
,
"%u"
,
data
->
intf_num
);
error
=
driverfs_create_symlink
(
&
data
->
intf
->
dir
,
linkname
,
path
);
kfree
(
path
);
return
error
;
}
void
intf_dev_unlink
(
struct
intf_data
*
data
)
{
char
linkname
[
16
];
snprintf
(
linkname
,
16
,
"%u"
,
data
->
intf_num
);
driverfs_remove_file
(
&
data
->
intf
->
dir
,
linkname
);
}
void
intf_remove_dir
(
struct
device_interface
*
intf
)
void
intf_remove_dir
(
struct
device_interface
*
intf
)
{
{
...
...
drivers/base/intf.c
View file @
99af1a94
...
@@ -11,6 +11,26 @@
...
@@ -11,6 +11,26 @@
#define to_intf(node) container_of(node,struct device_interface,node)
#define to_intf(node) container_of(node,struct device_interface,node)
/**
* intf_dev_link - symlink from interface's directory to device's directory
*
*/
int
intf_dev_link
(
struct
intf_data
*
data
)
{
char
linkname
[
16
];
snprintf
(
linkname
,
16
,
"%u"
,
data
->
intf_num
);
return
sysfs_create_link
(
&
data
->
intf
->
kobj
,
&
data
->
dev
->
kobj
,
linkname
);
}
void
intf_dev_unlink
(
struct
intf_data
*
data
)
{
char
linkname
[
16
];
snprintf
(
linkname
,
16
,
"%u"
,
data
->
intf_num
);
sysfs_remove_link
(
&
data
->
intf
->
kobj
,
linkname
);
}
int
interface_register
(
struct
device_interface
*
intf
)
int
interface_register
(
struct
device_interface
*
intf
)
{
{
struct
device_class
*
cls
=
intf
->
devclass
;
struct
device_class
*
cls
=
intf
->
devclass
;
...
@@ -19,6 +39,12 @@ int interface_register(struct device_interface * intf)
...
@@ -19,6 +39,12 @@ int interface_register(struct device_interface * intf)
pr_debug
(
"register interface '%s' with class '%s
\n
"
,
pr_debug
(
"register interface '%s' with class '%s
\n
"
,
intf
->
name
,
cls
->
name
);
intf
->
name
,
cls
->
name
);
intf_make_dir
(
intf
);
intf_make_dir
(
intf
);
kobject_init
(
&
intf
->
kobj
);
strncpy
(
intf
->
kobj
.
name
,
intf
->
name
,
KOBJ_NAME_LEN
);
intf
->
kobj
.
subsys
=
&
cls
->
subsys
;
kobject_register
(
&
intf
->
kobj
);
spin_lock
(
&
device_lock
);
spin_lock
(
&
device_lock
);
list_add_tail
(
&
intf
->
node
,
&
cls
->
intf_list
);
list_add_tail
(
&
intf
->
node
,
&
cls
->
intf_list
);
spin_unlock
(
&
device_lock
);
spin_unlock
(
&
device_lock
);
...
@@ -31,6 +57,7 @@ void interface_unregister(struct device_interface * intf)
...
@@ -31,6 +57,7 @@ void interface_unregister(struct device_interface * intf)
{
{
pr_debug
(
"unregistering interface '%s' from class '%s'
\n
"
,
pr_debug
(
"unregistering interface '%s' from class '%s'
\n
"
,
intf
->
name
,
intf
->
devclass
->
name
);
intf
->
name
,
intf
->
devclass
->
name
);
kobject_unregister
(
&
intf
->
kobj
);
spin_lock
(
&
device_lock
);
spin_lock
(
&
device_lock
);
list_del_init
(
&
intf
->
node
);
list_del_init
(
&
intf
->
node
);
spin_unlock
(
&
device_lock
);
spin_unlock
(
&
device_lock
);
...
...
include/linux/device.h
View file @
99af1a94
...
@@ -240,6 +240,7 @@ struct device_interface {
...
@@ -240,6 +240,7 @@ struct device_interface {
char
*
name
;
char
*
name
;
struct
device_class
*
devclass
;
struct
device_class
*
devclass
;
struct
kobject
kobj
;
struct
list_head
node
;
struct
list_head
node
;
struct
list_head
devices
;
struct
list_head
devices
;
struct
driver_dir_entry
dir
;
struct
driver_dir_entry
dir
;
...
...
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