Re: [PATCH] mfd/stmpe: Add support for no-interrupt config

From: Viresh Kumar
Date: Tue Jan 24 2012 - 06:34:22 EST


On 1/24/2012 3:48 PM, Linus WALLEIJ wrote:
> From: Chris Blair <chris.blair@xxxxxxxxxxxxxx>
>
> Adds support for boards which have an STMPE device without the
> interrupt pin connected.
>
> Cc: Viresh Kumar <viresh.kumar@xxxxxx>
> Signed-off-by: Chris Blair <chris.blair@xxxxxxxxxxxxxx>
> Tested-by: Michel Jaouen <michel.jaouen@xxxxxxxxxxxxxx>
> Reviewed-by: Srinidhi Kasagar <srinidhi.kasagar@xxxxxxxxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---
> drivers/mfd/stmpe.c | 72 +++++++++++++++++++++++++--------------------
> include/linux/mfd/stmpe.h | 2 +
> 2 files changed, 42 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c

> @@ -988,7 +990,7 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
> if (ci->init)
> ci->init(stmpe);
>
> - if (pdata->irq_over_gpio) {
> + if (!pdata->no_irq && pdata->irq_over_gpio) {
> ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe");
> if (ret) {
> dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",

[I will add the actual code present here after this change to describe the concern]

if (!pdata->no_irq && pdata->irq_over_gpio) {
ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe");
if (ret) {
dev_err(stmpe->dev, "failed to request IRQ GPIO: %d\n",
ret);
goto out_free;
}

stmpe->irq = gpio_to_irq(pdata->irq_gpio);
} else {
stmpe->irq = ci->irq;
}

Actually you want neither of them to work for no_irq case, if and else.
But with this code, if you pass no_irq = true, then else part will get called.

> @@ -1005,15 +1007,21 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
> if (ret)
> goto free_gpio;
>
> - ret = stmpe_irq_init(stmpe);
> - if (ret)
> - goto free_gpio;
> + if (pdata->no_irq) {
> + dev_info(stmpe->dev,
> + "board config says IRQs are not supported\n");
> + } else {
> + ret = stmpe_irq_init(stmpe);
> + if (ret)
> + goto free_gpio;
>

There are few more cases to handle in error part of probe and remove, where
following routines are called.

free_irq(stmpe->irq, stmpe);
stmpe_irq_remove(stmpe);
if (pdata->irq_over_gpio)
gpio_free(pdata->irq_gpio);

--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/