mirror of
https://github.com/bashrc/LKMPG.git
synced 2018-06-11 03:06:54 +02:00
Move to abbreviated printk macros #6
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -33,10 +33,10 @@ static struct gpio buttons[] = {
|
||||
/* Tasklet containing some non-trivial amount of processing */
|
||||
static void bottomhalf_tasklet_fn(unsigned long data)
|
||||
{
|
||||
printk("Bottom half tasklet starts\n");
|
||||
pr_info("Bottom half tasklet starts\n");
|
||||
/* do something which takes a while */
|
||||
mdelay(500);
|
||||
printk("Bottom half tasklet ends\n");
|
||||
pr_info("Bottom half tasklet ends\n");
|
||||
}
|
||||
|
||||
DECLARE_TASKLET(buttontask, bottomhalf_tasklet_fn, 0L);
|
||||
@@ -62,13 +62,13 @@ int init_module()
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
printk(KERN_INFO "%s\n", __func__);
|
||||
pr_info("%s\n", __func__);
|
||||
|
||||
/* register LED gpios */
|
||||
ret = gpio_request_array(leds, ARRAY_SIZE(leds));
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request GPIOs for LEDs: %d\n", ret);
|
||||
pr_err("Unable to request GPIOs for LEDs: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -76,23 +76,23 @@ int init_module()
|
||||
ret = gpio_request_array(buttons, ARRAY_SIZE(buttons));
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request GPIOs for BUTTONs: %d\n", ret);
|
||||
pr_err("Unable to request GPIOs for BUTTONs: %d\n", ret);
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "Current button1 value: %d\n",
|
||||
pr_info("Current button1 value: %d\n",
|
||||
gpio_get_value(buttons[0].gpio));
|
||||
|
||||
ret = gpio_to_irq(buttons[0].gpio);
|
||||
|
||||
if (ret < 0) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
button_irqs[0] = ret;
|
||||
|
||||
printk(KERN_INFO "Successfully requested BUTTON1 IRQ # %d\n",
|
||||
pr_info("Successfully requested BUTTON1 IRQ # %d\n",
|
||||
button_irqs[0]);
|
||||
|
||||
ret = request_irq(button_irqs[0], button_isr,
|
||||
@@ -100,7 +100,7 @@ int init_module()
|
||||
"gpiomod#button1", NULL);
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
@@ -108,13 +108,13 @@ int init_module()
|
||||
ret = gpio_to_irq(buttons[1].gpio);
|
||||
|
||||
if (ret < 0) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
button_irqs[1] = ret;
|
||||
|
||||
printk(KERN_INFO "Successfully requested BUTTON2 IRQ # %d\n",
|
||||
pr_info("Successfully requested BUTTON2 IRQ # %d\n",
|
||||
button_irqs[1]);
|
||||
|
||||
ret = request_irq(button_irqs[1], button_isr,
|
||||
@@ -122,7 +122,7 @@ int init_module()
|
||||
"gpiomod#button2", NULL);
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void cleanup_module()
|
||||
{
|
||||
int i;
|
||||
|
||||
printk(KERN_INFO "%s\n", __func__);
|
||||
pr_info("%s\n", __func__);
|
||||
|
||||
/* free irqs */
|
||||
free_irq(button_irqs[0], NULL);
|
||||
|
||||
@@ -33,10 +33,10 @@ static char msg[BUF_LEN]; /* The msg the device will give when asked */
|
||||
static char *msg_Ptr;
|
||||
|
||||
static struct file_operations fops = {
|
||||
.read = device_read,
|
||||
.write = device_write,
|
||||
.open = device_open,
|
||||
.release = device_release
|
||||
.read = device_read,
|
||||
.write = device_write,
|
||||
.open = device_open,
|
||||
.release = device_release
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -44,21 +44,21 @@ static struct file_operations fops = {
|
||||
*/
|
||||
int init_module(void)
|
||||
{
|
||||
Major = register_chrdev(0, DEVICE_NAME, &fops);
|
||||
Major = register_chrdev(0, DEVICE_NAME, &fops);
|
||||
|
||||
if (Major < 0) {
|
||||
printk(KERN_ALERT "Registering char device failed with %d\n", Major);
|
||||
return Major;
|
||||
}
|
||||
if (Major < 0) {
|
||||
pr_alert("Registering char device failed with %d\n", Major);
|
||||
return Major;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "I was assigned major number %d. To talk to\n", Major);
|
||||
printk(KERN_INFO "the driver, create a dev file with\n");
|
||||
printk(KERN_INFO "'mknod /dev/%s c %d 0'.\n", DEVICE_NAME, Major);
|
||||
printk(KERN_INFO "Try various minor numbers. Try to cat and echo to\n");
|
||||
printk(KERN_INFO "the device file.\n");
|
||||
printk(KERN_INFO "Remove the device file and module when done.\n");
|
||||
pr_info("I was assigned major number %d. To talk to\n", Major);
|
||||
pr_info("the driver, create a dev file with\n");
|
||||
pr_info("'mknod /dev/%s c %d 0'.\n", DEVICE_NAME, Major);
|
||||
pr_info("Try various minor numbers. Try to cat and echo to\n");
|
||||
pr_info("the device file.\n");
|
||||
pr_info("Remove the device file and module when done.\n");
|
||||
|
||||
return SUCCESS;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -66,10 +66,10 @@ int init_module(void)
|
||||
*/
|
||||
void cleanup_module(void)
|
||||
{
|
||||
/*
|
||||
* Unregister the device
|
||||
*/
|
||||
unregister_chrdev(Major, DEVICE_NAME);
|
||||
/*
|
||||
* Unregister the device
|
||||
*/
|
||||
unregister_chrdev(Major, DEVICE_NAME);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -82,17 +82,17 @@ void cleanup_module(void)
|
||||
*/
|
||||
static int device_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
static int counter = 0;
|
||||
static int counter = 0;
|
||||
|
||||
if (Device_Open)
|
||||
return -EBUSY;
|
||||
if (Device_Open)
|
||||
return -EBUSY;
|
||||
|
||||
Device_Open++;
|
||||
sprintf(msg, "I already told you %d times Hello world!\n", counter++);
|
||||
msg_Ptr = msg;
|
||||
try_module_get(THIS_MODULE);
|
||||
Device_Open++;
|
||||
sprintf(msg, "I already told you %d times Hello world!\n", counter++);
|
||||
msg_Ptr = msg;
|
||||
try_module_get(THIS_MODULE);
|
||||
|
||||
return SUCCESS;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -100,15 +100,15 @@ static int device_open(struct inode *inode, struct file *file)
|
||||
*/
|
||||
static int device_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
Device_Open--; /* We're now ready for our next caller */
|
||||
Device_Open--; /* We're now ready for our next caller */
|
||||
|
||||
/*
|
||||
* Decrement the usage count, or else once you opened the file, you'll
|
||||
* never get get rid of the module.
|
||||
*/
|
||||
module_put(THIS_MODULE);
|
||||
/*
|
||||
* Decrement the usage count, or else once you opened the file, you'll
|
||||
* never get get rid of the module.
|
||||
*/
|
||||
module_put(THIS_MODULE);
|
||||
|
||||
return SUCCESS;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -120,49 +120,49 @@ static ssize_t device_read(struct file *filp, /* see include/linux/fs.h */
|
||||
size_t length, /* length of the buffer */
|
||||
loff_t * offset)
|
||||
{
|
||||
/*
|
||||
* Number of bytes actually written to the buffer
|
||||
*/
|
||||
int bytes_read = 0;
|
||||
/*
|
||||
* Number of bytes actually written to the buffer
|
||||
*/
|
||||
int bytes_read = 0;
|
||||
|
||||
/*
|
||||
* If we're at the end of the message,
|
||||
* return 0 signifying end of file
|
||||
*/
|
||||
if (*msg_Ptr == 0)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Actually put the data into the buffer
|
||||
*/
|
||||
while (length && *msg_Ptr) {
|
||||
|
||||
/*
|
||||
* If we're at the end of the message,
|
||||
* return 0 signifying end of file
|
||||
* The buffer is in the user data segment, not the kernel
|
||||
* segment so "*" assignment won't work. We have to use
|
||||
* put_user which copies data from the kernel data segment to
|
||||
* the user data segment.
|
||||
*/
|
||||
if (*msg_Ptr == 0)
|
||||
return 0;
|
||||
put_user(*(msg_Ptr++), buffer++);
|
||||
|
||||
/*
|
||||
* Actually put the data into the buffer
|
||||
*/
|
||||
while (length && *msg_Ptr) {
|
||||
length--;
|
||||
bytes_read++;
|
||||
}
|
||||
|
||||
/*
|
||||
* The buffer is in the user data segment, not the kernel
|
||||
* segment so "*" assignment won't work. We have to use
|
||||
* put_user which copies data from the kernel data segment to
|
||||
* the user data segment.
|
||||
*/
|
||||
put_user(*(msg_Ptr++), buffer++);
|
||||
|
||||
length--;
|
||||
bytes_read++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Most read functions return the number of bytes put into the buffer
|
||||
*/
|
||||
return bytes_read;
|
||||
/*
|
||||
* Most read functions return the number of bytes put into the buffer
|
||||
*/
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when a process writes to dev file: echo "hi" > /dev/hello
|
||||
*/
|
||||
static ssize_t device_write(struct file *filp,
|
||||
const char *buff,
|
||||
size_t len,
|
||||
loff_t * off)
|
||||
const char *buff,
|
||||
size_t len,
|
||||
loff_t * off)
|
||||
{
|
||||
printk(KERN_ALERT "Sorry, this operation isn't supported.\n");
|
||||
return -EINVAL;
|
||||
pr_alert("Sorry, this operation isn't supported.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ static char *Message_Ptr;
|
||||
static int device_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printk(KERN_INFO "device_open(%p)\n", file);
|
||||
pr_info("device_open(%p)\n", file);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -57,7 +57,7 @@ static int device_open(struct inode *inode, struct file *file)
|
||||
static int device_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printk(KERN_INFO "device_release(%p,%p)\n", inode, file);
|
||||
pr_info("device_release(%p,%p)\n", inode, file);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -85,7 +85,7 @@ static ssize_t device_read(struct file *file, /* see include/linux/fs.h */
|
||||
int bytes_read = 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
printk(KERN_INFO "device_read(%p,%p,%d)\n", file, buffer, length);
|
||||
pr_info("device_read(%p,%p,%d)\n", file, buffer, length);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -113,7 +113,7 @@ static ssize_t device_read(struct file *file, /* see include/linux/fs.h */
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printk(KERN_INFO "Read %d bytes, %d left\n", bytes_read, length);
|
||||
pr_info("Read %d bytes, %d left\n", bytes_read, length);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -134,7 +134,7 @@ device_write(struct file *file,
|
||||
int i;
|
||||
|
||||
#ifdef DEBUG
|
||||
printk(KERN_INFO "device_write(%p,%s,%d)", file, buffer, length);
|
||||
pr_info("device_write(%p,%s,%d)", file, buffer, length);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < length && i < BUF_LEN; i++)
|
||||
@@ -246,20 +246,20 @@ int init_module()
|
||||
* Negative values signify an error
|
||||
*/
|
||||
if (ret_val < 0) {
|
||||
printk(KERN_ALERT "%s failed with %d\n",
|
||||
"Sorry, registering the character device ", ret_val);
|
||||
pr_alert("%s failed with %d\n",
|
||||
"Sorry, registering the character device ", ret_val);
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "%s The major device number is %d.\n",
|
||||
pr_info("%s The major device number is %d.\n",
|
||||
"Registeration is a success", MAJOR_NUM);
|
||||
printk(KERN_INFO "If you want to talk to the device driver,\n");
|
||||
printk(KERN_INFO "you'll have to create a device file. \n");
|
||||
printk(KERN_INFO "We suggest you use:\n");
|
||||
printk(KERN_INFO "mknod %s c %d 0\n", DEVICE_FILE_NAME, MAJOR_NUM);
|
||||
printk(KERN_INFO "The device file name is important, because\n");
|
||||
printk(KERN_INFO "the ioctl program assumes that's the\n");
|
||||
printk(KERN_INFO "file you'll use.\n");
|
||||
pr_info("If you want to talk to the device driver,\n");
|
||||
pr_info("you'll have to create a device file. \n");
|
||||
pr_info("We suggest you use:\n");
|
||||
pr_info("mknod %s c %d 0\n", DEVICE_FILE_NAME, MAJOR_NUM);
|
||||
pr_info("The device file name is important, because\n");
|
||||
pr_info("the ioctl program assumes that's the\n");
|
||||
pr_info("file you'll use.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ static struct {
|
||||
|
||||
static int machine_crank_thread(void* arg)
|
||||
{
|
||||
printk("Turn the crank\n");
|
||||
pr_info("Turn the crank\n");
|
||||
|
||||
complete_all(&machine.crank_comp);
|
||||
complete_and_exit(&machine.crank_comp, 0);
|
||||
@@ -21,7 +21,7 @@ static int machine_flywheel_spinup_thread(void* arg)
|
||||
{
|
||||
wait_for_completion(&machine.crank_comp);
|
||||
|
||||
printk("Flywheel spins up\n");
|
||||
pr_info("Flywheel spins up\n");
|
||||
|
||||
complete_all(&machine.flywheel_comp);
|
||||
complete_and_exit(&machine.flywheel_comp, 0);
|
||||
@@ -32,7 +32,7 @@ static int completions_init(void)
|
||||
struct task_struct* crank_thread;
|
||||
struct task_struct* flywheel_thread;
|
||||
|
||||
printk("completions example\n");
|
||||
pr_info("completions example\n");
|
||||
|
||||
init_completion(&machine.crank_comp);
|
||||
init_completion(&machine.flywheel_comp);
|
||||
@@ -66,7 +66,7 @@ void completions_exit(void)
|
||||
wait_for_completion(&machine.crank_comp);
|
||||
wait_for_completion(&machine.flywheel_comp);
|
||||
|
||||
printk("completions exit\n");
|
||||
pr_info("completions exit\n");
|
||||
}
|
||||
|
||||
module_init(completions_init);
|
||||
|
||||
@@ -50,7 +50,7 @@ static int test_skcipher_result(struct skcipher_def * sk, int rc)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printk("skcipher encrypt returned with %d result %d\n",
|
||||
pr_info("skcipher encrypt returned with %d result %d\n",
|
||||
rc, sk->result.err);
|
||||
break;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ static void test_skcipher_callback(struct crypto_async_request *req, int error)
|
||||
|
||||
result->err = error;
|
||||
complete(&result->completion);
|
||||
printk("Encryption finished successfully\n");
|
||||
pr_info("Encryption finished successfully\n");
|
||||
|
||||
/* decrypt data */
|
||||
/*
|
||||
@@ -83,8 +83,8 @@ static void test_skcipher_callback(struct crypto_async_request *req, int error)
|
||||
sg_copy_from_buffer(&sk.sg, 1, sk.scratchpad, CIPHER_BLOCK_SIZE);
|
||||
sk.scratchpad[CIPHER_BLOCK_SIZE-1] = 0;
|
||||
|
||||
printk("Decryption request successful\n");
|
||||
printk("Decrypted: %s\n", sk.scratchpad);
|
||||
pr_info("Decryption request successful\n");
|
||||
pr_info("Decrypted: %s\n", sk.scratchpad);
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ static int test_skcipher_encrypt(char * plaintext, char * password,
|
||||
if (!sk->tfm) {
|
||||
sk->tfm = crypto_alloc_skcipher("cbc-aes-aesni", 0, 0);
|
||||
if (IS_ERR(sk->tfm)) {
|
||||
printk("could not allocate skcipher handle\n");
|
||||
pr_info("could not allocate skcipher handle\n");
|
||||
return PTR_ERR(sk->tfm);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ static int test_skcipher_encrypt(char * plaintext, char * password,
|
||||
if (!sk->req) {
|
||||
sk->req = skcipher_request_alloc(sk->tfm, GFP_KERNEL);
|
||||
if (!sk->req) {
|
||||
printk("could not allocate skcipher request\n");
|
||||
pr_info("could not allocate skcipher request\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
@@ -123,18 +123,18 @@ static int test_skcipher_encrypt(char * plaintext, char * password,
|
||||
|
||||
/* AES 256 with given symmetric key */
|
||||
if (crypto_skcipher_setkey(sk->tfm, key, SYMMETRIC_KEY_LENGTH)) {
|
||||
printk("key could not be set\n");
|
||||
pr_info("key could not be set\n");
|
||||
ret = -EAGAIN;
|
||||
goto out;
|
||||
}
|
||||
printk("Symmetric key: %s\n", key);
|
||||
printk("Plaintext: %s\n", plaintext);
|
||||
pr_info("Symmetric key: %s\n", key);
|
||||
pr_info("Plaintext: %s\n", plaintext);
|
||||
|
||||
if (!sk->ivdata) {
|
||||
/* see https://en.wikipedia.org/wiki/Initialization_vector */
|
||||
sk->ivdata = kmalloc(CIPHER_BLOCK_SIZE, GFP_KERNEL);
|
||||
if (!sk->ivdata) {
|
||||
printk("could not allocate ivdata\n");
|
||||
pr_info("could not allocate ivdata\n");
|
||||
goto out;
|
||||
}
|
||||
get_random_bytes(sk->ivdata, CIPHER_BLOCK_SIZE);
|
||||
@@ -144,7 +144,7 @@ static int test_skcipher_encrypt(char * plaintext, char * password,
|
||||
/* The text to be encrypted */
|
||||
sk->scratchpad = kmalloc(CIPHER_BLOCK_SIZE, GFP_KERNEL);
|
||||
if (!sk->scratchpad) {
|
||||
printk("could not allocate scratchpad\n");
|
||||
pr_info("could not allocate scratchpad\n");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ static int test_skcipher_encrypt(char * plaintext, char * password,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
printk("Encryption request successful\n");
|
||||
pr_info("Encryption request successful\n");
|
||||
|
||||
out:
|
||||
return ret;
|
||||
|
||||
@@ -8,11 +8,11 @@ static void show_hash_result(char * plaintext, char * hash_sha256)
|
||||
int i;
|
||||
char str[SHA256_LENGTH*2 + 1];
|
||||
|
||||
printk("sha256 test for string: \"%s\"\n", plaintext);
|
||||
pr_info("sha256 test for string: \"%s\"\n", plaintext);
|
||||
for (i = 0; i < SHA256_LENGTH ; i++)
|
||||
sprintf(&str[i*2],"%02x", (unsigned char)hash_sha256[i]);
|
||||
str[i*2] = 0;
|
||||
printk("%s\n", str);
|
||||
pr_info("%s\n", str);
|
||||
}
|
||||
|
||||
int cryptosha256_init(void)
|
||||
|
||||
@@ -28,34 +28,34 @@ static void atomic_add_subtract(void)
|
||||
/* add one */
|
||||
atomic_inc(&debbie);
|
||||
|
||||
printk("chris: %d, debbie: %d\n",
|
||||
atomic_read(&chris), atomic_read(&debbie));
|
||||
pr_info("chris: %d, debbie: %d\n",
|
||||
atomic_read(&chris), atomic_read(&debbie));
|
||||
}
|
||||
|
||||
static void atomic_bitwise(void)
|
||||
{
|
||||
unsigned long word = 0;
|
||||
|
||||
printk("Bits 0: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
pr_info("Bits 0: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
set_bit(3, &word);
|
||||
set_bit(5, &word);
|
||||
printk("Bits 1: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
pr_info("Bits 1: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
clear_bit(5, &word);
|
||||
printk("Bits 2: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
pr_info("Bits 2: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
change_bit(3, &word);
|
||||
|
||||
printk("Bits 3: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
pr_info("Bits 3: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
if (test_and_set_bit(3, &word))
|
||||
printk("wrong\n");
|
||||
printk("Bits 4: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
pr_info("wrong\n");
|
||||
pr_info("Bits 4: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
|
||||
word = 255;
|
||||
printk("Bits 5: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
pr_info("Bits 5: "BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(word));
|
||||
}
|
||||
|
||||
static int example_atomic_init(void)
|
||||
{
|
||||
printk("example_atomic started\n");
|
||||
pr_info("example_atomic started\n");
|
||||
|
||||
atomic_add_subtract();
|
||||
atomic_bitwise();
|
||||
@@ -65,7 +65,7 @@ static int example_atomic_init(void)
|
||||
|
||||
static void example_atomic_exit(void)
|
||||
{
|
||||
printk("example_atomic exit\n");
|
||||
pr_info("example_atomic exit\n");
|
||||
}
|
||||
|
||||
module_init(example_atomic_init);
|
||||
|
||||
@@ -9,27 +9,27 @@ static int example_mutex_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
printk("example_mutex init\n");
|
||||
pr_info("example_mutex init\n");
|
||||
|
||||
ret = mutex_trylock(&mymutex);
|
||||
if (ret != 0) {
|
||||
printk("mutex is locked\n");
|
||||
pr_info("mutex is locked\n");
|
||||
|
||||
if (mutex_is_locked(&mymutex) == 0)
|
||||
printk("The mutex failed to lock!\n");
|
||||
pr_info("The mutex failed to lock!\n");
|
||||
|
||||
mutex_unlock(&mymutex);
|
||||
printk("mutex is unlocked\n");
|
||||
pr_info("mutex is unlocked\n");
|
||||
}
|
||||
else
|
||||
printk("Failed to lock\n");
|
||||
pr_info("Failed to lock\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void example_mutex_exit(void)
|
||||
{
|
||||
printk("example_mutex exit\n");
|
||||
pr_info("example_mutex exit\n");
|
||||
}
|
||||
|
||||
module_init(example_mutex_init);
|
||||
|
||||
@@ -9,12 +9,12 @@ static void example_read_lock(void)
|
||||
unsigned long flags;
|
||||
|
||||
read_lock_irqsave(&myrwlock, flags);
|
||||
printk("Read Locked\n");
|
||||
pr_info("Read Locked\n");
|
||||
|
||||
/* Read from something */
|
||||
|
||||
read_unlock_irqrestore(&myrwlock, flags);
|
||||
printk("Read Unlocked\n");
|
||||
pr_info("Read Unlocked\n");
|
||||
}
|
||||
|
||||
static void example_write_lock(void)
|
||||
@@ -22,17 +22,17 @@ static void example_write_lock(void)
|
||||
unsigned long flags;
|
||||
|
||||
write_lock_irqsave(&myrwlock, flags);
|
||||
printk("Write Locked\n");
|
||||
pr_info("Write Locked\n");
|
||||
|
||||
/* Write to something */
|
||||
|
||||
write_unlock_irqrestore(&myrwlock, flags);
|
||||
printk("Write Unlocked\n");
|
||||
pr_info("Write Unlocked\n");
|
||||
}
|
||||
|
||||
static int example_rwlock_init(void)
|
||||
{
|
||||
printk("example_rwlock started\n");
|
||||
pr_info("example_rwlock started\n");
|
||||
|
||||
example_read_lock();
|
||||
example_write_lock();
|
||||
@@ -42,7 +42,7 @@ static int example_rwlock_init(void)
|
||||
|
||||
static void example_rwlock_exit(void)
|
||||
{
|
||||
printk("example_rwlock exit\n");
|
||||
pr_info("example_rwlock exit\n");
|
||||
}
|
||||
|
||||
module_init(example_rwlock_init);
|
||||
|
||||
@@ -6,7 +6,7 @@ static int spi_probe(struct spi_device *spi)
|
||||
{
|
||||
int ret;
|
||||
|
||||
printk("spi example probe\n");
|
||||
pr_info("spi example probe\n");
|
||||
|
||||
spi->bits_per_word = 8;
|
||||
spi->mode = SPI_MODE_0;
|
||||
@@ -14,18 +14,18 @@ static int spi_probe(struct spi_device *spi)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
printk("spi device name = %s \n", spi->modalias);
|
||||
printk("spi device freq = %d \n", spi->max_speed_hz);
|
||||
printk("spi device's bus_num = %d \n", spi->master->bus_num);
|
||||
printk("spi device cs = %d \n", spi->chip_select);
|
||||
printk("spi device mode = %d \n\n", spi->mode);
|
||||
pr_info("spi device name = %s \n", spi->modalias);
|
||||
pr_info("spi device freq = %d \n", spi->max_speed_hz);
|
||||
pr_info("spi device's bus_num = %d \n", spi->master->bus_num);
|
||||
pr_info("spi device cs = %d \n", spi->chip_select);
|
||||
pr_info("spi device mode = %d \n\n", spi->mode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_remove(struct spi_device *spi)
|
||||
{
|
||||
printk("spi example remove\n");
|
||||
pr_info("spi example remove\n");
|
||||
|
||||
/* Your spi remove code */
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ static void example_spinlock_static(void)
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&sl_static, flags);
|
||||
printk("Locked static spinlock\n");
|
||||
pr_info("Locked static spinlock\n");
|
||||
|
||||
/* Do something or other safely.
|
||||
Because this uses 100% CPU time this
|
||||
@@ -20,7 +20,7 @@ static void example_spinlock_static(void)
|
||||
milliseconds to run */
|
||||
|
||||
spin_unlock_irqrestore(&sl_static, flags);
|
||||
printk("Unlocked static spinlock\n");
|
||||
pr_info("Unlocked static spinlock\n");
|
||||
}
|
||||
|
||||
static void example_spinlock_dynamic(void)
|
||||
@@ -29,7 +29,7 @@ static void example_spinlock_dynamic(void)
|
||||
|
||||
spin_lock_init(&sl_dynamic);
|
||||
spin_lock_irqsave(&sl_dynamic, flags);
|
||||
printk("Locked dynamic spinlock\n");
|
||||
pr_info("Locked dynamic spinlock\n");
|
||||
|
||||
/* Do something or other safely.
|
||||
Because this uses 100% CPU time this
|
||||
@@ -37,12 +37,12 @@ static void example_spinlock_dynamic(void)
|
||||
milliseconds to run */
|
||||
|
||||
spin_unlock_irqrestore(&sl_dynamic, flags);
|
||||
printk("Unlocked dynamic spinlock\n");
|
||||
pr_info("Unlocked dynamic spinlock\n");
|
||||
}
|
||||
|
||||
static int example_spinlock_init(void)
|
||||
{
|
||||
printk("example spinlock started\n");
|
||||
pr_info("example spinlock started\n");
|
||||
|
||||
example_spinlock_static();
|
||||
example_spinlock_dynamic();
|
||||
@@ -52,7 +52,7 @@ static int example_spinlock_init(void)
|
||||
|
||||
static void example_spinlock_exit(void)
|
||||
{
|
||||
printk("example spinlock exit\n");
|
||||
pr_info("example spinlock exit\n");
|
||||
}
|
||||
|
||||
module_init(example_spinlock_init);
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
|
||||
static void tasklet_fn(unsigned long data)
|
||||
{
|
||||
printk("Example tasklet starts\n");
|
||||
pr_info("Example tasklet starts\n");
|
||||
mdelay(5000);
|
||||
printk("Example tasklet ends\n");
|
||||
pr_info("Example tasklet ends\n");
|
||||
}
|
||||
|
||||
DECLARE_TASKLET(mytask, tasklet_fn, 0L);
|
||||
|
||||
static int example_tasklet_init(void)
|
||||
{
|
||||
printk("tasklet example init\n");
|
||||
pr_info("tasklet example init\n");
|
||||
tasklet_schedule(&mytask);
|
||||
mdelay(200);
|
||||
printk("Example tasklet init continues...\n");
|
||||
pr_info("Example tasklet init continues...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void example_tasklet_exit(void)
|
||||
{
|
||||
printk("tasklet example exit\n");
|
||||
pr_info("tasklet example exit\n");
|
||||
tasklet_kill(&mytask);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
printk(KERN_INFO "Hello world 1.\n");
|
||||
pr_info("Hello world 1.\n");
|
||||
|
||||
/*
|
||||
* A non 0 return means init_module failed; module can't be loaded.
|
||||
@@ -16,5 +16,5 @@ int init_module(void)
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
printk(KERN_INFO "Goodbye world 1.\n");
|
||||
pr_info("Goodbye world 1.\n");
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
|
||||
static int __init hello_2_init(void)
|
||||
{
|
||||
printk(KERN_INFO "Hello, world 2\n");
|
||||
pr_info("Hello, world 2\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit hello_2_exit(void)
|
||||
{
|
||||
printk(KERN_INFO "Goodbye, world 2\n");
|
||||
pr_info("Goodbye, world 2\n");
|
||||
}
|
||||
|
||||
module_init(hello_2_init);
|
||||
|
||||
@@ -9,13 +9,13 @@ static int hello3_data __initdata = 3;
|
||||
|
||||
static int __init hello_3_init(void)
|
||||
{
|
||||
printk(KERN_INFO "Hello, world %d\n", hello3_data);
|
||||
pr_info("Hello, world %d\n", hello3_data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit hello_3_exit(void)
|
||||
{
|
||||
printk(KERN_INFO "Goodbye, world 3\n");
|
||||
pr_info("Goodbye, world 3\n");
|
||||
}
|
||||
|
||||
module_init(hello_3_init);
|
||||
|
||||
@@ -12,13 +12,13 @@ MODULE_SUPPORTED_DEVICE("testdevice");
|
||||
|
||||
static int __init init_hello_4(void)
|
||||
{
|
||||
printk(KERN_INFO "Hello, world 4\n");
|
||||
return 0;
|
||||
pr_info("Hello, world 4\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit cleanup_hello_4(void)
|
||||
{
|
||||
printk(KERN_INFO "Goodbye, world 4\n");
|
||||
pr_info("Goodbye, world 4\n");
|
||||
}
|
||||
|
||||
module_init(init_hello_4);
|
||||
|
||||
@@ -48,22 +48,22 @@ MODULE_PARM_DESC(myintArray, "An array of integers");
|
||||
static int __init hello_5_init(void)
|
||||
{
|
||||
int i;
|
||||
printk(KERN_INFO "Hello, world 5\n=============\n");
|
||||
printk(KERN_INFO "myshort is a short integer: %hd\n", myshort);
|
||||
printk(KERN_INFO "myint is an integer: %d\n", myint);
|
||||
printk(KERN_INFO "mylong is a long integer: %ld\n", mylong);
|
||||
printk(KERN_INFO "mystring is a string: %s\n", mystring);
|
||||
pr_info("Hello, world 5\n=============\n");
|
||||
pr_info("myshort is a short integer: %hd\n", myshort);
|
||||
pr_info("myint is an integer: %d\n", myint);
|
||||
pr_info("mylong is a long integer: %ld\n", mylong);
|
||||
pr_info("mystring is a string: %s\n", mystring);
|
||||
|
||||
for (i = 0; i < (sizeof myintArray / sizeof (int)); i++)
|
||||
{
|
||||
printk(KERN_INFO "myintArray[%d] = %d\n", i, myintArray[i]);
|
||||
}
|
||||
printk(KERN_INFO "got %d arguments for myintArray.\n", arr_argc);
|
||||
pr_info("myintArray[%d] = %d\n", i, myintArray[i]);
|
||||
|
||||
pr_info("got %d arguments for myintArray.\n", arr_argc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit hello_5_exit(void)
|
||||
{
|
||||
printk(KERN_INFO "Goodbye, world 5\n");
|
||||
pr_info("Goodbye, world 5\n");
|
||||
}
|
||||
|
||||
module_init(hello_5_init);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/printk.h>
|
||||
#include <linux/kobject.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/init.h>
|
||||
@@ -42,7 +41,7 @@ static int __init mymodule_init (void)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
printk(KERN_INFO "mymodule: initialised\n");
|
||||
pr_info("mymodule: initialised\n");
|
||||
|
||||
mymodule =
|
||||
kobject_create_and_add("mymodule", kernel_kobj);
|
||||
@@ -51,8 +50,8 @@ static int __init mymodule_init (void)
|
||||
|
||||
error = sysfs_create_file(mymodule, &myvariable_attribute.attr);
|
||||
if (error) {
|
||||
printk(KERN_INFO "failed to create the myvariable file " \
|
||||
"in /sys/kernel/mymodule\n");
|
||||
pr_info("failed to create the myvariable file " \
|
||||
"in /sys/kernel/mymodule\n");
|
||||
}
|
||||
|
||||
return error;
|
||||
@@ -60,7 +59,7 @@ static int __init mymodule_init (void)
|
||||
|
||||
static void __exit mymodule_exit (void)
|
||||
{
|
||||
printk(KERN_INFO "mymodule: Exit success\n");
|
||||
pr_info("mymodule: Exit success\n");
|
||||
kobject_put(mymodule);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,13 +48,13 @@ int init_module()
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
printk(KERN_INFO "%s\n", __func__);
|
||||
pr_info("%s\n", __func__);
|
||||
|
||||
/* register LED gpios */
|
||||
ret = gpio_request_array(leds, ARRAY_SIZE(leds));
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request GPIOs for LEDs: %d\n", ret);
|
||||
pr_err("Unable to request GPIOs for LEDs: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -62,31 +62,31 @@ int init_module()
|
||||
ret = gpio_request_array(buttons, ARRAY_SIZE(buttons));
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request GPIOs for BUTTONs: %d\n", ret);
|
||||
pr_err("Unable to request GPIOs for BUTTONs: %d\n", ret);
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "Current button1 value: %d\n",
|
||||
gpio_get_value(buttons[0].gpio));
|
||||
pr_info("Current button1 value: %d\n",
|
||||
gpio_get_value(buttons[0].gpio));
|
||||
|
||||
ret = gpio_to_irq(buttons[0].gpio);
|
||||
|
||||
if (ret < 0) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
button_irqs[0] = ret;
|
||||
|
||||
printk(KERN_INFO "Successfully requested BUTTON1 IRQ # %d\n",
|
||||
button_irqs[0]);
|
||||
pr_info("Successfully requested BUTTON1 IRQ # %d\n",
|
||||
button_irqs[0]);
|
||||
|
||||
ret = request_irq(button_irqs[0], button_isr,
|
||||
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
||||
"gpiomod#button1", NULL);
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
@@ -94,21 +94,21 @@ int init_module()
|
||||
ret = gpio_to_irq(buttons[1].gpio);
|
||||
|
||||
if (ret < 0) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
button_irqs[1] = ret;
|
||||
|
||||
printk(KERN_INFO "Successfully requested BUTTON2 IRQ # %d\n",
|
||||
button_irqs[1]);
|
||||
pr_info("Successfully requested BUTTON2 IRQ # %d\n",
|
||||
button_irqs[1]);
|
||||
|
||||
ret = request_irq(button_irqs[1], button_isr,
|
||||
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
||||
"gpiomod#button2", NULL);
|
||||
|
||||
if (ret) {
|
||||
printk(KERN_ERR "Unable to request IRQ: %d\n", ret);
|
||||
pr_err("Unable to request IRQ: %d\n", ret);
|
||||
goto fail3;
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ void cleanup_module()
|
||||
{
|
||||
int i;
|
||||
|
||||
printk(KERN_INFO "%s\n", __func__);
|
||||
pr_info("%s\n", __func__);
|
||||
|
||||
/* free irqs */
|
||||
free_irq(button_irqs[0], NULL);
|
||||
|
||||
@@ -58,7 +58,7 @@ static long test_ioctl_ioctl(struct file* filp, unsigned int cmd, unsigned long
|
||||
goto done;
|
||||
}
|
||||
|
||||
printk(KERN_ALERT "IOCTL set val:%x .\n", data.val);
|
||||
pr_alert("IOCTL set val:%x .\n", data.val);
|
||||
write_lock(&ioctl_data->lock);
|
||||
ioctl_data->val = data.val;
|
||||
write_unlock(&ioctl_data->lock);
|
||||
@@ -125,7 +125,7 @@ out:
|
||||
}
|
||||
|
||||
static int test_ioctl_close(struct inode* inode, struct file* filp) {
|
||||
printk(KERN_ALERT "%s call.\n", __func__);
|
||||
pr_alert("%s call.\n", __func__);
|
||||
|
||||
if (filp->private_data) {
|
||||
kfree(filp->private_data);
|
||||
@@ -137,7 +137,7 @@ static int test_ioctl_close(struct inode* inode, struct file* filp) {
|
||||
|
||||
static int test_ioctl_open(struct inode* inode, struct file* filp) {
|
||||
struct test_ioctl_data* ioctl_data;
|
||||
printk(KERN_ALERT "%s call.\n", __func__);
|
||||
pr_alert("%s call.\n", __func__);
|
||||
ioctl_data = kmalloc(sizeof(struct test_ioctl_data), GFP_KERNEL);
|
||||
|
||||
if (ioctl_data == NULL) {
|
||||
@@ -176,7 +176,7 @@ static int ioctl_init(void) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
printk(KERN_ALERT "%s driver(major: %d) installed.\n", DRIVER_NAME, test_ioctl_major);
|
||||
pr_alert("%s driver(major: %d) installed.\n", DRIVER_NAME, test_ioctl_major);
|
||||
return 0;
|
||||
error:
|
||||
|
||||
@@ -195,7 +195,7 @@ static void ioctl_exit(void) {
|
||||
dev_t dev = MKDEV(test_ioctl_major, 0);
|
||||
cdev_del(&test_ioctl_cdev);
|
||||
unregister_chrdev_region(dev, num_of_dev);
|
||||
printk(KERN_ALERT "%s driver removed.\n", DRIVER_NAME);
|
||||
pr_alert("%s driver removed.\n", DRIVER_NAME);
|
||||
}
|
||||
|
||||
module_init(ioctl_init);
|
||||
|
||||
@@ -57,19 +57,19 @@ static int __init kbleds_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
printk(KERN_INFO "kbleds: loading\n");
|
||||
printk(KERN_INFO "kbleds: fgconsole is %x\n", fg_console);
|
||||
pr_info("kbleds: loading\n");
|
||||
pr_info("kbleds: fgconsole is %x\n", fg_console);
|
||||
for (i = 0; i < MAX_NR_CONSOLES; i++) {
|
||||
if (!vc_cons[i].d)
|
||||
break;
|
||||
printk(KERN_INFO "poet_atkm: console[%i/%i] #%i, tty %lx\n", i,
|
||||
MAX_NR_CONSOLES, vc_cons[i].d->vc_num,
|
||||
(unsigned long)vc_cons[i].d->port.tty);
|
||||
pr_info("poet_atkm: console[%i/%i] #%i, tty %lx\n", i,
|
||||
MAX_NR_CONSOLES, vc_cons[i].d->vc_num,
|
||||
(unsigned long)vc_cons[i].d->port.tty);
|
||||
}
|
||||
printk(KERN_INFO "kbleds: finished scanning consoles\n");
|
||||
pr_info("kbleds: finished scanning consoles\n");
|
||||
|
||||
my_driver = vc_cons[fg_console].d->port.tty->driver;
|
||||
printk(KERN_INFO "kbleds: tty driver magic %x\n", my_driver->magic);
|
||||
pr_info("kbleds: tty driver magic %x\n", my_driver->magic);
|
||||
|
||||
/*
|
||||
* Set up the LED blink timer the first time
|
||||
@@ -85,7 +85,7 @@ static int __init kbleds_init(void)
|
||||
|
||||
static void __exit kbleds_cleanup(void)
|
||||
{
|
||||
printk(KERN_INFO "kbleds: unloading...\n");
|
||||
pr_info("kbleds: unloading...\n");
|
||||
del_timer(&my_timer);
|
||||
(my_driver->ops->ioctl) (vc_cons[fg_console].d->port.tty,
|
||||
KDSETLED, RESTORE_LEDS);
|
||||
|
||||
@@ -17,7 +17,7 @@ ssize_t procfile_read(struct file *filePointer,char *buffer,
|
||||
{
|
||||
int ret=0;
|
||||
if(strlen(buffer) ==0) {
|
||||
printk(KERN_INFO "procfile read %s\n",filePointer->f_path.dentry->d_name.name);
|
||||
pr_info("procfile read %s\n",filePointer->f_path.dentry->d_name.name);
|
||||
ret=copy_to_user(buffer,"HelloWorld!\n",sizeof("HelloWorld!\n"));
|
||||
ret=sizeof("HelloWorld!\n");
|
||||
}
|
||||
@@ -35,16 +35,16 @@ int init_module()
|
||||
Our_Proc_File = proc_create(procfs_name,0644,NULL,&proc_file_fops);
|
||||
if(NULL==Our_Proc_File) {
|
||||
proc_remove(Our_Proc_File);
|
||||
printk(KERN_ALERT "Error:Could not initialize /proc/%s\n",procfs_name);
|
||||
pr_alert("Error:Could not initialize /proc/%s\n",procfs_name);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "/proc/%s created\n", procfs_name);
|
||||
pr_info("/proc/%s created\n", procfs_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanup_module()
|
||||
{
|
||||
proc_remove(Our_Proc_File);
|
||||
printk(KERN_INFO "/proc/%s removed\n", procfs_name);
|
||||
pr_info("/proc/%s removed\n", procfs_name);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ ssize_t procfile_read(struct file *filePointer,char *buffer,
|
||||
{
|
||||
int ret=0;
|
||||
if(strlen(buffer) ==0) {
|
||||
printk(KERN_INFO "procfile read %s\n",filePointer->f_path.dentry->d_name.name);
|
||||
pr_info("procfile read %s\n",filePointer->f_path.dentry->d_name.name);
|
||||
ret=copy_to_user(buffer,"HelloWorld!\n",sizeof("HelloWorld!\n"));
|
||||
ret=sizeof("HelloWorld!\n");
|
||||
}
|
||||
@@ -79,11 +79,11 @@ int init_module()
|
||||
Our_Proc_File = proc_create(PROCFS_NAME,0644,NULL,&proc_file_fops);
|
||||
if(NULL==Our_Proc_File) {
|
||||
proc_remove(Our_Proc_File);
|
||||
printk(KERN_ALERT "Error:Could not initialize /proc/%s\n",PROCFS_NAME);
|
||||
pr_alert("Error:Could not initialize /proc/%s\n",PROCFS_NAME);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
printk(KERN_INFO "/proc/%s created\n", PROCFS_NAME);
|
||||
pr_info("/proc/%s created\n", PROCFS_NAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -94,5 +94,5 @@ int init_module()
|
||||
void cleanup_module()
|
||||
{
|
||||
proc_remove(Our_Proc_File);
|
||||
printk(KERN_INFO "/proc/%s removed\n", PROCFS_NAME);
|
||||
pr_info("/proc/%s removed\n", PROCFS_NAME);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ static ssize_t procfs_read(struct file *filp, char *buffer,
|
||||
static int finished = 0;
|
||||
if(finished)
|
||||
{
|
||||
printk(KERN_DEBUG "procfs_read: END\n");
|
||||
pr_debug("procfs_read: END\n");
|
||||
finished = 0;
|
||||
return 0;
|
||||
}
|
||||
finished = 1;
|
||||
if(copy_to_user(buffer, procfs_buffer, procfs_buffer_size))
|
||||
return -EFAULT;
|
||||
printk(KERN_DEBUG "procfs_read: read %lu bytes\n", procfs_buffer_size);
|
||||
pr_debug("procfs_read: read %lu bytes\n", procfs_buffer_size);
|
||||
return procfs_buffer_size;
|
||||
}
|
||||
static ssize_t procfs_write(struct file *file, const char *buffer,
|
||||
@@ -40,7 +40,7 @@ static ssize_t procfs_write(struct file *file, const char *buffer,
|
||||
procfs_buffer_size = len;
|
||||
if(copy_from_user(procfs_buffer, buffer, procfs_buffer_size))
|
||||
return -EFAULT;
|
||||
printk(KERN_DEBUG "procfs_write: write %lu bytes\n", procfs_buffer_size);
|
||||
pr_debug("procfs_write: write %lu bytes\n", procfs_buffer_size);
|
||||
return procfs_buffer_size;
|
||||
}
|
||||
int procfs_open(struct inode *inode, struct file *file)
|
||||
@@ -67,17 +67,17 @@ int init_module()
|
||||
if(Our_Proc_File == NULL)
|
||||
{
|
||||
remove_proc_entry(PROCFS_ENTRY_FILENAME, NULL);
|
||||
printk(KERN_DEBUG "Error: Could not initialize /proc/%s\n", PROCFS_ENTRY_FILENAME);
|
||||
pr_debug("Error: Could not initialize /proc/%s\n", PROCFS_ENTRY_FILENAME);
|
||||
return -ENOMEM;
|
||||
}
|
||||
proc_set_size(Our_Proc_File, 80);
|
||||
proc_set_user(Our_Proc_File, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID);
|
||||
|
||||
printk(KERN_DEBUG "/proc/%s created\n", PROCFS_ENTRY_FILENAME);
|
||||
pr_debug("/proc/%s created\n", PROCFS_ENTRY_FILENAME);
|
||||
return 0;
|
||||
}
|
||||
void cleanup_module()
|
||||
{
|
||||
remove_proc_entry(PROCFS_ENTRY_FILENAME, NULL);
|
||||
printk(KERN_DEBUG "/proc/%s removed\n", PROCFS_ENTRY_FILENAME);
|
||||
pr_debug("/proc/%s removed\n", PROCFS_ENTRY_FILENAME);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ int init_module(void)
|
||||
if(entry == NULL)
|
||||
{
|
||||
remove_proc_entry(PROC_NAME, NULL);
|
||||
printk(KERN_DEBUG "Error: Could not initialize /proc/%s\n", PROC_NAME);
|
||||
pr_debug("Error: Could not initialize /proc/%s\n", PROC_NAME);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -130,5 +130,5 @@ int init_module(void)
|
||||
void cleanup_module(void)
|
||||
{
|
||||
remove_proc_entry(PROC_NAME, NULL);
|
||||
printk(KERN_DEBUG "/proc/%s removed\n", PROC_NAME);
|
||||
pr_debug("/proc/%s removed\n", PROC_NAME);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ int __init init_module()
|
||||
|
||||
if (Our_Proc_File == NULL) {
|
||||
remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
|
||||
printk(KERN_ALERT "Error: Could not initialize /proc/%s\n",
|
||||
PROC_ENTRY_FILENAME);
|
||||
pr_alert("Error: Could not initialize /proc/%s\n",
|
||||
PROC_ENTRY_FILENAME);
|
||||
return -ENOMEM;
|
||||
}
|
||||
proc_set_size(Our_Proc_File, 80);
|
||||
@@ -131,7 +131,7 @@ int __init init_module()
|
||||
my_workqueue = create_workqueue(MY_WORK_QUEUE_NAME);
|
||||
queue_delayed_work(my_workqueue, &Task, 100);
|
||||
|
||||
printk(KERN_INFO "/proc/%s created\n", PROC_ENTRY_FILENAME);
|
||||
pr_info("/proc/%s created\n", PROC_ENTRY_FILENAME);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -145,7 +145,7 @@ void __exit cleanup_module()
|
||||
* Unregister our /proc file
|
||||
*/
|
||||
remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
|
||||
printk(KERN_INFO "/proc/%s removed\n", PROC_ENTRY_FILENAME);
|
||||
pr_info("/proc/%s removed\n", PROC_ENTRY_FILENAME);
|
||||
|
||||
die = 1; /* keep intrp_routine from queueing itself */
|
||||
cancel_delayed_work(&Task); /* no "new ones" */
|
||||
|
||||
@@ -241,13 +241,13 @@ int init_module()
|
||||
if(Our_Proc_File == NULL)
|
||||
{
|
||||
remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
|
||||
printk(KERN_DEBUG "Error: Could not initialize /proc/%s\n", PROC_ENTRY_FILENAME);
|
||||
pr_debug("Error: Could not initialize /proc/%s\n", PROC_ENTRY_FILENAME);
|
||||
return -ENOMEM;
|
||||
}
|
||||
proc_set_size(Our_Proc_File, 80);
|
||||
proc_set_user(Our_Proc_File, GLOBAL_ROOT_UID, GLOBAL_ROOT_GID);
|
||||
|
||||
printk(KERN_INFO "/proc/test created\n");
|
||||
pr_info("/proc/test created\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -261,5 +261,5 @@ int init_module()
|
||||
void cleanup_module()
|
||||
{
|
||||
remove_proc_entry(PROC_ENTRY_FILENAME, NULL);
|
||||
printk(KERN_DEBUG "/proc/%s removed\n", PROC_ENTRY_FILENAME);
|
||||
pr_debug("/proc/%s removed\n", PROC_ENTRY_FILENAME);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
printk(KERN_INFO "Hello, world - this is the kernel speaking\n");
|
||||
pr_info("Hello, world - this is the kernel speaking\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
|
||||
void cleanup_module()
|
||||
{
|
||||
printk(KERN_INFO "Short is the life of a kernel module\n");
|
||||
pr_info("Short is the life of a kernel module\n");
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ asmlinkage int our_sys_open(const char *filename, int flags, int mode)
|
||||
/*
|
||||
* Report the file, if relevant
|
||||
*/
|
||||
printk("Opened file by %d: ", uid);
|
||||
pr_info("Opened file by %d: ", uid);
|
||||
do {
|
||||
get_user(ch, filename + i);
|
||||
i++;
|
||||
printk("%c", ch);
|
||||
pr_info("%c", ch);
|
||||
} while (ch != 0);
|
||||
printk("\n");
|
||||
pr_info("\n");
|
||||
|
||||
/*
|
||||
* Call the original sys_open - otherwise, we lose
|
||||
@@ -121,7 +121,7 @@ static int __init syscall_start(void)
|
||||
|
||||
write_cr0(original_cr0);
|
||||
|
||||
printk(KERN_INFO "Spying on UID:%d\n", uid);
|
||||
pr_info("Spying on UID:%d\n", uid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -136,10 +136,10 @@ static void __exit syscall_end(void)
|
||||
* Return the system call back to normal
|
||||
*/
|
||||
if (sys_call_table[__NR_open] != (unsigned long *)our_sys_open) {
|
||||
printk(KERN_ALERT "Somebody else also played with the ");
|
||||
printk(KERN_ALERT "open system call\n");
|
||||
printk(KERN_ALERT "The system may be left in ");
|
||||
printk(KERN_ALERT "an unstable state.\n");
|
||||
pr_alert("Somebody else also played with the ");
|
||||
pr_alert("open system call\n");
|
||||
pr_alert("The system may be left in ");
|
||||
pr_alert("an unstable state.\n");
|
||||
}
|
||||
|
||||
write_cr0(original_cr0 & ~0x00010000);
|
||||
|
||||
Reference in New Issue
Block a user