Re: [PATCH 1/4] mfd: max14577: Add max14577 MFD driver core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi,

On Wed, 2013-11-13 at 13:13 +0000, Mark Brown wrote:
> On Wed, Nov 13, 2013 at 08:40:54AM +0100, Krzysztof Kozlowski wrote:
> 
> > +/**
> > + * After resuming from suspend it may happen that IRQ is signalled but
> > + * IRQ GPIO is not high. Also the interrupt registers won't have any data
> > + * (all of them equal to 0x00).
> > + *
> > + * In such case retry few times reading the interrupt registers.
> > + */
> > +#define IRQ_READ_REG_RETRY_CNT		5
> 
> What is the cause here?  This smells like an unreliable workaround for
> some other behaviour.  In general this all looks very like standard
> regmap code.
> 
> > +	for (i = 0; i < MAX14577_IRQ_REGS_NUM; i++) {
> > +		u8 mask_reg = max14577_mask_reg[i];
> > +
> > +		if (mask_reg == MAX14577_REG_INVALID ||
> > +				IS_ERR_OR_NULL(max14577->regmap))
> > +			continue;
> 
> Why would this code even be running if you don't have a register map?
> 
> > +		dev_info(max14577->dev, "Got interrupts [1:0x%02x, 2:0x%02x, 3:0x%02x]\n",
> > +			irq_reg[MAX14577_IRQ_INT1], irq_reg[MAX14577_IRQ_INT2],
> > +			irq_reg[MAX14577_IRQ_INT3]);
> 
> This is far too noisy, dev_dbg() at most.
> 
> > +		gpio_val = gpio_get_value(pdata->irq_gpio);
> > +
> > +		if (gpio_get_value(pdata->irq_gpio) == 0)
> > +			dev_warn(max14577->dev, "IRQ GPIO is not high, retry reading interrupt registers\n");
> > +	} while (gpio_val == 0 && --retry > 0);
> 
> This looks very strange...
> 
> > +	max14577->irq = gpio_to_irq(pdata->irq_gpio);
> > +	ret = gpio_request(pdata->irq_gpio, "max14577_irq");
> > +	if (ret) {
> > +		dev_err(max14577->dev, "Failed requesting GPIO %d: %d\n",
> > +				pdata->irq_gpio, ret);
> > +		goto err;
> > +	}
> > +	gpio_direction_input(pdata->irq_gpio);
> > +	gpio_free(pdata->irq_gpio);
> 
> This means the GPIO handling code that was present in the handling is
> broken, it's trying to use the GPIO after it was freed.
> 
> > +	ret = request_threaded_irq(max14577->irq, NULL, max14577_irq_thread,
> > +				   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
> > +				   "max14577-irq", max14577);
> 
> Are you *positive* this is a falling triggered IRQ?  All the code to do
> with spinning reading the GPIO state during handling makes it look like
> this is in fact an active low interrupt and a lot of the code in here is
> working around trying to handle that as the wrong kind of IRQ.
> 
> > +int max14577_bulk_write(struct regmap *map, u8 reg, u8 *buf, int count)
> > +{
> > +	return regmap_bulk_write(map, reg, buf, count);
> > +}
> > +EXPORT_SYMBOL_GPL(max14577_bulk_write);
> 
> Given that these are basically all trivial wrappers around regmap they
> probably ought to be static inlines in the header.
> 
> > +static struct max14577_platform_data *max14577_i2c_parse_dt(struct device *dev)
> > +{
> 
> There's no DT binding document?
> 
> > +const struct dev_pm_ops max14577_pm = {
> > +	.suspend = max14577_suspend,
> > +	.resume = max14577_resume,
> > +};
> 
> SET_SYSTEM_SLEEP_PM_OPS().
> 
> > +static int __init max14577_i2c_init(void)
> > +{
> > +	return i2c_add_driver(&max14577_i2c_driver);
> > +}
> > +subsys_initcall(max14577_i2c_init);
> 
> Why not module_i2c_driver?

Thanks for review. I'll the fix issues and send later new version of
patch.

Best regards,
Krzysztof

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux