mirror of
https://github.com/sysprog21/lkmpg.git
synced 2024-11-22 09:52:45 +08:00
treewide: Replace kernel.h by printk.h
The kernel.h should be discouraged for use. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
parent
e62dff0df4
commit
b8bbcd8a07
|
@ -11,8 +11,8 @@
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
|
|
||||||
/* Macro DECLARE_TASKLET_OLD exists for compatibiity.
|
/* Macro DECLARE_TASKLET_OLD exists for compatibiity.
|
||||||
* See https://lwn.net/Articles/830964/
|
* See https://lwn.net/Articles/830964/
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
#include <linux/completion.h>
|
#include <linux/completion.h>
|
||||||
#include <linux/err.h> /* for IS_ERR() */
|
#include <linux/err.h> /* for IS_ERR() */
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/kthread.h>
|
#include <linux/kthread.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
struct completion crank_comp;
|
struct completion crank_comp;
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*/
|
*/
|
||||||
#include <linux/atomic.h>
|
#include <linux/atomic.h>
|
||||||
#include <linux/bitops.h>
|
#include <linux/bitops.h>
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
|
|
||||||
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
|
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
|
||||||
#define BYTE_TO_BINARY(byte) \
|
#define BYTE_TO_BINARY(byte) \
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* example_mutex.c
|
* example_mutex.c
|
||||||
*/
|
*/
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
|
|
||||||
static DEFINE_MUTEX(mymutex);
|
static DEFINE_MUTEX(mymutex);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* example_rwlock.c
|
* example_rwlock.c
|
||||||
*/
|
*/
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
#include <linux/rwlock.h>
|
#include <linux/rwlock.h>
|
||||||
|
|
||||||
static DEFINE_RWLOCK(myrwlock);
|
static DEFINE_RWLOCK(myrwlock);
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* example_spinlock.c
|
* example_spinlock.c
|
||||||
*/
|
*/
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
#include <linux/spinlock.h>
|
#include <linux/spinlock.h>
|
||||||
|
|
||||||
static DEFINE_SPINLOCK(sl_static);
|
static DEFINE_SPINLOCK(sl_static);
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*/
|
*/
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/kernel.h>
|
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
|
|
||||||
/* Macro DECLARE_TASKLET_OLD exists for compatibility.
|
/* Macro DECLARE_TASKLET_OLD exists for compatibility.
|
||||||
* See https://lwn.net/Articles/830964/
|
* See https://lwn.net/Articles/830964/
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* hello-1.c - The simplest kernel module.
|
* hello-1.c - The simplest kernel module.
|
||||||
*/
|
*/
|
||||||
#include <linux/kernel.h> /* Needed for pr_info() */
|
|
||||||
#include <linux/module.h> /* Needed by all modules */
|
#include <linux/module.h> /* Needed by all modules */
|
||||||
|
#include <linux/printk.h> /* Needed for pr_info() */
|
||||||
|
|
||||||
int init_module(void)
|
int init_module(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
* This is preferred over using init_module() and cleanup_module().
|
* This is preferred over using init_module() and cleanup_module().
|
||||||
*/
|
*/
|
||||||
#include <linux/init.h> /* Needed for the macros */
|
#include <linux/init.h> /* Needed for the macros */
|
||||||
#include <linux/kernel.h> /* Needed for pr_info() */
|
|
||||||
#include <linux/module.h> /* Needed by all modules */
|
#include <linux/module.h> /* Needed by all modules */
|
||||||
|
#include <linux/printk.h> /* Needed for pr_info() */
|
||||||
|
|
||||||
static int __init hello_2_init(void)
|
static int __init hello_2_init(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* hello-3.c - Illustrating the __init, __initdata and __exit macros.
|
* hello-3.c - Illustrating the __init, __initdata and __exit macros.
|
||||||
*/
|
*/
|
||||||
#include <linux/init.h> /* Needed for the macros */
|
#include <linux/init.h> /* Needed for the macros */
|
||||||
#include <linux/kernel.h> /* Needed for pr_info() */
|
|
||||||
#include <linux/module.h> /* Needed by all modules */
|
#include <linux/module.h> /* Needed by all modules */
|
||||||
|
#include <linux/printk.h> /* Needed for pr_info() */
|
||||||
|
|
||||||
static int hello3_data __initdata = 3;
|
static int hello3_data __initdata = 3;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* hello-4.c - Demonstrates module documentation.
|
* hello-4.c - Demonstrates module documentation.
|
||||||
*/
|
*/
|
||||||
#include <linux/init.h> /* Needed for the macros */
|
#include <linux/init.h> /* Needed for the macros */
|
||||||
#include <linux/kernel.h> /* Needed for pr_info() */
|
|
||||||
#include <linux/module.h> /* Needed by all modules */
|
#include <linux/module.h> /* Needed by all modules */
|
||||||
|
#include <linux/printk.h> /* Needed for pr_info() */
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
MODULE_AUTHOR("LKMPG");
|
MODULE_AUTHOR("LKMPG");
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
* hello-5.c - Demonstrates command line argument passing to a module.
|
* hello-5.c - Demonstrates command line argument passing to a module.
|
||||||
*/
|
*/
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h> /* for ARRAY_SIZE() */
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/moduleparam.h>
|
#include <linux/moduleparam.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
#include <linux/stat.h>
|
#include <linux/stat.h>
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
|
|
@ -10,8 +10,9 @@
|
||||||
|
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h> /* for ARRAY_SIZE() */
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/printk.h>
|
||||||
|
|
||||||
static int button_irqs[] = { -1, -1 };
|
static int button_irqs[] = { -1, -1 };
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
|
|
||||||
#include <linux/atomic.h>
|
#include <linux/atomic.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/kernel.h> /* We're doing kernel work */
|
#include <linux/kernel.h> /* for sprintf() */
|
||||||
#include <linux/module.h> /* Specifically, a module */
|
#include <linux/module.h> /* Specifically, a module */
|
||||||
|
#include <linux/printk.h>
|
||||||
#include <linux/proc_fs.h> /* Necessary because we use proc fs */
|
#include <linux/proc_fs.h> /* Necessary because we use proc fs */
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/uaccess.h> /* for get_user and put_user */
|
#include <linux/uaccess.h> /* for get_user and put_user */
|
||||||
|
|
|
@ -401,7 +401,7 @@ The \cpp|cleanup_module()| function is supposed to undo whatever \cpp|init_modul
|
||||||
|
|
||||||
Lastly, every kernel module needs to include \verb|<linux/module.h>|.
|
Lastly, every kernel module needs to include \verb|<linux/module.h>|.
|
||||||
% TODO: adjust the section anchor
|
% TODO: adjust the section anchor
|
||||||
We needed to include \verb|<linux/kernel.h>| only for the macro expansion for the \cpp|pr_alert()| log level, which you'll learn about in Section \ref{sec:printk}.
|
We needed to include \verb|<linux/printk.h>| only for the macro expansion for the \cpp|pr_alert()| log level, which you'll learn about in Section \ref{sec:printk}.
|
||||||
|
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item A point about coding style.
|
\item A point about coding style.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user