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/u= power/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" << "asu= s_laptop" - << "toshiba" << "eeepc" << "thinkpad_screen" << "acpi_video= 1" << "acpi_video0" - << "intel_backlight" << "apple_backlight" << "fujitsu-lapto= p" << "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 =3D 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 =3D dir.entryList(); - if (!dirList.isEmpty()) { - m_dirname =3D dirList.first(); - } - } -} - -bool BacklightHelper::useWhitelistInit() -{ - struct utsname uts; - uname(&uts); - - int major, minor, patch, result; - result =3D sscanf(uts.release, "%d.%d", &major, &minor); - - if (result !=3D 2) { - return true; // Malformed version - } - - if (major >=3D 3) { - return false; //Kernel 3+, we want type based init - } - - result =3D sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch); - - if (result !=3D 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/upo= wer/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 =3D 0); + BacklightHelper(QObject *parent =3D 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 us= e we have - * a whitelsit based on the feedback given by our users, if the interf= ace is not - * within our whitelist we will look for a random one within the backl= ight 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=3D288180 - */ - bool useWhitelistInit(); - bool m_isSupported; + bool m_isSupported =3D false; QString m_dirname; QString m_sysctlDevice; QList m_sysctlBrightnessLevels;