From 397b761cc42e2c56f8de07de680486892448b628 Mon Sep 17 00:00:00 2001 From: Alexey Dobriyan Date: Sat, 5 Dec 2009 03:27:29 +0300 Subject: Blackfin: convert kgdbtest to proc_fops The read_proc and write_proc interfaces are going to be removed in the common kernel code. Signed-off-by: Alexey Dobriyan Signed-off-by: Mike Frysinger --- arch/blackfin/kernel/kgdb_test.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) (limited to 'arch/blackfin/kernel/kgdb_test.c') diff --git a/arch/blackfin/kernel/kgdb_test.c b/arch/blackfin/kernel/kgdb_test.c index 59fc42dc5d6..6fc4e5f6226 100644 --- a/arch/blackfin/kernel/kgdb_test.c +++ b/arch/blackfin/kernel/kgdb_test.c @@ -18,7 +18,7 @@ #include static char cmdline[256]; -static unsigned long len; +static size_t len; #ifndef CONFIG_SMP static int num1 __attribute__((l1_data)); @@ -59,7 +59,8 @@ int kgdb_test(char *name, int len, int count, int z) return count; } -static int test_proc_output(char *buf) +static ssize_t kgdb_test_proc_read(struct file *file, char __user *buf, + size_t count, loff_t *ppos) { kgdb_test("hello world!", 12, 0x55, 0x10); #ifndef CONFIG_SMP @@ -72,25 +73,8 @@ static int test_proc_output(char *buf) return 0; } -static int test_read_proc(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - int len; - - len = test_proc_output(page); - if (len <= off+count) - *eof = 1; - *start = page + off; - len -= off; - if (len > count) - len = count; - if (len < 0) - len = 0; - return len; -} - -static int test_write_proc(struct file *file, const char *buffer, - unsigned long count, void *data) +static ssize_t kgdb_test_proc_write(struct file *file, + const char __user *buffer, size_t count, loff_t *pos) { if (count >= 256) len = 255; @@ -103,18 +87,19 @@ static int test_write_proc(struct file *file, const char *buffer, return len; } +static const struct file_operations kgdb_test_proc_fops = { + .owner = THIS_MODULE, + .read = kgdb_test_proc_read, + .write = kgdb_test_proc_write, +}; + static int __init kgdbtest_init(void) { struct proc_dir_entry *entry; - entry = create_proc_entry("kgdbtest", 0, NULL); + entry = proc_create("kgdbtest", 0, NULL, &kgdb_test_proc_fops); if (entry == NULL) return -ENOMEM; - - entry->read_proc = test_read_proc; - entry->write_proc = test_write_proc; - entry->data = NULL; - return 0; } -- cgit v1.2.3 From 88f7c2fb0fa96887c7be8cdb00afb1a6f9d7894e Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 7 Dec 2009 10:20:20 +0000 Subject: Blackfin: kgdb_test: clean up code a bit - document simple global symbols - convert printk to pr_* - clean up spurious whitespace - use min_t() Signed-off-by: Mike Frysinger --- arch/blackfin/kernel/kgdb_test.c | 44 +++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'arch/blackfin/kernel/kgdb_test.c') diff --git a/arch/blackfin/kernel/kgdb_test.c b/arch/blackfin/kernel/kgdb_test.c index 6fc4e5f6226..9a4b0759438 100644 --- a/arch/blackfin/kernel/kgdb_test.c +++ b/arch/blackfin/kernel/kgdb_test.c @@ -17,6 +17,7 @@ #include +/* Symbols are here for kgdb test to poke directly */ static char cmdline[256]; static size_t len; @@ -27,11 +28,10 @@ void kgdb_l1_test(void) __attribute__((l1_text)); void kgdb_l1_test(void) { - printk(KERN_ALERT "L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); - printk(KERN_ALERT "L1 : code function addr = 0x%p\n", kgdb_l1_test); - num1 = num1 + 10 ; - printk(KERN_ALERT "L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); - return ; + pr_alert("L1(before change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); + pr_alert("L1 : code function addr = 0x%p\n", kgdb_l1_test); + num1 = num1 + 10; + pr_alert("L1(after change) : data variable addr = 0x%p, data value is %d\n", &num1, num1); } #endif @@ -42,11 +42,10 @@ void kgdb_l2_test(void) __attribute__((l2)); void kgdb_l2_test(void) { - printk(KERN_ALERT "L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); - printk(KERN_ALERT "L2 : code function addr = 0x%p\n", kgdb_l2_test); - num2 = num2 + 20 ; - printk(KERN_ALERT "L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); - return ; + pr_alert("L2(before change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); + pr_alert("L2 : code function addr = 0x%p\n", kgdb_l2_test); + num2 = num2 + 20; + pr_alert("L2(after change) : data variable addr = 0x%p, data value is %d\n", &num2, num2); } #endif @@ -54,13 +53,14 @@ void kgdb_l2_test(void) int kgdb_test(char *name, int len, int count, int z) { - printk(KERN_ALERT "kgdb name(%d): %s, %d, %d\n", len, name, count, z); + pr_alert("kgdb name(%d): %s, %d, %d\n", len, name, count, z); count = z; return count; } -static ssize_t kgdb_test_proc_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) +static ssize_t +kgdb_test_proc_read(struct file *file, char __user *buf, + size_t count, loff_t *ppos) { kgdb_test("hello world!", 12, 0x55, 0x10); #ifndef CONFIG_SMP @@ -73,14 +73,11 @@ static ssize_t kgdb_test_proc_read(struct file *file, char __user *buf, return 0; } -static ssize_t kgdb_test_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) +static ssize_t +kgdb_test_proc_write(struct file *file, const char __user *buffer, + size_t count, loff_t *pos) { - if (count >= 256) - len = 255; - else - len = count; - + len = min_t(size_t, 255, count); memcpy(cmdline, buffer, count); cmdline[len] = 0; @@ -88,9 +85,9 @@ static ssize_t kgdb_test_proc_write(struct file *file, } static const struct file_operations kgdb_test_proc_fops = { - .owner = THIS_MODULE, - .read = kgdb_test_proc_read, - .write = kgdb_test_proc_write, + .owner = THIS_MODULE, + .read = kgdb_test_proc_read, + .write = kgdb_test_proc_write, }; static int __init kgdbtest_init(void) @@ -100,6 +97,7 @@ static int __init kgdbtest_init(void) entry = proc_create("kgdbtest", 0, NULL, &kgdb_test_proc_fops); if (entry == NULL) return -ENOMEM; + return 0; } -- cgit v1.2.3