summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher N. Hesse <raymanfx@gmail.com>2016-11-18 18:56:17 +0100
committerdeadman96385 <seanhoyt963@gmail.com>2017-01-28 19:09:34 -0600
commit462a6787661c293f7b9383340f1407366f91797c (patch)
tree6aed2c1c80dcf7acbf57a5bc3235e1b13370f5bf
parentdf3f7d73444c3bb5516bd3eaffa5bdf661e5060a (diff)
downloadandroid_hardware_samsung-462a6787661c293f7b9383340f1407366f91797c.tar.gz
android_hardware_samsung-462a6787661c293f7b9383340f1407366f91797c.tar.bz2
android_hardware_samsung-462a6787661c293f7b9383340f1407366f91797c.zip
power: Simplify read_panel_brightness()
Overengineering. Change-Id: Ifef79a7e8f2249fdd22099a043303f9686ac014b
-rw-r--r--power/power.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/power/power.c b/power/power.c
index 364a563..f80f3e8 100644
--- a/power/power.c
+++ b/power/power.c
@@ -23,6 +23,7 @@
#include <fcntl.h>
#include <malloc.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -124,11 +125,14 @@ static void sysfs_write(const char *path, char *s)
close(fd);
}
-static unsigned int read_panel_brightness() {
- unsigned int i, ret = 0;
+static int read_panel_brightness() {
+ int ret = 0;
int read_status;
// brightness can range from 0 to 255, so max. 3 chars + '\0'
char panel_brightness[4];
+ // for strtol
+ char *dummy;
+ const int base = 10;
read_status = sysfs_read(PANEL_BRIGHTNESS, panel_brightness, sizeof(PANEL_BRIGHTNESS));
if (read_status < 0) {
@@ -136,12 +140,7 @@ static unsigned int read_panel_brightness() {
return -1;
}
- for (i = 0; i < (sizeof(panel_brightness) / sizeof(panel_brightness[0])); i++) {
- if (isdigit(panel_brightness[i])) {
- ret += (panel_brightness[i] - '0');
- }
- }
-
+ ret = strtol(panel_brightness, &dummy, base);
ALOGV("%s: Panel brightness is: %d", __func__, ret);
return ret;