EDP: psy depletion: allow null rbat lut
Sivaram Nair [Wed, 29 May 2013 17:50:29 +0000 (20:50 +0300)]
For boards that do not specify an rbat lut, use the r_const as the
RBAT.

Change-Id: Ica8045c65fed34b48f2b89a5be4bc1435320924f
Signed-off-by: Sivaram Nair <sivaramn@nvidia.com>
Reviewed-on: http://git-master/r/233805
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>

drivers/edp/psy_depletion.c

index d9eeac5..e26c97f 100644 (file)
@@ -89,21 +89,22 @@ static int depl_rbat(struct depl_driver *drv)
        unsigned int capacity;
        int rbat;
 
+       rbat = drv->pdata->r_const;
        capacity = depl_psy_capacity(drv);
        p = drv->pdata->rbat_lut;
+       if (!p)
+               return rbat;
 
        while (p->capacity > capacity)
                p++;
 
        if (p == drv->pdata->rbat_lut)
-               return p->rbat;
+               return rbat + p->rbat;
 
        q = p - 1;
 
-       rbat = depl_interpolate(capacity, p->capacity, p->rbat,
+       rbat += depl_interpolate(capacity, p->capacity, p->rbat,
                        q->capacity, q->rbat);
-       rbat += drv->pdata->r_const;
-
        pr_debug("capacity : %u\n", capacity);
        pr_debug("rbat     : %d\n", rbat);