@@ -111,6 +111,7 @@ struct sc27xx_fgu_data {
111
111
static int sc27xx_fgu_cap_to_clbcnt (struct sc27xx_fgu_data * data , int capacity );
112
112
static void sc27xx_fgu_capacity_calibration (struct sc27xx_fgu_data * data ,
113
113
int cap , bool int_mode );
114
+ static void sc27xx_fgu_adjust_cap (struct sc27xx_fgu_data * data , int cap );
114
115
115
116
static const char * const sc27xx_charger_supply_name [] = {
116
117
"sc2731_charger" ,
@@ -610,17 +611,25 @@ static int sc27xx_fgu_set_property(struct power_supply *psy,
610
611
struct sc27xx_fgu_data * data = power_supply_get_drvdata (psy );
611
612
int ret ;
612
613
613
- if (psp != POWER_SUPPLY_PROP_CAPACITY )
614
- return - EINVAL ;
615
-
616
614
mutex_lock (& data -> lock );
617
615
618
- ret = sc27xx_fgu_save_last_cap (data , val -> intval );
616
+ switch (psp ) {
617
+ case POWER_SUPPLY_PROP_CAPACITY :
618
+ ret = sc27xx_fgu_save_last_cap (data , val -> intval );
619
+ if (ret < 0 )
620
+ dev_err (data -> dev , "failed to save battery capacity\n" );
621
+ break ;
619
622
620
- mutex_unlock (& data -> lock );
623
+ case POWER_SUPPLY_PROP_CALIBRATE :
624
+ sc27xx_fgu_adjust_cap (data , val -> intval );
625
+ ret = 0 ;
626
+ break ;
621
627
622
- if (ret < 0 )
623
- dev_err (data -> dev , "failed to save battery capacity\n" );
628
+ default :
629
+ ret = - EINVAL ;
630
+ }
631
+
632
+ mutex_unlock (& data -> lock );
624
633
625
634
return ret ;
626
635
}
@@ -635,7 +644,8 @@ static void sc27xx_fgu_external_power_changed(struct power_supply *psy)
635
644
static int sc27xx_fgu_property_is_writeable (struct power_supply * psy ,
636
645
enum power_supply_property psp )
637
646
{
638
- return psp == POWER_SUPPLY_PROP_CAPACITY ;
647
+ return psp == POWER_SUPPLY_PROP_CAPACITY ||
648
+ psp == POWER_SUPPLY_PROP_CALIBRATE ;
639
649
}
640
650
641
651
static enum power_supply_property sc27xx_fgu_props [] = {
@@ -651,6 +661,7 @@ static enum power_supply_property sc27xx_fgu_props[] = {
651
661
POWER_SUPPLY_PROP_CURRENT_AVG ,
652
662
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE ,
653
663
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN ,
664
+ POWER_SUPPLY_PROP_CALIBRATE ,
654
665
};
655
666
656
667
static const struct power_supply_desc sc27xx_fgu_desc = {
0 commit comments