]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - samples/hw_breakpoint/data_breakpoint.c
Merge branch 'devel' of git://git.kernel.org/pub/scm/linux/kernel/git/ycmiao/pxa...
[karo-tx-linux.git] / samples / hw_breakpoint / data_breakpoint.c
index 5bc9819a819e548eaa72d95cc7e17ce0c9b9ac47..c69cbe9b2426a287bf754a82344957f9a2ead426 100644 (file)
@@ -23,6 +23,8 @@
  * that variable.
  *
  * Copyright (C) IBM Corporation, 2009
+ *
+ * Author: K.Prasad <prasad@linux.vnet.ibm.com>
  */
 #include <linux/module.h>      /* Needed by all modules */
 #include <linux/kernel.h>      /* Needed for KERN_INFO */
@@ -39,7 +41,9 @@ module_param_string(ksym, ksym_name, KSYM_NAME_LEN, S_IRUGO);
 MODULE_PARM_DESC(ksym, "Kernel symbol to monitor; this module will report any"
                        " write operations on the kernel symbol");
 
-static void sample_hbp_handler(struct perf_event *temp, void *data)
+static void sample_hbp_handler(struct perf_event *bp, int nmi,
+                              struct perf_sample_data *data,
+                              struct pt_regs *regs)
 {
        printk(KERN_INFO "%s value is changed\n", ksym_name);
        dump_stack();
@@ -49,19 +53,17 @@ static void sample_hbp_handler(struct perf_event *temp, void *data)
 static int __init hw_break_module_init(void)
 {
        int ret;
-       unsigned long addr;
+       struct perf_event_attr attr;
 
-       addr = kallsyms_lookup_name(ksym_name);
+       hw_breakpoint_init(&attr);
+       attr.bp_addr = kallsyms_lookup_name(ksym_name);
+       attr.bp_len = HW_BREAKPOINT_LEN_4;
+       attr.bp_type = HW_BREAKPOINT_W | HW_BREAKPOINT_R;
 
-       sample_hbp = register_wide_hw_breakpoint(addr, HW_BREAKPOINT_LEN_4,
-                                                HW_BREAKPOINT_W | HW_BREAKPOINT_R,
-                                                sample_hbp_handler, true);
+       sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler);
        if (IS_ERR(sample_hbp)) {
                ret = PTR_ERR(sample_hbp);
                goto fail;
-       } else if (!sample_hbp) {
-               ret = -EINVAL;
-               goto fail;
        }
 
        printk(KERN_INFO "HW Breakpoint for %s write installed\n", ksym_name);