mbpfan-josie

Support for kernel >= 3.15

6bfe9325c37fb5f1f84437af0eeb592202bd5264
Daniel Graziotin <daniel@ineed.coffee> · 2014-06-21T19:35 · browse files at this commit

parents: f3bbf97

diff --git a/README.md b/README.md
index 7c222ce..c38d754 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,7 @@ Tested Macbook Models
 ---------------------
 This section reports those models where mbpfan was tested successfully. It does not necessarily mean that the daemon does not work on non-listed models. 
 
+- MacBook Pro 11,1 13"  (Intel i5 - Linux 3.14, Linux 3.15)
 - MacBook Pro 9,2 13"  (Intel i5/i7 - Linux 3.10)
 - Macbook Pro 8,2 15"  (Intel i7 - Linux 3.6.2)
 - MacBook Pro 8,1 13"  (Intel i7 - Linux 3.2.0)
diff --git a/src/daemon.c b/src/daemon.c
old mode 100644
new mode 100755
index 9b33b61..215558f
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -1,6 +1,6 @@
 /**
  *  Copyright (C) 2012  Peter Lombardo <http://peterlombardo.wikidot.com/linux-daemon-in-c>
- *  Modifications (2012) by Daniel Graziotin <dgraziotin@task3.cc>
+ *  Modifications (2012) by Daniel Graziotin <daniel@ineed.coffee>
  *  Modifications (2012) by Ismail Khatib <ikhatib@gmail.com>
  *
  *  This program is free software: you can redistribute it and/or modify
diff --git a/src/daemon.h b/src/daemon.h
index 67fa775..35b7592 100644
--- a/src/daemon.h
+++ b/src/daemon.h
@@ -1,5 +1,5 @@
 /**
- *  Copyright (C) (2012) Daniel Graziotin <dgraziotin@task3.cc>
+ *  Copyright (C) (2012) Daniel Graziotin <daniel@ineed.coffee>
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
diff --git a/src/main.c b/src/main.c
index 067e933..e766954 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,5 @@
 /**
- *  Copyright (C) (2012) Daniel Graziotin <dgraziotin@task3.cc>
+ *  Copyright (C) (2012-2014) Daniel Graziotin <daniel@ineed.coffee>
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
diff --git a/src/mbpfan.c b/src/mbpfan.c
old mode 100644
new mode 100755
index 86cdbe5..0650113
--- a/src/mbpfan.c
+++ b/src/mbpfan.c
@@ -2,7 +2,7 @@
  *  mbpfan.c - automatically control fan for MacBook Pro
  *  Copyright (C) 2010  Allan McRae <allan@archlinux.org>
  *  Modifications by Rafael Vega <rvega@elsoftwarehamuerto.org>
- *  Modifications (2012) by Daniel Graziotin <dgraziotin@task3.cc>
+ *  Modifications (2012) by Daniel Graziotin <daniel@ineed.coffee>
  *  Modifications (2012) by Ismail Khatib <ikhatib@gmail.com>
  *
  *  This program is free software: you can redistribute it and/or modify
@@ -15,7 +15,7 @@
  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *  GNU General Public License for more details.
  *
- *  2012-06-09 - v1.2
+ *  2012-06-09 - v1.5.x
  *
  *  Notes:
  *    Assumes any number of processors and fans (max. 10)
@@ -36,6 +36,7 @@
 #include <string.h>
 #include <math.h>
 #include <syslog.h>
+#include <linux/version.h>
 #include "mbpfan.h"
 #include "global.h"
 #include "settings.h"
@@ -67,7 +68,34 @@ t_sensors *retrieve_sensors()
     t_sensors *s = NULL;
 
     char *path = NULL;
+
+    
+    #if LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)
+
+    if(verbose) {
+        printf("Using legacy sensor path for kernel < 3.15.0\n");
+
+        if(daemonize) {
+            syslog(LOG_INFO, "Using legacy path for kernel < 3.15.0");
+        }
+    }
+
     const char *path_begin = "/sys/devices/platform/coretemp.0/temp";
+
+    #else
+
+    if(verbose) {
+        printf("Using new sensor path for kernel >= 3.0.15\n");
+
+        if(daemonize) {
+            syslog(LOG_INFO, "Using new sensor path for kernel >= 3.0.15");
+        }
+    }
+
+    const char *path_begin = "/sys/devices/platform/coretemp.0/hwmon/hwmon0/temp";
+
+    #endif
+
     const char *path_end = "_input";
 
     int path_size = strlen(path_begin) + strlen(path_end) + 2;
diff --git a/src/mbpfan.h b/src/mbpfan.h
index 27cba96..5b6ed21 100644
--- a/src/mbpfan.h
+++ b/src/mbpfan.h
@@ -1,6 +1,6 @@
 /**
  *  Copyright (C) 2010  Allan McRae <allan@archlinux.org>
- *  Modifications (2012) by Daniel Graziotin <dgraziotin@task3.cc>
+ *  Modifications (2012) by Daniel Graziotin <daniel@ineed.coffee>
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by