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
d4b86e56
Commit
d4b86e56
authored
Apr 04, 2002
by
Patrick Mochel
Committed by
Patrick Mochel
Apr 04, 2002
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add platform driver object
parent
c26faf67
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
2 deletions
+118
-2
include/linux/platform.h
include/linux/platform.h
+43
-0
kernel/Makefile
kernel/Makefile
+2
-2
kernel/platform.c
kernel/platform.c
+73
-0
No files found.
include/linux/platform.h
0 → 100644
View file @
d4b86e56
/*
* include/linux/platform.h - platform driver definitions
*
* Because of the prolific consumerism of the average American,
* and the dominant marketing budgets of PC OEMs, we have been
* blessed with frequent updates of the PC architecture.
*
* While most of these calls are singular per architecture, they
* require an extra layer of abstraction on the x86 so the right
* subsystem gets the right call.
*
* Basically, this consolidates the power off and reboot callbacks
* into one structure, as well as adding power management hooks.
*
* When adding a platform driver, please make sure all callbacks are
* filled. There are defaults defined below that do nothing; use those
* if you do not support that callback.
*/
#ifndef _PLATFORM_H_
#define _PLATFORM_H_
#ifdef __KERNEL__
#include <linux/types.h>
struct
platform_t
{
char
*
name
;
u32
suspend_states
;
void
(
*
reboot
)(
char
*
cmd
);
void
(
*
halt
)(
void
);
void
(
*
power_off
)(
void
);
int
(
*
suspend
)(
int
state
,
int
flags
);
void
(
*
idle
)(
void
);
};
extern
struct
platform_t
*
platform
;
extern
void
default_reboot
(
char
*
cmd
);
extern
void
default_halt
(
void
);
extern
int
default_suspend
(
int
state
,
int
flags
);
extern
void
default_idle
(
void
);
#endif
/* __KERNEL__ */
#endif
/* _PLATFORM_H */
kernel/Makefile
View file @
d4b86e56
...
@@ -10,12 +10,12 @@
...
@@ -10,12 +10,12 @@
O_TARGET
:=
kernel.o
O_TARGET
:=
kernel.o
export-objs
=
signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o
\
export-objs
=
signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o
\
printk.o
printk.o
platform.o
obj-y
=
sched.o dma.o fork.o exec_domain.o panic.o printk.o
\
obj-y
=
sched.o dma.o fork.o exec_domain.o panic.o printk.o
\
module.o exit.o itimer.o info.o time.o softirq.o resource.o
\
module.o exit.o itimer.o info.o time.o softirq.o resource.o
\
sysctl.o capability.o ptrace.o timer.o user.o
\
sysctl.o capability.o ptrace.o timer.o user.o
\
signal.o sys.o kmod.o context.o futex.o
signal.o sys.o kmod.o context.o futex.o
platform.o
obj-$(CONFIG_UID16)
+=
uid16.o
obj-$(CONFIG_UID16)
+=
uid16.o
obj-$(CONFIG_MODULES)
+=
ksyms.o
obj-$(CONFIG_MODULES)
+=
ksyms.o
...
...
kernel/platform.c
0 → 100644
View file @
d4b86e56
/*
* platform driver support
*/
#include <linux/platform.h>
#include <linux/module.h>
#include <linux/errno.h>
static
struct
platform_t
default_platform
;
struct
platform_t
*
platform
=
&
default_platform
;
static
spinlock_t
platform_lock
=
SPIN_LOCK_UNLOCKED
;
void
default_reboot
(
char
*
cmd
)
{
/* nothing */
}
void
default_halt
(
void
)
{
/* nothing */
}
int
default_suspend
(
int
state
,
int
flags
)
{
return
-
ENOSYS
;
}
static
struct
platform_t
default_platform
=
{
name:
"Default Platform"
,
suspend_states:
0
,
reboot:
default_reboot
,
halt:
default_halt
,
power_off:
default_halt
,
suspend:
default_suspend
,
idle:
default_idle
,
};
/**
* set_platform_driver - set the platform driver.
* @pf: driver to set it to
*
* Return -EEXIST if someone else already owns it.
*/
int
set_platform_driver
(
struct
platform_t
*
pf
)
{
if
(
!
pf
)
return
-
EINVAL
;
spin_lock
(
&
platform_lock
);
if
(
platform
!=
&
default_platform
)
{
spin_unlock
(
&
platform_lock
);
return
-
EEXIST
;
}
platform
=
pf
;
spin_unlock
(
&
platform_lock
);
return
0
;
}
void
remove_platform_driver
(
struct
platform_t
*
pf
)
{
spin_lock
(
&
platform_lock
);
if
(
platform
==
pf
)
platform
=
&
default_platform
;
spin_unlock
(
&
platform_lock
);
}
EXPORT_SYMBOL
(
default_reboot
);
EXPORT_SYMBOL
(
default_halt
);
EXPORT_SYMBOL
(
default_suspend
);
EXPORT_SYMBOL
(
platform
);
EXPORT_SYMBOL
(
set_platform_driver
);
EXPORT_SYMBOL
(
remove_platform_driver
);
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