linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (no subject)
@ 2014-07-09  1:03 James Ban
  2014-07-09  7:56 ` your mail Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: James Ban @ 2014-07-09  1:03 UTC (permalink / raw)
  To: Mark Brown; +Cc: Liam Girdwood, Support Opensource, LKML, David Dajun Chen

> -----Original Message-----
> From: Mark Brown [mailto:broonie@kernel.org]
> Sent: Tuesday, July 08, 2014 4:36 PM
> To: Opensource [James Seong-Won Ban]
> Cc: Liam Girdwood; Support Opensource; LKML; David Dajun Chen
> Subject: Re: [PATCH V4] regulator: DA9211 : new regulator driver
> 
> On Thu, Jul 03, 2014 at 04:29:03PM +0900, James Ban wrote:
> 
> This is greatly improved, thanks, however there are still a few issues which
> should be addressed:
> 
> > +static irqreturn_t da9211_irq_handler(int irq, void *data) {
> > +	struct da9211 *chip = data;
> > +	int reg_val, ret;
> > +
> > +	ret = regmap_read(chip->regmap, DA9211_REG_EVENT_B, &reg_val);
> > +	if (ret < 0)
> > +		goto error_i2c;
> > +
> > +	if (reg_val & DA9211_E_OV_CURR_A) {
> 
> > +	if (reg_val & DA9211_E_OV_CURR_B) {
> 
> > +
> > +	return IRQ_HANDLED;
> 
> This is buggy - the driver should only return IRQ_HANDLED if it handled the
> interrupt somehow, otherwise it should return IRQ_NONE and let the interrupt
> core handle things.  This is especially important since the device appears to
> require that interrupts are explicitly acknoweldged so if something is flagged
> but not handled the interrupt will just sit constantly asserted.
Basically all interrupts are masked when the chip wakes up. 
Only two interrupts are unmasked at the start of driver like below.
-------------
if (chip->chip_irq != 0) {
			ret = regmap_update_bits(chip->regmap,
				DA9211_REG_MASK_B, DA9211_M_OV_CURR_A << i, 1);
-----------------
So constant assertion which you are worry about could not happen.
Please let me know if you think other case.
> 
> > +static int da9211_regulator_init(struct da9211 *chip) {
> > +	struct regulator_config config = { };
> > +	int i, ret;
> > +	unsigned int data;
> > +
> > +	ret = regmap_update_bits(chip->regmap, DA9211_REG_PAGE_CON,
> > +			DA9211_REG_PAGE_MASK, DA9211_REG_PAGE2);
> > +	if (ret < 0) {
> > +		dev_err(chip->dev, "Failed to update PAGE reg: %d\n", ret);
> > +		goto err;
> > +	}
> 
> It would be better to model the paging in the register map in the regmap
> - the API has support for this, it's going to be more robust to use it.
I will change the code for the usage of the API.
> 
> > +		dev_info(chip->dev, "# IRQ configured [%d]\n", chip->chip_irq);
> 
> > +	for (i = 0; i < chip->num_regulator; i++)
> > +		regulator_unregister(chip->rdev[i]);
> 
> Use devm_regulator_register().
I will do it.
> 
> > +	if (chip->chip_irq != 0)
> > +		free_irq(chip->chip_irq, chip);
> 
> devm_request_threaded_irq().
I will use devm_request_threaded_irq and remove free_irq.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: your mail
  2014-07-09  1:03 James Ban
@ 2014-07-09  7:56 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-07-09  7:56 UTC (permalink / raw)
  To: James Ban; +Cc: Liam Girdwood, Support Opensource, LKML, David Dajun Chen

[-- Attachment #1: Type: text/plain, Size: 1145 bytes --]

On Wed, Jul 09, 2014 at 10:03:32AM +0900, James Ban wrote:

> > > +	ret = regmap_read(chip->regmap, DA9211_REG_EVENT_B, &reg_val);
> > > +	if (ret < 0)
> > > +		goto error_i2c;

> > > +	if (reg_val & DA9211_E_OV_CURR_A) {

> > > +	if (reg_val & DA9211_E_OV_CURR_B) {

> > > +	return IRQ_HANDLED;

> > This is buggy - the driver should only return IRQ_HANDLED if it handled the
> > interrupt somehow, otherwise it should return IRQ_NONE and let the interrupt
> > core handle things.  This is especially important since the device appears to
> > require that interrupts are explicitly acknoweldged so if something is flagged
> > but not handled the interrupt will just sit constantly asserted.

> Basically all interrupts are masked when the chip wakes up. 
> Only two interrupts are unmasked at the start of driver like below.

I know that's the intention but the code should still be written
robustly - something might go wrong somewhere which causes another
interrupt to be enabled, or we might even gain support for shared
threaded interrupts in the interrupt core and someone could then
try to use that in a system.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-09  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-09  1:03 James Ban
2014-07-09  7:56 ` your mail Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).