[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [powerdevil] daemon/backends/upower: Remove whitelist-based init
From:       Kai Uwe Broulik <kde () privat ! broulik ! de>
Date:       2015-02-28 19:45:41
Message-ID: E1YRnKX-00044p-4u () scm ! kde ! org
[Download RAW message or body]

Git commit dfcee0b0e22c3708552bbd7003fb926e2df033d8 by Kai Uwe Broulik.
Committed on 28/02/2015 at 19:44.
Pushed by broulik into branch 'master'.

Remove whitelist-based init

Since Kernel 2.6.37, which has been released in September 2010,
we use a type-based init system

M  +2    -69   daemon/backends/upower/backlighthelper.cpp
M  +2    -13   daemon/backends/upower/backlighthelper.h

http://commits.kde.org/powerdevil/dfcee0b0e22c3708552bbd7003fb926e2df033d8

diff --git a/daemon/backends/upower/backlighthelper.cpp \
b/daemon/backends/upower/backlighthelper.cpp index e46aaab..83efec1 100644
--- a/daemon/backends/upower/backlighthelper.cpp
+++ b/daemon/backends/upower/backlighthelper.cpp
@@ -41,20 +41,14 @@
 
 #define PREFIX "/sys/class/backlight/"
 
-BacklightHelper::BacklightHelper(QObject * parent)
-    : QObject(parent), m_isSupported(false)
+BacklightHelper::BacklightHelper(QObject *parent) : QObject(parent)
 {
     init();
 }
 
 void BacklightHelper::init()
 {
-
-    if (useWhitelistInit()) {
-        initUsingWhitelist();
-    } else {
-        initUsingBacklightType();
-    }
+    initUsingBacklightType();
 
     if (m_dirname.isEmpty()) {
         initUsingSysctl();
@@ -120,67 +114,6 @@ void BacklightHelper::initUsingBacklightType()
     }
 }
 
-
-void BacklightHelper::initUsingWhitelist()
-{
-    QStringList interfaces;
-    interfaces << "nv_backlight" << "radeon_bl" << "mbp_backlight" << "asus_laptop"
-               << "toshiba" << "eeepc" << "thinkpad_screen" << "acpi_video1" << \
                "acpi_video0"
-               << "intel_backlight" << "apple_backlight" << "fujitsu-laptop" << \
                "samsung"
-               << "nvidia_backlight" << "dell_backlight" << "sony" << \
                "pwm-backlight"
-               ;
-
-    QDir dir;
-    foreach (const QString & interface, interfaces) {
-        dir.setPath(PREFIX + interface);
-        //qCDebug(POWERDEVIL) << "searching dir:" << dir;
-        if (dir.exists()) {
-            m_dirname = dir.path();
-            //qCDebug(POWERDEVIL) << "kernel backlight support found in" << \
                m_dirname;
-            break;
-        }
-    }
-
-    //If none of our whitelisted interface is available, get the first one  (if any)
-    if (m_dirname.isEmpty()) {
-        dir.setPath(PREFIX);
-        dir.setFilter(QDir::AllDirs | QDir::NoDot | QDir::NoDotDot | \
                QDir::NoDotAndDotDot | QDir::Readable);
-        QStringList dirList = dir.entryList();
-        if (!dirList.isEmpty()) {
-            m_dirname = dirList.first();
-        }
-    }
-}
-
-bool BacklightHelper::useWhitelistInit()
-{
-    struct utsname uts;
-    uname(&uts);
-
-    int major, minor, patch, result;
-    result = sscanf(uts.release, "%d.%d", &major, &minor);
-
-    if (result != 2) {
-        return true; // Malformed version
-    }
-
-    if (major >= 3) {
-        return false; //Kernel 3+, we want type based init
-    }
-
-    result = sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch);
-
-    if (result != 3) {
-        return true; // Malformed version
-    }
-
-    if (patch < 37) {
-        return true; //Minor than 2.6.37, use whiteList based
-    }
-
-    return false;//Use Type based interafce
-}
-
 void BacklightHelper::initUsingSysctl()
 {
 #ifdef USE_SYSCTL
diff --git a/daemon/backends/upower/backlighthelper.h \
b/daemon/backends/upower/backlighthelper.h index 7fc30f6..b5ce7dc 100644
--- a/daemon/backends/upower/backlighthelper.h
+++ b/daemon/backends/upower/backlighthelper.h
@@ -29,7 +29,7 @@ class BacklightHelper: public QObject
 {
     Q_OBJECT
 public:
-    BacklightHelper(QObject * parent = 0);
+    BacklightHelper(QObject *parent = nullptr);
 
 public slots:
     ActionReply brightness(const QVariantMap &args);
@@ -39,12 +39,6 @@ public slots:
 
 private:
     void init();
-    /**
-     * For older kernels that doesn't indicate which type the interface use we have
-     * a whitelsit based on the feedback given by our users, if the interface is not
-     * within our whitelist we will look for a random one within the backlight \
                folder
-     */
-    void initUsingWhitelist();
 
     /**
      * The kernel offer from version 2.6.37 the type of the interface, and based on \
that @@ -58,12 +52,7 @@ private:
      */
     void initUsingSysctl();
 
-    /**
-     * If Kernel older than 2.6.37 use whitelsit, otherwise use backlight/type
-     * @see https://bugs.kde.org/show_bug.cgi?id=288180
-     */
-    bool useWhitelistInit();
-    bool m_isSupported;
+    bool m_isSupported = false;
     QString m_dirname;
     QString m_sysctlDevice;
     QList<int> m_sysctlBrightnessLevels;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic