From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: ashishj3 <ashish.jangam@kpitcummins.com>
Cc: linaro-dev@lists.linaro.org, cbou@mail.ru, dwmw2@infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [Patch v1 04/11]Power: DA9052 battery driver
Date: Fri, 15 Jul 2011 09:57:54 +0900 [thread overview]
Message-ID: <20110715005749.GA2760@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1310633828.284.88.camel@L-0532.kpit.com>
On Thu, Jul 14, 2011 at 02:27:08PM +0530, ashishj3 wrote:
> +static inline int volt_reg_to_mV(int value)
> + { return ((value*1000) / 512) + 2500; }
> +static inline int ichg_reg_to_mA(int value)
> + { return ((value * 3900) / 1000); }
It'd be better to use the standard coding style for this stuff.
> +static int da9052_battery_read_temperature(struct da9052_battery *battery,
> + int *bat_temp)
> +{
> + int count, avg_value[DA9052_AVERAGE_SIZE];
> +
> + for (count = 0; count < DA9052_AVERAGE_SIZE; count++)
> + avg_value[count] = da9052_adc_temperature_read(battery->da9052);
> + if (avg_value[count] < 0)
> + return avg_value[count];
> +
> + *bat_temp = da9052_average_calcuation(avg_value);
> +
> + return 0;
> +}
Don't do this, just return the reading let something higher up the stack
figure out if it needs to take an average reading. Probably userspace.
This isn't specific to this device, if we need to do something in the
kernel it should be a core feature but I'd expect userspace can do a
better job by looking at longer term trends.
> +static struct power_supply template_battery = {
> + .name = "da9052-bat",
> + .type = POWER_SUPPLY_TYPE_BATTERY,
> + .properties = da9052_bat_props,
> + .num_properties = ARRAY_SIZE(da9052_bat_props),
> + .get_property = da9052_bat_get_property,
> + .use_for_apm = 1,
> +};
Hrm, use_for_apm isn't typically set by embedded battery drivers so
probably shouldn't be set by this one. We should figure out some better
way to set this, perhaps board specific, if it's needed.
prev parent reply other threads:[~2011-07-15 2:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-14 8:57 [Patch v1 04/11]Power: DA9052 battery driver ashishj3
2011-07-15 0:57 ` Mark Brown [this message]
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=20110715005749.GA2760@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=ashish.jangam@kpitcummins.com \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.org \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox