summaryrefslogtreecommitdiff
path: root/drivers/staging/greybus/light.c
diff options
context:
space:
mode:
authorRui Miguel Silva <rui.silva@linaro.org>2016-02-17 14:32:53 +0000
committerGreg Kroah-Hartman <gregkh@google.com>2016-02-17 15:24:09 -0800
commitc6ad27a98ce5f9718c7235cf02de2055897f56d5 (patch)
tree82e169c61e626fb81872c840650b94f0d2ccc120 /drivers/staging/greybus/light.c
parent137f717942c9cff82484ee90647881d9c524178f (diff)
greybus: lights: fix check for configured lights
The validation for a complete configured light is wrong and it is reworked to make sure that only when the light is ready, will handle request events. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Reported-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/light.c')
-rw-r--r--drivers/staging/greybus/light.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 4c46d149cb7d..17877f7e2ee4 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -55,6 +55,7 @@ struct gb_light {
u8 channels_count;
struct gb_channel *channels;
bool has_flash;
+ bool ready;
#ifdef V4L2_HAVE_FLASH
struct v4l2_flash *v4l2_flash;
#endif
@@ -1002,6 +1003,8 @@ static int gb_lights_light_register(struct gb_light *light)
return ret;
}
+ light->ready = true;
+
if (light->has_flash) {
ret = gb_lights_light_v4l2_register(light);
if (ret < 0) {
@@ -1040,6 +1043,7 @@ static void gb_lights_light_release(struct gb_light *light)
int i;
int count;
+ light->ready = false;
count = light->channels_count;
@@ -1174,7 +1178,8 @@ static int gb_lights_request_handler(struct gb_operation *op)
payload = request->payload;
light_id = payload->light_id;
- if (light_id >= glights->lights_count || !&glights->lights[light_id]) {
+ if (light_id >= glights->lights_count || !glights->lights ||
+ !glights->lights[light_id].ready) {
dev_err(dev, "Event received for unconfigured light id: %d\n",
light_id);
return -EINVAL;