greybus: power_supply: fix check for configured supply
authorRui Miguel Silva <rui.silva@linaro.org>
Tue, 12 Jan 2016 14:38:21 +0000 (14:38 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 12 Jan 2016 19:21:35 +0000 (11:21 -0800)
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>
drivers/staging/greybus/power_supply.c

index d985e13b5a0de545074668a9d41c8874beb83cc4..2dc193a081b0a821464dc466ff52b5cc3f57d36b 100644 (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);