summaryrefslogtreecommitdiff
path: root/liblight
diff options
context:
space:
mode:
Diffstat (limited to 'liblight')
-rw-r--r--liblight/lights.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/liblight/lights.c b/liblight/lights.c
index ccfbe102..229777a3 100644
--- a/liblight/lights.c
+++ b/liblight/lights.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2014 The Linux Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -115,6 +116,9 @@ set_light_backlight(struct light_device_t* dev,
{
int err = 0;
int brightness = rgb_to_brightness(state);
+ if(!dev) {
+ return -1;
+ }
pthread_mutex_lock(&g_lock);
err = write_int(LCD_FILE, brightness);
pthread_mutex_unlock(&g_lock);
@@ -125,12 +129,15 @@ static int
set_speaker_light_locked(struct light_device_t* dev,
struct light_state_t const* state)
{
- int len;
- int alpha, red, green, blue;
+ int red, green, blue;
int blink;
int onMS, offMS;
unsigned int colorRGB;
+ if(!dev) {
+ return -1;
+ }
+
switch (state->flashMode) {
case LIGHT_FLASH_TIMED:
onMS = state->flashOnMS;
@@ -217,6 +224,9 @@ set_light_buttons(struct light_device_t* dev,
struct light_state_t const* state)
{
int err = 0;
+ if(!dev) {
+ return -1;
+ }
pthread_mutex_lock(&g_lock);
err = write_int(BUTTON_FILE, state->color & 0xFF);
pthread_mutex_unlock(&g_lock);