From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Ashish Jangam <Ashish.Jangam@kpitcummins.com>
Cc: "cbou@mail.ru" <cbou@mail.ru>,
"dwmw2@infradead.org" <dwmw2@infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCHv1 4/11] Power: Battery module of DA9052 PMIC driver
Date: Wed, 20 Apr 2011 16:37:22 +0100 [thread overview]
Message-ID: <20110420153722.GC9869@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <E2CAE7F7B064EA49B5CE7EE9A4BB167D151B4AC1AE@KCINPUNHJCMS01.kpit.com>
On Wed, Apr 06, 2011 at 06:28:03PM +0530, Ashish Jangam wrote:
> +static u16 filter_sample(u16 *buffer)
> +{
> + u8 count;
> + u16 tempvalue = 0;
> + u16 ret;
> +
> + if (buffer == NULL)
> + return -EINVAL;
> +
> + for (count = 0; count < DA9052_FILTER_SIZE; count++)
> + tempvalue = tempvalue + *(buffer + count);
> +
> + ret = tempvalue/DA9052_FILTER_SIZE;
> + return ret;
It's probably as well to pass the size of buffer in as an argument so
that it's less surprising that you don't handle a partially filled
buffer.
You probably want to call this _average() or something, it's not
actually doing any filtering, it's just taking an average. This is
perfectly sensible but it's a bit confusing.
> +static irqreturn_t da9052_tbat_irq(int irq, void *data)
> +{
> + struct da9052_charger_device *chg_device =
> + (struct da9052_charger_device *)data;
> +
> + chg_device->health = POWER_SUPPLY_HEALTH_OVERHEAT;
> +
> + return IRQ_HANDLED;
> +}
Shouldn't you also be telling the core about the status change so it can
go notify userspace?
> +/* STATIC CONFIGURATION */
> +#define DA9052_LOOK_UP_TABLE_SIZE 68
> +#define DA9052_NO_OF_LOOKUP_TABLE 3
> +#define DA9052_FILTER_SIZE 4
> +#define DA9052_NUMBER_OF_STORE_CURENT_READING 4
> +static u32 const vbat_vs_capacity_look_up[DA9052_NO_OF_LOOKUP_TABLE]
> + [DA9052_LOOK_UP_TABLE_SIZE][2] = {
You probably want to be using ARRAY_SIZE() for some of this.
next prev parent reply other threads:[~2011-04-20 15:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-06 12:58 [PATCHv1 4/11] Power: Battery module of DA9052 PMIC driver Ashish Jangam
2011-04-20 15:37 ` Mark Brown [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-04-13 11:58 Ashish Jangam
2011-04-13 12:48 ` Anton Vorontsov
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=20110420153722.GC9869@opensource.wolfsonmicro.com \
--to=broonie@opensource.wolfsonmicro.com \
--cc=Ashish.Jangam@kpitcummins.com \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.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 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.