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
8f1640cb
Commit
8f1640cb
authored
May 27, 2002
by
Patrick Mochel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deivce model: actually compile and use bus drivers
parent
cfff1d8f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
15 deletions
+29
-15
drivers/base/Makefile
drivers/base/Makefile
+2
-2
drivers/base/base.h
drivers/base/base.h
+4
-0
drivers/base/bus.c
drivers/base/bus.c
+2
-6
drivers/base/core.c
drivers/base/core.c
+4
-0
drivers/base/fs.c
drivers/base/fs.c
+11
-7
include/linux/device.h
include/linux/device.h
+6
-0
No files found.
drivers/base/Makefile
View file @
8f1640cb
O_TARGET
:=
base.o
obj-y
:=
core.o sys.o interface.o fs.o power.o
obj-y
:=
core.o sys.o interface.o fs.o power.o
bus.o
export-objs
:=
core.o fs.o power.o sys.o
export-objs
:=
core.o fs.o power.o sys.o
bus.o
include
$(TOPDIR)/Rules.make
drivers/base/base.h
View file @
8f1640cb
...
...
@@ -9,6 +9,10 @@
extern
struct
device
device_root
;
extern
spinlock_t
device_lock
;
extern
int
bus_add_device
(
struct
device
*
dev
);
extern
void
bus_remove_device
(
struct
device
*
dev
);
extern
int
device_create_dir
(
struct
driver_dir_entry
*
dir
,
struct
driver_dir_entry
*
parent
);
extern
int
device_make_dir
(
struct
device
*
dev
);
extern
void
device_remove_dir
(
struct
device
*
dev
);
drivers/base/bus.c
View file @
8f1640cb
...
...
@@ -10,7 +10,8 @@
#include <linux/device.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/stat.h>
#include "base.h"
static
LIST_HEAD
(
bus_driver_list
);
...
...
@@ -103,10 +104,6 @@ void put_bus(struct bus_type * bus)
driverfs_remove_dir
(
&
bus
->
driver_dir
);
driverfs_remove_dir
(
&
bus
->
device_dir
);
driverfs_remove_dir
(
&
bus
->
dir
);
/* tell the driver it can go away now */
if
(
bus
->
release
)
bus
->
release
();
}
static
int
__init
bus_init
(
void
)
...
...
@@ -117,7 +114,6 @@ static int __init bus_init(void)
subsys_initcall
(
bus_init
);
EXPORT_SYMBOL
(
bus_for_each_dev
);
EXPORT_SYMBOL
(
bus_add_device
);
EXPORT_SYMBOL
(
bus_remove_device
);
EXPORT_SYMBOL
(
bus_register
);
...
...
drivers/base/core.c
View file @
8f1640cb
...
...
@@ -70,6 +70,8 @@ int device_register(struct device *dev)
if
((
error
=
device_make_dir
(
dev
)))
goto
register_done
;
bus_add_device
(
dev
);
/* notify platform of device entry */
if
(
platform_notify
)
platform_notify
(
dev
);
...
...
@@ -102,6 +104,8 @@ void put_device(struct device * dev)
if
(
platform_notify_remove
)
platform_notify_remove
(
dev
);
bus_remove_device
(
dev
);
/* Tell the driver to clean up after itself.
* Note that we likely didn't allocate the device,
* so this is the driver's chance to free that up...
...
...
drivers/base/fs.c
View file @
8f1640cb
...
...
@@ -68,6 +68,13 @@ void device_remove_dir(struct device * dev)
driverfs_remove_dir
(
&
dev
->
dir
);
}
int
device_create_dir
(
struct
driver_dir_entry
*
dir
,
struct
driver_dir_entry
*
parent
)
{
INIT_LIST_HEAD
(
&
dir
->
files
);
dir
->
mode
=
(
S_IFDIR
|
S_IRWXU
|
S_IRUGO
|
S_IXUGO
);
return
driverfs_create_dir
(
dir
,
parent
);
}
/**
* device_make_dir - create a driverfs directory
* @name: name of directory
...
...
@@ -87,23 +94,20 @@ int device_make_dir(struct device * dev)
int
error
;
int
i
;
INIT_LIST_HEAD
(
&
dev
->
dir
.
files
);
dev
->
dir
.
mode
=
(
S_IFDIR
|
S_IRWXU
|
S_IRUGO
|
S_IXUGO
);
dev
->
dir
.
name
=
dev
->
bus_id
;
if
(
dev
->
parent
)
parent
=
&
dev
->
parent
->
dir
;
dev
->
dir
.
name
=
dev
->
bus_id
;
if
((
error
=
d
riverfs
_create_dir
(
&
dev
->
dir
,
parent
)))
if
((
error
=
d
evice
_create_dir
(
&
dev
->
dir
,
parent
)))
return
error
;
for
(
i
=
0
;
(
entry
=
*
(
device_default_files
+
i
));
i
++
)
{
if
((
error
=
device_create_file
(
dev
,
entry
)))
{
device_remove_dir
(
dev
);
return
error
;
break
;
}
}
return
0
;
return
error
;
}
EXPORT_SYMBOL
(
device_create_file
);
...
...
include/linux/device.h
View file @
8f1640cb
...
...
@@ -63,6 +63,11 @@ struct bus_type {
list_t
node
;
list_t
devices
;
list_t
drivers
;
struct
driver_dir_entry
dir
;
struct
driver_dir_entry
device_dir
;
struct
driver_dir_entry
driver_dir
;
};
...
...
@@ -102,6 +107,7 @@ struct device {
atomic_t
refcount
;
/* refcount to make sure the device
* persists for the right amount of time */
struct
bus_type
*
bus
;
/* type of bus device is on */
struct
driver_dir_entry
dir
;
struct
device_driver
*
driver
;
/* which driver has allocated this
...
...
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