greybus: power_supply: fix check for configured supply

The correct check for if the power supply is ready to receive event is
wrong and it should check for the registered flag.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Rui Miguel Silva 2016-01-12 14:38:21 +00:00 committed by Greg Kroah-Hartman
parent e527338104
commit adb57cff54
1 changed files with 2 additions and 1 deletions

View File

@ -697,7 +697,8 @@ static int gb_power_supply_event_recv(u8 type, struct gb_operation *op)
payload = request->payload;
psy_id = payload->psy_id;
mutex_lock(&supplies->supplies_lock);
if (psy_id >= supplies->supplies_count || !&supplies->supply[psy_id]) {
if (psy_id >= supplies->supplies_count ||
!supplies->supply[psy_id].registered) {
dev_err(&connection->bundle->dev,
"Event received for unconfigured power_supply id: %d\n",
psy_id);