Commit c6ad27a9 authored by Rui Miguel Silva's avatar Rui Miguel Silva Committed by Greg Kroah-Hartman

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: default avatarRui Miguel Silva <rui.silva@linaro.org>
Reported-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 137f7179
...@@ -55,6 +55,7 @@ struct gb_light { ...@@ -55,6 +55,7 @@ struct gb_light {
u8 channels_count; u8 channels_count;
struct gb_channel *channels; struct gb_channel *channels;
bool has_flash; bool has_flash;
bool ready;
#ifdef V4L2_HAVE_FLASH #ifdef V4L2_HAVE_FLASH
struct v4l2_flash *v4l2_flash; struct v4l2_flash *v4l2_flash;
#endif #endif
...@@ -1002,6 +1003,8 @@ static int gb_lights_light_register(struct gb_light *light) ...@@ -1002,6 +1003,8 @@ static int gb_lights_light_register(struct gb_light *light)
return ret; return ret;
} }
light->ready = true;
if (light->has_flash) { if (light->has_flash) {
ret = gb_lights_light_v4l2_register(light); ret = gb_lights_light_v4l2_register(light);
if (ret < 0) { if (ret < 0) {
...@@ -1040,6 +1043,7 @@ static void gb_lights_light_release(struct gb_light *light) ...@@ -1040,6 +1043,7 @@ static void gb_lights_light_release(struct gb_light *light)
int i; int i;
int count; int count;
light->ready = false;
count = light->channels_count; count = light->channels_count;
...@@ -1174,7 +1178,8 @@ static int gb_lights_request_handler(struct gb_operation *op) ...@@ -1174,7 +1178,8 @@ static int gb_lights_request_handler(struct gb_operation *op)
payload = request->payload; payload = request->payload;
light_id = payload->light_id; 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", dev_err(dev, "Event received for unconfigured light id: %d\n",
light_id); light_id);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment