More cleanups for sharpsl_pm.c
Subsystems (3)
Hi!
sharpsl.c uses macros to hide method calls, in quite a confusing way. This just inlines the macros, so it is easy to see what is going on.
arch/arm/mach-pxa/sharpsl.h +0 -8
@@ -108,14 +108,6 @@ extern struct battery_thresh spitz_batte#define SHARPSL_LED_ON 1#define SHARPSL_LED_OFF 0 -#define CHARGE_ON () sharpsl_pm.machinfo->charge(1) -#define CHARGE_OFF () sharpsl_pm.machinfo->charge(0) -#define CHARGE_LED_ON () sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ON) -#define CHARGE_LED_OFF () sharpsl_pm.machinfo->chargeled(SHARPSL_LED_OFF) -#define CHARGE_LED_ERR () sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ERROR) -#define DISCHARGE_ON () sharpsl_pm.machinfo->discharge(1) -#define DISCHARGE_OFF () sharpsl_pm.machinfo->discharge(0) -#define STATUS_AC_IN () sharpsl_pm.machinfo->status_acin()#define STATUS_BATT_LOCKED () READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock)#define STATUS_CHRG_FULL () READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull)#define STATUS_FATAL () READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal)
arch/arm/mach-pxa/sharpsl_pm.c +35 -33
183 lines not on this page · raw message
arch/arm/mach-pxa/spitz_pm.c +6 -5
@@ -81,7 +81,7 @@ static void spitz_discharge1(int on)static void spitz_presuspend (void ) { - spitz_last_ac_status =STATUS_AC_IN (); + spitz_last_ac_status = sharpsl_pm.machinfo->status_acin ();/* GPIO Sleep Register */ PGSR0 =0x00144018 ;
@@ -129,17 +129,18 @@ static void spitz_postsuspend(void)static int spitz_should_wakeup (unsigned int resume_on_alarm) {int is_resume =0 ; +int acin = sharpsl_pm.machinfo->status_acin (); -if (spitz_last_ac_status !=STATUS_AC_IN ()) { -if (STATUS_AC_IN ()) { +if (spitz_last_ac_status != acin) { +if (acin) {/* charge on */ sharpsl_pm.flags |=SHARPSL_DO_OFFLINE_CHRG ;dev_dbg (sharpsl_pm.dev,"AC Inserted\n" ); }else {/* charge off */ dev_dbg (sharpsl_pm.dev,"AC Removed\n" ); -CHARGE_LED_OFF (); -CHARGE_OFF (); + sharpsl_pm.machinfo->chargeled (SHARPSL_LED_OFF ); + sharpsl_pm.machinfo->charge (0 ); sharpsl_pm.charge_mode =CHRG_OFF ; }/* Return to suspend as this must be what we were woken for */
Signature · 1 line
Thanks, Sharp!
Quoted 3 lines · Pavel Machek
sharpsl.cuses macros to hide method calls, in quite a confusing way. This just inlines the macros, so it is easy to see what is going on.
I'm not totally convinced this makes it easier to read. To me, CHARGE_ON(); is more readable than sharpsl_pm.machinfo->charge(1);. Yes, you need to look up what the macro does but the names give a fairly good idea.
ALso, keeping the macros means when I implement the LED trigger for charging, I don't have to edit every function in sharpsl_pm but can just tweak the header and add an extra level of LED functions. Given that, I'd prefer to leave these as they are for now.
arch/arm/mach-pxa/sharpsl_pm.c static int get_percentage(int voltage) · line 222
Quoted 6 lines
arch/arm/mach-pxa/sharpsl_pm.c +3
-0+/* FIXME: +why not simply get_percentage, and base it off that? +*/ if (sharpsl_pm.charge_mode ==CHRG_ON ) { high_thresh = sharpsl_pm.machinfo->status_high_acin; low_thresh = sharpsl_pm.machinfo->status_low_acin;
The percentage curves is likely to change in the future and I doubt anyone would remember to update these values. I'd therefore prefer for them to be independent of the lookup table.
(The table will change once I get more discharge profiles from users and can work out a more accurate discharge curve).
Richard
Hi!
Quoted 8 lines
Quoted 3 lines
sharpsl.cuses macros to hide method calls, in quite a confusing way. This just inlines the macros, so it is easy to see what is going on.I'm not totally convinced this makes it easier to read. To me,
CHARGE_ON(); is more readable thansharpsl_pm.machinfo->charge(1);. Yes, you need to look up what the macro does but the names give a fairly good idea.
I'm quite convinced it is easier to read...
Quoted 4 lines
ALso, keeping the macros means when I implement the LED trigger for charging, I don't have to edit every function in
sharpsl_pmbut can just tweak the header and add an extra level of LED functions. Given that, I'd prefer to leave these as they are for now.
...but if this code still changes rapidly, it can probably wait.
Quoted 10 lines
arch/arm/mach-pxa/sharpsl_pm.c static int get_percentage(int voltage) · line 222
Quoted 6 lines
arch/arm/mach-pxa/sharpsl_pm.c +3
-0+/* FIXME: +why not simply get_percentage, and base it off that? +*/ if (sharpsl_pm.charge_mode ==CHRG_ON ) { high_thresh = sharpsl_pm.machinfo->status_high_acin; low_thresh = sharpsl_pm.machinfo->status_low_acin;The percentage curves is likely to change in the future and I doubt anyone would remember to update these values. I'd therefore prefer for them to be independent of the lookup table.
Well, apm status is not quite critical, right? And if 5% is remaining, it *is* low battery; if that gets more precise over time, that is okay.
Pavel
Signature · 1 line
Thanks, Sharp!