* [PATCH] pinctrl: st: Fix Sparse error @ 2014-09-29 13:48 Pramod Gurav 2014-09-29 13:47 ` Patrice Chotard 2014-09-29 14:46 ` Srinivas Kandagatla 0 siblings, 2 replies; 7+ messages in thread From: Pramod Gurav @ 2014-09-29 13:48 UTC (permalink / raw) To: linux-kernel Cc: Pramod Gurav, Maxime Coquelin, Patrice Chotard, Linus Walleij, Srinivas Kandagatla This change fixes below sparse error, drivers/pinctrl/pinctrl-st.c:1515:31: error: incompatible types for operation (>) drivers/pinctrl/pinctrl-st.c:1515:31: left side has type void [noderef] <asn:2>*irqmux_base drivers/pinctrl/pinctrl-st.c:1515:31: right side has type int The fix is done by removing a check on info->irqmux_base as info->irqmux_base has already been checked for error when allocating it. Hence there is no need to redo the check. Cc: Maxime Coquelin <maxime.coquelin@st.com> Cc: Patrice Chotard <patrice.chotard@st.com> CC: Linus Walleij <linus.walleij@linaro.org> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com> --- drivers/pinctrl/pinctrl-st.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 5475374..ddeaeda 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, gpio_irq, st_gpio_irq_handler); } - if (info->irqmux_base > 0 || gpio_irq > 0) { + if (gpio_irq > 0) { err = gpiochip_irqchip_add(&bank->gpio_chip, &st_gpio_irqchip, 0, handle_simple_irq, IRQ_TYPE_LEVEL_LOW); -- 1.7.9.5 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: st: Fix Sparse error 2014-09-29 13:48 [PATCH] pinctrl: st: Fix Sparse error Pramod Gurav @ 2014-09-29 13:47 ` Patrice Chotard 2014-09-29 14:46 ` Srinivas Kandagatla 1 sibling, 0 replies; 7+ messages in thread From: Patrice Chotard @ 2014-09-29 13:47 UTC (permalink / raw) To: Pramod Gurav, linux-kernel Cc: Maxime Coquelin, Linus Walleij, Srinivas Kandagatla Hi Pramod On 09/29/2014 03:48 PM, Pramod Gurav wrote: > This change fixes below sparse error, > drivers/pinctrl/pinctrl-st.c:1515:31: error: incompatible types for operation (>) > drivers/pinctrl/pinctrl-st.c:1515:31: left side has type void [noderef] <asn:2>*irqmux_base > drivers/pinctrl/pinctrl-st.c:1515:31: right side has type int > > The fix is done by removing a check on info->irqmux_base as > info->irqmux_base has already been checked for error when allocating it. > Hence there is no need to redo the check. > > Cc: Maxime Coquelin <maxime.coquelin@st.com> > Cc: Patrice Chotard <patrice.chotard@st.com> > CC: Linus Walleij <linus.walleij@linaro.org> > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com> > --- > drivers/pinctrl/pinctrl-st.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c > index 5475374..ddeaeda 100644 > --- a/drivers/pinctrl/pinctrl-st.c > +++ b/drivers/pinctrl/pinctrl-st.c > @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, > gpio_irq, st_gpio_irq_handler); > } > > - if (info->irqmux_base > 0 || gpio_irq > 0) { > + if (gpio_irq > 0) { > err = gpiochip_irqchip_add(&bank->gpio_chip, &st_gpio_irqchip, > 0, handle_simple_irq, > IRQ_TYPE_LEVEL_LOW); Acked-by: Patrice Chotard <patrice.chotard@st.com> Thanks ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: st: Fix Sparse error 2014-09-29 13:48 [PATCH] pinctrl: st: Fix Sparse error Pramod Gurav 2014-09-29 13:47 ` Patrice Chotard @ 2014-09-29 14:46 ` Srinivas Kandagatla 2014-09-29 15:05 ` Pramod Gurav 2014-09-29 15:09 ` Daniel Thompson 1 sibling, 2 replies; 7+ messages in thread From: Srinivas Kandagatla @ 2014-09-29 14:46 UTC (permalink / raw) To: Pramod Gurav, linux-kernel Cc: Maxime Coquelin, Patrice Chotard, Linus Walleij On 29/09/14 14:48, Pramod Gurav wrote: > This change fixes below sparse error, > drivers/pinctrl/pinctrl-st.c:1515:31: error: incompatible types for operation (>) > drivers/pinctrl/pinctrl-st.c:1515:31: left side has type void [noderef] <asn:2>*irqmux_base > drivers/pinctrl/pinctrl-st.c:1515:31: right side has type int > > The fix is done by removing a check on info->irqmux_base as > info->irqmux_base has already been checked for error when allocating it. > Hence there is no need to redo the check. > > Cc: Maxime Coquelin <maxime.coquelin@st.com> > Cc: Patrice Chotard <patrice.chotard@st.com> > CC: Linus Walleij <linus.walleij@linaro.org> > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> > Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com> > --- > drivers/pinctrl/pinctrl-st.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c > index 5475374..ddeaeda 100644 > --- a/drivers/pinctrl/pinctrl-st.c > +++ b/drivers/pinctrl/pinctrl-st.c > @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, > gpio_irq, st_gpio_irq_handler); > } > > - if (info->irqmux_base > 0 || gpio_irq > 0) { > + if (gpio_irq > 0) { > err = gpiochip_irqchip_add(&bank->gpio_chip, &st_gpio_irqchip, > 0, handle_simple_irq, > IRQ_TYPE_LEVEL_LOW); This is not the correct fix. Please see why irqmux_base and gpio_irq are used in the driver. You are breaking the logic here... please read the below comment from the code. /** * GPIO bank can have one of the two possible types of * interrupt-wirings. * * First type is via irqmux, single interrupt is used by multiple * gpio banks. This reduces number of overall interrupts numbers * required. All these banks belong to a single pincontroller. * _________ * | |----> [gpio-bank (n) ] * | |----> [gpio-bank (n + 1)] * [irqN]-- | irq-mux |----> [gpio-bank (n + 2)] * | |----> [gpio-bank (... )] * |_________|----> [gpio-bank (n + 7)] * * Second type has a dedicated interrupt per each gpio bank. * * [irqN]----> [gpio-bank (n)] */ so irqmux_base is first type and gpio_irq is second type. if you remove check for irqmux_base here you would end up NOT adding irqchip the gpiochip in first type so you break the existing logic here. I think the correct fix is: diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 5475374..4060c30 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl *info, gpio_irq, st_gpio_irq_handler); } - if (info->irqmux_base > 0 || gpio_irq > 0) { + if (!IS_ERR(info->irqmux_base) || gpio_irq > 0) { err = gpiochip_irqchip_add(&bank->gpio_chip, &st_gpio_irqchip, 0, handle_simple_irq, IRQ_TYPE_LEVEL_LOW); Thanks, srini ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: st: Fix Sparse error 2014-09-29 14:46 ` Srinivas Kandagatla @ 2014-09-29 15:05 ` Pramod Gurav 2014-09-29 15:38 ` Srinivas Kandagatla 2014-09-29 15:09 ` Daniel Thompson 1 sibling, 1 reply; 7+ messages in thread From: Pramod Gurav @ 2014-09-29 15:05 UTC (permalink / raw) To: Srinivas Kandagatla Cc: Pramod Gurav, linux-kernel@vger.kernel.org, Maxime Coquelin, Patrice Chotard, Linus Walleij Hi Srini, Thanks for review. On Mon, Sep 29, 2014 at 8:16 PM, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote: > On 29/09/14 14:48, Pramod Gurav wrote: >> >> This change fixes below sparse error, >> drivers/pinctrl/pinctrl-st.c:1515:31: error: incompatible types for >> operation (>) >> drivers/pinctrl/pinctrl-st.c:1515:31: left side has type void [noderef] >> <asn:2>*irqmux_base >> drivers/pinctrl/pinctrl-st.c:1515:31: right side has type int >> >> The fix is done by removing a check on info->irqmux_base as >> info->irqmux_base has already been checked for error when allocating it. >> Hence there is no need to redo the check. >> >> Cc: Maxime Coquelin <maxime.coquelin@st.com> >> Cc: Patrice Chotard <patrice.chotard@st.com> >> CC: Linus Walleij <linus.walleij@linaro.org> >> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> >> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com> >> --- >> drivers/pinctrl/pinctrl-st.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c >> index 5475374..ddeaeda 100644 >> --- a/drivers/pinctrl/pinctrl-st.c >> +++ b/drivers/pinctrl/pinctrl-st.c >> @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct >> st_pinctrl *info, >> gpio_irq, >> st_gpio_irq_handler); >> } >> >> - if (info->irqmux_base > 0 || gpio_irq > 0) { >> + if (gpio_irq > 0) { >> err = gpiochip_irqchip_add(&bank->gpio_chip, >> &st_gpio_irqchip, >> 0, handle_simple_irq, >> IRQ_TYPE_LEVEL_LOW); > > > This is not the correct fix. Please see why irqmux_base and gpio_irq are > used in the driver. > You are breaking the logic here... > > please read the below comment from the code. > > /** > * GPIO bank can have one of the two possible types of > * interrupt-wirings. > * > * First type is via irqmux, single interrupt is used by multiple > * gpio banks. This reduces number of overall interrupts numbers > * required. All these banks belong to a single pincontroller. > * _________ > * | |----> [gpio-bank (n) ] > * | |----> [gpio-bank (n + 1)] > * [irqN]-- | irq-mux |----> [gpio-bank (n + 2)] > * | |----> [gpio-bank (... )] > * |_________|----> [gpio-bank (n + 7)] > * > * Second type has a dedicated interrupt per each gpio bank. > * > * [irqN]----> [gpio-bank (n)] > */ > > > so irqmux_base is first type and gpio_irq is second type. > if you remove check for irqmux_base here you would end up NOT adding irqchip > the gpiochip in first type so you break the existing logic here. > > Thanks for this nice explanation. > I think the correct fix is: > > diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c > index 5475374..4060c30 100644 > --- a/drivers/pinctrl/pinctrl-st.c > +++ b/drivers/pinctrl/pinctrl-st.c > @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl > *info, > gpio_irq, st_gpio_irq_handler); > } > > - if (info->irqmux_base > 0 || gpio_irq > 0) { > + if (!IS_ERR(info->irqmux_base) || gpio_irq > 0) { > err = gpiochip_irqchip_add(&bank->gpio_chip, But if I am not wrong in function st_pctl_probe_dt, This is already done: if (IS_ERR(info->irqmux_base)) return PTR_ERR(info->irqmux_base); That is the reason I thought there is no need to recheck the pointer info->irqmux_base. Am I misunderstanding something? > &st_gpio_irqchip, > 0, handle_simple_irq, > IRQ_TYPE_LEVEL_LOW); > > > Thanks, > srini > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Thanks and Regards Pramod ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: st: Fix Sparse error 2014-09-29 15:05 ` Pramod Gurav @ 2014-09-29 15:38 ` Srinivas Kandagatla 2014-09-29 16:10 ` Pramod Gurav 0 siblings, 1 reply; 7+ messages in thread From: Srinivas Kandagatla @ 2014-09-29 15:38 UTC (permalink / raw) To: Pramod Gurav Cc: Pramod Gurav, linux-kernel@vger.kernel.org, Maxime Coquelin, Patrice Chotard, Linus Walleij On 29/09/14 16:05, Pramod Gurav wrote: >> >I think the correct fix is: >> > >> >diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c >> >index 5475374..4060c30 100644 >> >--- a/drivers/pinctrl/pinctrl-st.c >> >+++ b/drivers/pinctrl/pinctrl-st.c >> >@@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct st_pinctrl >> >*info, >> > gpio_irq, st_gpio_irq_handler); >> > } >> > >> >- if (info->irqmux_base > 0 || gpio_irq > 0) { >> >+ if (!IS_ERR(info->irqmux_base) || gpio_irq > 0) { >> > err = gpiochip_irqchip_add(&bank->gpio_chip, > But if I am not wrong in function st_pctl_probe_dt, This is already done: > > if (IS_ERR(info->irqmux_base)) > return PTR_ERR(info->irqmux_base); > > That is the reason I thought there is no need to recheck the pointer > info->irqmux_base. > Am I misunderstanding something? Ok, we want to add the irqchip only when there is a valid irqmux_base or a valid gpio_irq per bank. As st_gpiolib_register_bank() is used by both types of irq wirings and it does not know if irqmux or gpio irq is in use, so we need this explicit check. Also we want to make sure that atleast one type is valid before adding irqchip. If you just check for only gpio_irq in this code, you would miss the case where irqmux is used. As Dan pointed you could check if irqmux_base is valid and not remove it totally. Removing it will *break* the irqmux support as I explained. thanks, srini >> >&st_gpio_irqchip, >> > 0, handle_simple_irq, >> > IRQ_TYPE_LEVEL_LOW); >> > >> > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: st: Fix Sparse error 2014-09-29 15:38 ` Srinivas Kandagatla @ 2014-09-29 16:10 ` Pramod Gurav 0 siblings, 0 replies; 7+ messages in thread From: Pramod Gurav @ 2014-09-29 16:10 UTC (permalink / raw) To: Srinivas Kandagatla Cc: Pramod Gurav, linux-kernel@vger.kernel.org, Maxime Coquelin, Patrice Chotard, Linus Walleij On Mon, Sep 29, 2014 at 9:08 PM, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote: > > > On 29/09/14 16:05, Pramod Gurav wrote: >>> >>> >I think the correct fix is: >>> > >>> >diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c >>> >index 5475374..4060c30 100644 >>> >--- a/drivers/pinctrl/pinctrl-st.c >>> >+++ b/drivers/pinctrl/pinctrl-st.c >>> >@@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct >>> > st_pinctrl >>> >*info, >>> > gpio_irq, >>> > st_gpio_irq_handler); >>> > } >>> > >>> >- if (info->irqmux_base > 0 || gpio_irq > 0) { >>> >+ if (!IS_ERR(info->irqmux_base) || gpio_irq > 0) { >>> > err = gpiochip_irqchip_add(&bank->gpio_chip, >> >> But if I am not wrong in function st_pctl_probe_dt, This is already done: >> >> if (IS_ERR(info->irqmux_base)) >> return PTR_ERR(info->irqmux_base); >> >> That is the reason I thought there is no need to recheck the pointer >> info->irqmux_base. >> Am I misunderstanding something? > > > Ok, we want to add the irqchip only when there is a valid irqmux_base or a > valid gpio_irq per bank. > > As st_gpiolib_register_bank() is used by both types of irq wirings and it > does not know if irqmux or gpio irq is in use, so we need this explicit > check. Also we want to make sure that atleast one type is valid before > adding irqchip. > > If you just check for only gpio_irq in this code, you would miss the case > where irqmux is used. > > As Dan pointed you could check if irqmux_base is valid and not remove it > totally. Removing it will *break* the irqmux support as I explained. Thanks Srini, Will resend the patch. > > thanks, > srini > > > >>> >&st_gpio_irqchip, >>> > 0, handle_simple_irq, >>> > IRQ_TYPE_LEVEL_LOW); >>> > >>> > -- Thanks and Regards Pramod ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] pinctrl: st: Fix Sparse error 2014-09-29 14:46 ` Srinivas Kandagatla 2014-09-29 15:05 ` Pramod Gurav @ 2014-09-29 15:09 ` Daniel Thompson 1 sibling, 0 replies; 7+ messages in thread From: Daniel Thompson @ 2014-09-29 15:09 UTC (permalink / raw) To: Srinivas Kandagatla, Pramod Gurav, linux-kernel Cc: Maxime Coquelin, Patrice Chotard, Linus Walleij On 29/09/14 15:46, Srinivas Kandagatla wrote: > On 29/09/14 14:48, Pramod Gurav wrote: >> This change fixes below sparse error, >> drivers/pinctrl/pinctrl-st.c:1515:31: error: incompatible types for >> operation (>) >> drivers/pinctrl/pinctrl-st.c:1515:31: left side has type void >> [noderef] <asn:2>*irqmux_base >> drivers/pinctrl/pinctrl-st.c:1515:31: right side has type int >> >> The fix is done by removing a check on info->irqmux_base as >> info->irqmux_base has already been checked for error when allocating it. >> Hence there is no need to redo the check. >> >> Cc: Maxime Coquelin <maxime.coquelin@st.com> >> Cc: Patrice Chotard <patrice.chotard@st.com> >> CC: Linus Walleij <linus.walleij@linaro.org> >> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> >> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com> >> --- >> drivers/pinctrl/pinctrl-st.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c >> index 5475374..ddeaeda 100644 >> --- a/drivers/pinctrl/pinctrl-st.c >> +++ b/drivers/pinctrl/pinctrl-st.c >> @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct >> st_pinctrl *info, >> gpio_irq, st_gpio_irq_handler); >> } >> >> - if (info->irqmux_base > 0 || gpio_irq > 0) { >> + if (gpio_irq > 0) { >> err = gpiochip_irqchip_add(&bank->gpio_chip, &st_gpio_irqchip, >> 0, handle_simple_irq, >> IRQ_TYPE_LEVEL_LOW); > > This is not the correct fix. Please see why irqmux_base and gpio_irq are > used in the driver. > You are breaking the logic here... > > please read the below comment from the code. > > /** > * GPIO bank can have one of the two possible types of > * interrupt-wirings. > * > * First type is via irqmux, single interrupt is used by multiple > * gpio banks. This reduces number of overall interrupts numbers > * required. All these banks belong to a single pincontroller. > * _________ > * | |----> [gpio-bank (n) ] > * | |----> [gpio-bank (n + 1)] > * [irqN]-- | irq-mux |----> [gpio-bank (n + 2)] > * | |----> [gpio-bank (... )] > * |_________|----> [gpio-bank (n + 7)] > * > * Second type has a dedicated interrupt per each gpio bank. > * > * [irqN]----> [gpio-bank (n)] > */ > > > so irqmux_base is first type and gpio_irq is second type. > if you remove check for irqmux_base here you would end up NOT adding > irqchip the gpiochip in first type so you break the existing logic here. > > > I think the correct fix is: > > diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c > index 5475374..4060c30 100644 > --- a/drivers/pinctrl/pinctrl-st.c > +++ b/drivers/pinctrl/pinctrl-st.c > @@ -1512,7 +1512,7 @@ static int st_gpiolib_register_bank(struct > st_pinctrl *info, > gpio_irq, > st_gpio_irq_handler); > } > > - if (info->irqmux_base > 0 || gpio_irq > 0) { > + if (!IS_ERR(info->irqmux_base) || gpio_irq > 0) { > err = gpiochip_irqchip_add(&bank->gpio_chip, > &st_gpio_irqchip, > 0, handle_simple_irq, > IRQ_TYPE_LEVEL_LOW); IS_ERR() should be irrelavent because the allocation code bombs out on error. Shouldn't this just be a NULL pointer check? if(info->irqmux_base || gpio_irq > 0) Daniel. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-09-29 16:10 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-09-29 13:48 [PATCH] pinctrl: st: Fix Sparse error Pramod Gurav 2014-09-29 13:47 ` Patrice Chotard 2014-09-29 14:46 ` Srinivas Kandagatla 2014-09-29 15:05 ` Pramod Gurav 2014-09-29 15:38 ` Srinivas Kandagatla 2014-09-29 16:10 ` Pramod Gurav 2014-09-29 15:09 ` Daniel Thompson
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.