All of lore.kernel.org
 help / color / mirror / Atom feed
From: jonghwa3.lee@samsung.com
To: Anton Vorontsov <anton@enomsg.org>
Cc: linux-pm@vger.kernel.org, dwmw2@infradead.org,
	myungjoo.ham@samsung.com, cw00.choi@samsung.com
Subject: Re: [PATCH 2/3] charger-manager : Add default battery temperature checking funtion.
Date: Mon, 28 Oct 2013 11:26:18 +0900	[thread overview]
Message-ID: <526DCB4A.5010009@samsung.com> (raw)
In-Reply-To: <20131025234436.GC13859@teo>

On 2013년 10월 26일 08:44, Anton Vorontsov wrote:

> On Fri, Oct 25, 2013 at 11:47:32AM +0900, Jonghwa Lee wrote:
>> During the charger manager driver's probing time, it can't succeed
>> if there's no pre-defined .temperature_out_of_range callback function.
>> But if fuel gauge supports battery temperature measurement, we
>> can use it directly. That's what cm_default_get_temp() function does.
>>
>> With flag measure_batter_temp ON, we normally use cm_default_get_temp()
>> for .temperature_out_of_range callback funtion.
>> The TEMP_AMBIENT property is only used for pre-defined one.
>>
>> Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
>> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
>> ---
> ...
>> +static int cm_default_get_temp(struct charger_manager *cm)
>> +{
>> +	struct charger_desc *desc = cm->desc;
>> +	union power_supply_propval val;
>> +	static int temp_alert_min = 0;
> 
> No. Never.


Can I assume that you worried about initialization of a variable which would be
used to hold minimum value to zero not INT_MAX or something big?
Anyway, come to think of it, it looks ugly for me either. I'll fix it.

> 
>> +	static int temp_alert_max = 0;
>> +	static int temp_alert_diff = 0;
>> +	static int last_temp_status = 0;
>> +	int ret;
>> +
>> +	if (!temp_alert_min && !temp_alert_max) {
>> +		/* Initialize minimum temperature for alert */
>> +		ret = cm->fuel_gauge->get_property(cm->fuel_gauge,
>> +					POWER_SUPPLY_PROP_TEMP_ALERT_MIN,
>> +					&val);
>> +		temp_alert_min = ret ? desc->temp_alert_min :
>> +					min(desc->temp_alert_min, val.intval);
> 
> Is it a minimum temperature of a bettery below which we should alert?
> Should it be max() then?


Yes, you're right. I'll fix it.

> 
>> +		if (!temp_alert_min)
>> +			temp_alert_min = CM_DEFAULT_TEMP_ALERT_MIN;
> 
> The whole function is ugly as hell.  Please tidy it up, split it into two,
> three or whatever amount needed to make it readable and comprehendable.
> Use temporary variables for things like
> cm->fuel_gauge->get_property(cm->fuel_gauge, ....).
> 


Okay, I'll re-post it.

Thanks for comments
Jonghwa.

>> +
>> +		/* Initialize maximum temperature for alert */
>> +		ret = cm->fuel_gauge->get_property(cm->fuel_gauge,
>> +					POWER_SUPPLY_PROP_TEMP_ALERT_MAX,
>> +					&val);
>> +		temp_alert_max = ret ? desc->temp_alert_max :
>> +					min(desc->temp_alert_max, val.intval);
> 
> Thanks,
> 
> Anton
> 



  reply	other threads:[~2013-10-28  2:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25  2:47 [PATCH 0/3] Update charger manager driver to support device tree Jonghwa Lee
2013-10-25  2:47 ` [PATCH 1/3] charger-manager : Replace kzalloc to devm_kzalloc and remove uneccessary code Jonghwa Lee
2013-10-25 23:30   ` Anton Vorontsov
2013-10-28  2:01     ` jonghwa3.lee
2013-10-25  2:47 ` [PATCH 2/3] charger-manager : Add default battery temperature checking funtion Jonghwa Lee
2013-10-25 23:44   ` Anton Vorontsov
2013-10-28  2:26     ` jonghwa3.lee [this message]
2013-10-28  6:31       ` Anton Vorontsov
2013-10-25  2:47 ` [PATCH 3/3] charger-manager : Support deivce tree in charger manager driver Jonghwa Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=526DCB4A.5010009@samsung.com \
    --to=jonghwa3.lee@samsung.com \
    --cc=anton@enomsg.org \
    --cc=cw00.choi@samsung.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.