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>
u8 channels_count;
struct gb_channel *channels;
bool has_flash;
+ bool ready;
#ifdef V4L2_HAVE_FLASH
struct v4l2_flash *v4l2_flash;
#endif
return ret;
}
+ light->ready = true;
+
if (light->has_flash) {
ret = gb_lights_light_v4l2_register(light);
if (ret < 0) {
int i;
int count;
+ light->ready = false;
count = light->channels_count;
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;