public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Samuel Ortiz <sameo@linux.intel.com>
To: MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: linux-kernel@vger.kernel.org, kyungmin.park@samsung.com,
	myungjoo.ham@gmail.com
Subject: Re: [PATCH 1/2] MAX8997/8966 MFD: Add IRQ control feature
Date: Mon, 14 Mar 2011 11:11:18 +0100	[thread overview]
Message-ID: <20110314101117.GB31153@sortiz-mobl> (raw)
In-Reply-To: <1299224747-11081-1-git-send-email-myungjoo.ham@samsung.com>

Hi MyungJoo,

On Fri, Mar 04, 2011 at 04:45:47PM +0900, MyungJoo Ham wrote:
> This patch enables IRQ handling for MAX8997/8966 chips.
> 
> Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Joe's comments make sense. Also, here are my comments:

> +static irqreturn_t max8997_irq_thread(int irq, void *data)
> +{
> +	struct max8997_dev *max8997 = data;
> +	u8 irq_reg[MAX8997_IRQ_GROUP_NR];
> +	u8 irq_src;
> +	int ret;
> +	int i;
> +
> +	ret = max8997_read_reg(max8997->i2c, MAX8997_REG_INTSRC, &irq_src);
> +	if (ret < 0) {
> +		dev_err(max8997->dev, "Failed to read interrupt source: %d\n",
> +				ret);
> +		return IRQ_NONE;
> +	}
> +
> +	for (i = 0; i < MAX8997_IRQ_GROUP_NR; i++)
> +		irq_reg[i] = 0;
> +
> +	if (irq_src & (1 << 1)) {
All the (1 << n) parts could be nicely replaced with relevant #define. That
would make your code more readable.



> +		/* PMIC INT1 ~ INT4 */
> +		max8997_bulk_read(max8997->i2c, MAX8997_REG_INT1, 4,
> +				&irq_reg[PMIC_INT1]);
> +	}
> +	if (irq_src & (1 << 2)) {
> +		/* FUEL GAUGE Interrupt */
> +		/* Ignored */
> +		irq_reg[FUEL_GAUGE] = 0;
> +	}
> +	if (irq_src & (1 << 3)) {
> +		/* MUIC INT1 ~ INT3 */
> +		max8997_bulk_read(max8997->muic, MAX8997_MUIC_REG_INT1, 3,
> +				&irq_reg[MUIC_INT1]);
> +	}
> +	if (irq_src & (1 << 4)) {
> +		/* GPIO Interrupt */
> +		u8 gpio_info[12];
> +		int gpio;
> +
> +		irq_reg[GPIO_LOW] = 0;
> +		irq_reg[GPIO_HI] = 0;
> +
> +		max8997_bulk_read(max8997->i2c, MAX8997_REG_GPIOCNTL1, 12,
> +				gpio_info);
> +		for (gpio = 0; gpio < 8; gpio++) {
> +			u8 val = gpio_info[gpio] & 0x34;
> +			if (((val & 0x30) == 0x30) ||
> +					(val == 0x10) ||
> +					(val == 0x24))
There are a lot of magic constants here, and I'd love to see that replaced as
well with some more descriptive macros.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

  parent reply	other threads:[~2011-03-14 10:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04  6:50 [PATCH v2 0/2] MAX8997/8966 MFD (includig PMIC) Initial Release MyungJoo Ham
2011-03-04  6:50 ` [PATCH v2 1/2] MAX8997/8966 MFD Driver Initial Release (PMIC+RTC+MUIC+Haptic+...) MyungJoo Ham
2011-03-05 11:31   ` Mark Brown
2011-03-04  6:50 ` [PATCH v2 2/2] MAX8997/8966 PMIC Regulator Driver Initial Release MyungJoo Ham
2011-03-04  7:16   ` [PATCH] MAX8997/8966 PMIC: compiler warning removed (incompatible pointer) MyungJoo Ham
2011-03-05 12:03   ` [PATCH v2 2/2] MAX8997/8966 PMIC Regulator Driver Initial Release Mark Brown
2011-03-08  1:50     ` MyungJoo Ham
2011-03-08 12:41       ` Mark Brown
2011-03-04  7:45 ` [PATCH 1/2] MAX8997/8966 MFD: Add IRQ control feature MyungJoo Ham
2011-03-04  8:58   ` Joe Perches
2011-03-14 10:11   ` Samuel Ortiz [this message]
2011-03-14 10:37     ` MyungJoo Ham
2011-03-04  7:48 ` [PATCH 2/2] MAX8997/8966 RTC Driver Initial Release MyungJoo Ham
2011-03-04  8:58   ` Joe Perches
2011-03-05 12:07   ` [rtc-linux] " Mark Brown
2011-03-14  9:49 ` [PATCH v2 0/2] MAX8997/8966 MFD (includig PMIC) " Samuel Ortiz

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=20110314101117.GB31153@sortiz-mobl \
    --to=sameo@linux.intel.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox