]> www.infradead.org Git - users/mchehab/rasdaemon.git/commitdiff
Fix rasdaemon -d
authorMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 23 May 2013 11:21:55 +0000 (08:21 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 23 May 2013 11:21:55 +0000 (08:21 -0300)
We need to get the debugfs pointer in order to toggle the MC events.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
ras-events.c
ras-events.h
rasdaemon.c

index 091172e4dfb6b4019faf8920f46b5c616f056fa3..95fb09701e92ba571e030421285bf0e0a0fe0f2d 100644 (file)
@@ -138,7 +138,7 @@ static int get_tracing_dir(struct ras_events *ras)
 /*
  * Tracing enable/disable code
  */
-int toggle_ras_mc_event(struct ras_events *ras, int enable)
+static int __toggle_ras_mc_event(struct ras_events *ras, int enable)
 {
        int fd, rc;
 
@@ -173,6 +173,31 @@ int toggle_ras_mc_event(struct ras_events *ras, int enable)
        return 0;
 }
 
+int toggle_ras_mc_event(int enable)
+{
+       struct ras_events *ras;
+       int rc = 0;
+
+       ras = calloc(1, sizeof(*ras));
+       if (!ras) {
+               log(TERM, LOG_ERR, "Can't allocate memory for ras struct\n");
+               return errno;
+       }
+
+       rc = get_tracing_dir(ras);
+       if (rc < 0) {
+               log(TERM, LOG_ERR, "Can't locate a mounted debugfs\n");
+               goto free_ras;
+       }
+
+       __toggle_ras_mc_event(ras, enable);
+
+free_ras:
+       free(ras);
+       return rc;
+}
+
+
 /*
  * Tracing read code
  */
@@ -438,7 +463,7 @@ int handle_ras_events(int record_events)
        }
 
        /* Enable RAS events */
-       rc = toggle_ras_mc_event(ras, 1);
+       rc = __toggle_ras_mc_event(ras, 1);
        if (rc < 0) {
                log(TERM, LOG_ERR, "Can't enable RAS tracing\n");
                goto free_ras;
index b614eb11d97e45941bd85cac86c9c21e17a6b90b..22d286533e0c7ebf52d611b16d741ba4923c5c18 100644 (file)
@@ -66,7 +66,7 @@ enum hw_event_mc_err_type {
 };
 
 /* Function prototypes */
-int toggle_ras_mc_event(struct ras_events *ras, int enable);
+int toggle_ras_mc_event(int enable);
 int handle_ras_events(int record_events);
 char *mc_event_error_type(unsigned long long err_type);
 
index bb194a53e8bbe39a3e002830fc3d5610319a1974..94fbb638d5659d502a1b1a52fc75145670f3838e 100644 (file)
@@ -96,13 +96,14 @@ int main(int argc, char *argv[])
                return -1;
        }
 
-       if (args.enable_ras > 0)
-               toggle_ras_mc_event(ras, 1);
-       else if (args.enable_ras < 0)
-               toggle_ras_mc_event(ras, 0);
+       if (args.enable_ras) {
+               int enable;
+
+               enable = (args.enable_ras > 0) ? 1 : 0;
+               toggle_ras_mc_event(enable);
 
-       if (args.enable_ras)
                return 0;
+       }
 
        openlog(TOOL_NAME, 0, LOG_DAEMON);
        if (!args.foreground)