* [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
@ 2017-08-06 23:49 Christophe JAILLET
2017-08-07 6:36 ` Uwe Kleine-König
0 siblings, 1 reply; 8+ messages in thread
From: Christophe JAILLET @ 2017-08-06 23:49 UTC (permalink / raw)
To: wsa; +Cc: linux-i2c, linux-kernel, kernel-janitors, Christophe JAILLET
'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/i2c/busses/i2c-imx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 54a47b40546f..7e84662fe1c0 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -997,7 +997,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
- if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
+ if (IS_ERR(i2c_imx->pinctrl)) {
dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
return PTR_ERR(i2c_imx->pinctrl);
}
--
2.11.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
2017-08-06 23:49 [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()' Christophe JAILLET
@ 2017-08-07 6:36 ` Uwe Kleine-König
2017-08-07 7:16 ` Julia Lawall
2017-08-08 7:40 ` Christophe JAILLET
0 siblings, 2 replies; 8+ messages in thread
From: Uwe Kleine-König @ 2017-08-07 6:36 UTC (permalink / raw)
To: Christophe JAILLET
Cc: wsa, linux-i2c, linux-kernel, kernel-janitors, Julia Lawall
On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
> 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
NULL. But I think this shouldn't be considered an error, so your change
is right, just the commit log is not.
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 54a47b40546f..7e84662fe1c0 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -997,7 +997,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
> struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
>
> i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> + if (IS_ERR(i2c_imx->pinctrl)) {
> dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
> return PTR_ERR(i2c_imx->pinctrl);
> }
Side note: I'm not sure, this construct is valid. IIRC PTR_ERR should
only be called for values x where IS_ERR(x) is true. Here it is at least
surprising that an message hints to a problem but the return code is 0.
@Julia: I'm sure coccinelle can find more of those?!
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
2017-08-07 6:36 ` Uwe Kleine-König
@ 2017-08-07 7:16 ` Julia Lawall
2017-08-08 6:44 ` Christophe JAILLET
2017-08-08 7:40 ` Christophe JAILLET
1 sibling, 1 reply; 8+ messages in thread
From: Julia Lawall @ 2017-08-07 7:16 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Christophe JAILLET, wsa, linux-i2c, linux-kernel, kernel-janitors,
Julia Lawall
[-- Attachment #1: Type: text/plain, Size: 4105 bytes --]
On Mon, 7 Aug 2017, Uwe Kleine-König wrote:
> On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
> > 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
>
> That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
> NULL. But I think this shouldn't be considered an error, so your change
> is right, just the commit log is not.
>
> > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> > index 54a47b40546f..7e84662fe1c0 100644
> > --- a/drivers/i2c/busses/i2c-imx.c
> > +++ b/drivers/i2c/busses/i2c-imx.c
> > @@ -997,7 +997,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
> > struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
> >
> > i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> > - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> > + if (IS_ERR(i2c_imx->pinctrl)) {
> > dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
> > return PTR_ERR(i2c_imx->pinctrl);
> > }
>
> Side note: I'm not sure, this construct is valid. IIRC PTR_ERR should
> only be called for values x where IS_ERR(x) is true. Here it is at least
> surprising that an message hints to a problem but the return code is 0.
>
> @Julia: I'm sure coccinelle can find more of those?!
I only found a few. Christophe, if you want to fix tem up, please go
ahead.
julia
diff -u -p /var/linuxes/linux-next/drivers/net/ethernet/intel/e100.c
/tmp/nothing/drivers/net/ethernet/intel/e100.c
--- /var/linuxes/linux-next/drivers/net/ethernet/intel/e100.c
+++ /tmp/nothing/drivers/net/ethernet/intel/e100.c
@@ -1370,8 +1370,6 @@ static inline int e100_load_ucode_wait(s
fw = e100_request_firmware(nic);
/* If it's NULL, then no ucode is required */
- if (!fw || IS_ERR(fw))
- return PTR_ERR(fw);
if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode)))
netif_err(nic, probe, nic->netdev,
diff -u -p /var/linuxes/linux-next/drivers/i2c/busses/i2c-imx.c
/tmp/nothing/drivers/i2c/busses/i2c-imx.c
--- /var/linuxes/linux-next/drivers/i2c/busses/i2c-imx.c
+++ /tmp/nothing/drivers/i2c/busses/i2c-imx.c
@@ -997,9 +997,7 @@ static int i2c_imx_init_recovery_info(st
struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
- if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
dev_info(&pdev->dev, "can't get pinctrl, bus recovery not
supported\n");
- return PTR_ERR(i2c_imx->pinctrl);
}
i2c_imx->pinctrl_pins_default =
pinctrl_lookup_state(i2c_imx->pinctrl,
diff -u -p /var/linuxes/linux-next/drivers/crypto/chelsio/chcr_algo.c
/tmp/nothing/drivers/crypto/chelsio/chcr_algo.c
--- /var/linuxes/linux-next/drivers/crypto/chelsio/chcr_algo.c
+++ /tmp/nothing/drivers/crypto/chelsio/chcr_algo.c
@@ -3159,8 +3159,6 @@ static int chcr_aead_op(struct aead_requ
skb = create_wr_fn(req, u_ctx->lldi.rxq_ids[ctx->rx_qidx], size,
op_type);
- if (IS_ERR(skb) || !skb)
- return PTR_ERR(skb);
skb->dev = u_ctx->lldi.ports[0];
set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_qidx);
diff -u -p /var/linuxes/linux-next/fs/ocfs2/acl.c
/tmp/nothing/fs/ocfs2/acl.c
--- /var/linuxes/linux-next/fs/ocfs2/acl.c
+++ /tmp/nothing/fs/ocfs2/acl.c
@@ -331,8 +331,6 @@ int ocfs2_acl_chmod(struct inode *inode,
return 0;
acl = ocfs2_get_acl_nolock(inode, ACL_TYPE_ACCESS, bh);
- if (IS_ERR(acl) || !acl)
- return PTR_ERR(acl);
ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
if (ret)
return ret;
>
> Best regards
> Uwe
>
> --
> Pengutronix e.K. | Uwe Kleine-König |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
2017-08-07 7:16 ` Julia Lawall
@ 2017-08-08 6:44 ` Christophe JAILLET
2017-08-08 7:04 ` Julia Lawall
0 siblings, 1 reply; 8+ messages in thread
From: Christophe JAILLET @ 2017-08-08 6:44 UTC (permalink / raw)
To: Julia Lawall, Uwe Kleine-König
Cc: wsa, linux-i2c, linux-kernel, kernel-janitors
Le 07/08/2017 à 09:16, Julia Lawall a écrit :
>
> On Mon, 7 Aug 2017, Uwe Kleine-König wrote:
>
>> On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
>>> 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
>> That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
>> NULL. But I think this shouldn't be considered an error, so your change
>> is right, just the commit log is not.
>>
>>> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
>>> index 54a47b40546f..7e84662fe1c0 100644
>>> --- a/drivers/i2c/busses/i2c-imx.c
>>> +++ b/drivers/i2c/busses/i2c-imx.c
>>> @@ -997,7 +997,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
>>> struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
>>>
>>> i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
>>> - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
>>> + if (IS_ERR(i2c_imx->pinctrl)) {
>>> dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
>>> return PTR_ERR(i2c_imx->pinctrl);
>>> }
>> Side note: I'm not sure, this construct is valid. IIRC PTR_ERR should
>> only be called for values x where IS_ERR(x) is true. Here it is at least
>> surprising that an message hints to a problem but the return code is 0.
>>
>> @Julia: I'm sure coccinelle can find more of those?!
> I only found a few. Christophe, if you want to fix tem up, please go
> ahead.
Hi Julia,
I've looked quickly at your output, and can't see what could/should be
done in the spotted cases.
e100.c: a comment says that 'If it's NULL, then no ucode is
required', so, the behavior looks ok to me
chcr_algo.c: function 'create_wr_fn' is passed as a parameter. I've
no way to make sure of its behavior, so the code could be valid. I won't
touch it.
acl.c: by code inspection, the way the code is written looks valid
to me. We have NULL if the a call in 'ocfs2_get_acl_nolock' returns
-ENODATA. Not that strange to return success in this case
So, personally, I won't propose anything on these files. Up to anyone to
dig further than me.
CJ
> julia
>
> diff -u -p /var/linuxes/linux-next/drivers/net/ethernet/intel/e100.c
> /tmp/nothing/drivers/net/ethernet/intel/e100.c
> --- /var/linuxes/linux-next/drivers/net/ethernet/intel/e100.c
> +++ /tmp/nothing/drivers/net/ethernet/intel/e100.c
> @@ -1370,8 +1370,6 @@ static inline int e100_load_ucode_wait(s
>
> fw = e100_request_firmware(nic);
> /* If it's NULL, then no ucode is required */
> - if (!fw || IS_ERR(fw))
> - return PTR_ERR(fw);
>
> if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode)))
> netif_err(nic, probe, nic->netdev,
> diff -u -p /var/linuxes/linux-next/drivers/i2c/busses/i2c-imx.c
> /tmp/nothing/drivers/i2c/busses/i2c-imx.c
> --- /var/linuxes/linux-next/drivers/i2c/busses/i2c-imx.c
> +++ /tmp/nothing/drivers/i2c/busses/i2c-imx.c
> @@ -997,9 +997,7 @@ static int i2c_imx_init_recovery_info(st
> struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
>
> i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> dev_info(&pdev->dev, "can't get pinctrl, bus recovery not
> supported\n");
> - return PTR_ERR(i2c_imx->pinctrl);
> }
>
> i2c_imx->pinctrl_pins_default =
> pinctrl_lookup_state(i2c_imx->pinctrl,
> diff -u -p /var/linuxes/linux-next/drivers/crypto/chelsio/chcr_algo.c
> /tmp/nothing/drivers/crypto/chelsio/chcr_algo.c
> --- /var/linuxes/linux-next/drivers/crypto/chelsio/chcr_algo.c
> +++ /tmp/nothing/drivers/crypto/chelsio/chcr_algo.c
> @@ -3159,8 +3159,6 @@ static int chcr_aead_op(struct aead_requ
> skb = create_wr_fn(req, u_ctx->lldi.rxq_ids[ctx->rx_qidx], size,
> op_type);
>
> - if (IS_ERR(skb) || !skb)
> - return PTR_ERR(skb);
>
> skb->dev = u_ctx->lldi.ports[0];
> set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_qidx);
> diff -u -p /var/linuxes/linux-next/fs/ocfs2/acl.c
> /tmp/nothing/fs/ocfs2/acl.c
> --- /var/linuxes/linux-next/fs/ocfs2/acl.c
> +++ /tmp/nothing/fs/ocfs2/acl.c
> @@ -331,8 +331,6 @@ int ocfs2_acl_chmod(struct inode *inode,
> return 0;
>
> acl = ocfs2_get_acl_nolock(inode, ACL_TYPE_ACCESS, bh);
> - if (IS_ERR(acl) || !acl)
> - return PTR_ERR(acl);
> ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
> if (ret)
> return ret;
>
>
>
>
>
>> Best regards
>> Uwe
>>
>> --
>> Pengutronix e.K. | Uwe Kleine-König |
>> Industrial Linux Solutions | http://www.pengutronix.de/ |
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
2017-08-08 6:44 ` Christophe JAILLET
@ 2017-08-08 7:04 ` Julia Lawall
0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2017-08-08 7:04 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Uwe Kleine-König, wsa, linux-i2c, linux-kernel,
kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 5506 bytes --]
On Tue, 8 Aug 2017, Christophe JAILLET wrote:
> Le 07/08/2017 à 09:16, Julia Lawall a écrit :
> >
> > On Mon, 7 Aug 2017, Uwe Kleine-König wrote:
> >
> > > On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
> > > > 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
> > > That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
> > > NULL. But I think this shouldn't be considered an error, so your change
> > > is right, just the commit log is not.
> > >
> > > > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> > > > index 54a47b40546f..7e84662fe1c0 100644
> > > > --- a/drivers/i2c/busses/i2c-imx.c
> > > > +++ b/drivers/i2c/busses/i2c-imx.c
> > > > @@ -997,7 +997,7 @@ static int i2c_imx_init_recovery_info(struct
> > > > imx_i2c_struct *i2c_imx,
> > > > struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
> > > >
> > > > i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> > > > - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> > > > + if (IS_ERR(i2c_imx->pinctrl)) {
> > > > dev_info(&pdev->dev, "can't get pinctrl, bus recovery
> > > > not supported\n");
> > > > return PTR_ERR(i2c_imx->pinctrl);
> > > > }
> > > Side note: I'm not sure, this construct is valid. IIRC PTR_ERR should
> > > only be called for values x where IS_ERR(x) is true. Here it is at least
> > > surprising that an message hints to a problem but the return code is 0.
> > >
> > > @Julia: I'm sure coccinelle can find more of those?!
> > I only found a few. Christophe, if you want to fix tem up, please go
> > ahead.
>
> Hi Julia,
>
> I've looked quickly at your output, and can't see what could/should be done in
> the spotted cases.
> e100.c: a comment says that 'If it's NULL, then no ucode is required', so,
> the behavior looks ok to me
> chcr_algo.c: function 'create_wr_fn' is passed as a parameter. I've no way
> to make sure of its behavior, so the code could be valid. I won't touch it.
> acl.c: by code inspection, the way the code is written looks valid to me.
> We have NULL if the a call in 'ocfs2_get_acl_nolock' returns -ENODATA. Not
> that strange to return success in this case
>
> So, personally, I won't propose anything on these files. Up to anyone to dig
> further than me.
OK, thanks for looking at them. I do find it odd to exploit PTR_ERR to
return a success value. Maybe I will check with the maintainers in the
uncommented cases.
julia
>
> CJ
> > julia
> >
> > diff -u -p /var/linuxes/linux-next/drivers/net/ethernet/intel/e100.c
> > /tmp/nothing/drivers/net/ethernet/intel/e100.c
> > --- /var/linuxes/linux-next/drivers/net/ethernet/intel/e100.c
> > +++ /tmp/nothing/drivers/net/ethernet/intel/e100.c
> > @@ -1370,8 +1370,6 @@ static inline int e100_load_ucode_wait(s
> >
> > fw = e100_request_firmware(nic);
> > /* If it's NULL, then no ucode is required */
> > - if (!fw || IS_ERR(fw))
> > - return PTR_ERR(fw);
> >
> > if ((err = e100_exec_cb(nic, (void *)fw, e100_setup_ucode)))
> > netif_err(nic, probe, nic->netdev,
> > diff -u -p /var/linuxes/linux-next/drivers/i2c/busses/i2c-imx.c
> > /tmp/nothing/drivers/i2c/busses/i2c-imx.c
> > --- /var/linuxes/linux-next/drivers/i2c/busses/i2c-imx.c
> > +++ /tmp/nothing/drivers/i2c/busses/i2c-imx.c
> > @@ -997,9 +997,7 @@ static int i2c_imx_init_recovery_info(st
> > struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
> >
> > i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
> > - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
> > dev_info(&pdev->dev, "can't get pinctrl, bus recovery not
> > supported\n");
> > - return PTR_ERR(i2c_imx->pinctrl);
> > }
> >
> > i2c_imx->pinctrl_pins_default =
> > pinctrl_lookup_state(i2c_imx->pinctrl,
> > diff -u -p /var/linuxes/linux-next/drivers/crypto/chelsio/chcr_algo.c
> > /tmp/nothing/drivers/crypto/chelsio/chcr_algo.c
> > --- /var/linuxes/linux-next/drivers/crypto/chelsio/chcr_algo.c
> > +++ /tmp/nothing/drivers/crypto/chelsio/chcr_algo.c
> > @@ -3159,8 +3159,6 @@ static int chcr_aead_op(struct aead_requ
> > skb = create_wr_fn(req, u_ctx->lldi.rxq_ids[ctx->rx_qidx], size,
> > op_type);
> >
> > - if (IS_ERR(skb) || !skb)
> > - return PTR_ERR(skb);
> >
> > skb->dev = u_ctx->lldi.ports[0];
> > set_wr_txq(skb, CPL_PRIORITY_DATA, ctx->tx_qidx);
> > diff -u -p /var/linuxes/linux-next/fs/ocfs2/acl.c
> > /tmp/nothing/fs/ocfs2/acl.c
> > --- /var/linuxes/linux-next/fs/ocfs2/acl.c
> > +++ /tmp/nothing/fs/ocfs2/acl.c
> > @@ -331,8 +331,6 @@ int ocfs2_acl_chmod(struct inode *inode,
> > return 0;
> >
> > acl = ocfs2_get_acl_nolock(inode, ACL_TYPE_ACCESS, bh);
> > - if (IS_ERR(acl) || !acl)
> > - return PTR_ERR(acl);
> > ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
> > if (ret)
> > return ret;
> >
> >
> >
> >
> >
> > > Best regards
> > > Uwe
> > >
> > > --
> > > Pengutronix e.K. | Uwe Kleine-König |
> > > Industrial Linux Solutions | http://www.pengutronix.de/ |
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe kernel-janitors"
> > > in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > >
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
2017-08-07 6:36 ` Uwe Kleine-König
2017-08-07 7:16 ` Julia Lawall
@ 2017-08-08 7:40 ` Christophe JAILLET
2017-08-08 8:15 ` Uwe Kleine-König
1 sibling, 1 reply; 8+ messages in thread
From: Christophe JAILLET @ 2017-08-08 7:40 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: wsa, linux-i2c, linux-kernel, kernel-janitors, Julia Lawall
Le 07/08/2017 à 08:36, Uwe Kleine-König a écrit :
> On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
>> 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
> That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
> NULL. But I think this shouldn't be considered an error, so your change
> is right, just the commit log is not.
With that said, in fact, I think that the test is correct as is.
If CONFIG_PINCTRL is disabled, we will display an info about a missing
functionality, but would still continue normally without it (i.e. return
PTR_ERR(NULL) = 0 = success), as stated in the comment in front of
'i2c_imx_init_recovery_info':
"These alternative pinmux settings can be described in the device
tree by
a separate pinctrl state "gpio". If this is missing this is not a big
problem, the only implication is that we can't do bus recovery."
So, I won't propose any v2 patch with an updated commit log.
Feel free to update it yourself and apply it if you don't share my
analysis above.
Sorry for the noise.
CJ
>
>> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
>> index 54a47b40546f..7e84662fe1c0 100644
>> --- a/drivers/i2c/busses/i2c-imx.c
>> +++ b/drivers/i2c/busses/i2c-imx.c
>> @@ -997,7 +997,7 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
>> struct i2c_bus_recovery_info *rinfo = &i2c_imx->rinfo;
>>
>> i2c_imx->pinctrl = devm_pinctrl_get(&pdev->dev);
>> - if (!i2c_imx->pinctrl || IS_ERR(i2c_imx->pinctrl)) {
>> + if (IS_ERR(i2c_imx->pinctrl)) {
>> dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n");
>> return PTR_ERR(i2c_imx->pinctrl);
>> }
> Side note: I'm not sure, this construct is valid. IIRC PTR_ERR should
> only be called for values x where IS_ERR(x) is true. Here it is at least
> surprising that an message hints to a problem but the return code is 0.
>
> @Julia: I'm sure coccinelle can find more of those?!
>
> Best regards
> Uwe
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
2017-08-08 7:40 ` Christophe JAILLET
@ 2017-08-08 8:15 ` Uwe Kleine-König
2017-10-27 20:08 ` Wolfram Sang
0 siblings, 1 reply; 8+ messages in thread
From: Uwe Kleine-König @ 2017-08-08 8:15 UTC (permalink / raw)
To: Christophe JAILLET
Cc: wsa, linux-i2c, linux-kernel, kernel-janitors, Julia Lawall
On Tue, Aug 08, 2017 at 09:40:59AM +0200, Christophe JAILLET wrote:
> Le 07/08/2017 à 08:36, Uwe Kleine-König a écrit :
> > On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
> > > 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
> > That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
> > NULL. But I think this shouldn't be considered an error, so your change
> > is right, just the commit log is not.
> With that said, in fact, I think that the test is correct as is.
> If CONFIG_PINCTRL is disabled, we will display an info about a missing
> functionality, but would still continue normally without it (i.e. return
> PTR_ERR(NULL) = 0 = success), as stated in the comment in front of
> 'i2c_imx_init_recovery_info':
> "These alternative pinmux settings can be described in the device tree
> by
> a separate pinctrl state "gpio". If this is missing this is not a big
> problem, the only implication is that we can't do bus recovery."
>
> So, I won't propose any v2 patch with an updated commit log.
> Feel free to update it yourself and apply it if you don't share my analysis
> above.
Then the only issue (maybe?) is that the driver makes use of
PTR_ERR(NULL) == 0 which I'm not sure is explicitly allowed.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()'
2017-08-08 8:15 ` Uwe Kleine-König
@ 2017-10-27 20:08 ` Wolfram Sang
0 siblings, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2017-10-27 20:08 UTC (permalink / raw)
To: Uwe Kleine-König
Cc: Christophe JAILLET, linux-i2c, linux-kernel, kernel-janitors,
Julia Lawall
[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]
On Tue, Aug 08, 2017 at 10:15:01AM +0200, Uwe Kleine-König wrote:
> On Tue, Aug 08, 2017 at 09:40:59AM +0200, Christophe JAILLET wrote:
> > Le 07/08/2017 à 08:36, Uwe Kleine-König a écrit :
> > > On Mon, Aug 07, 2017 at 01:49:53AM +0200, Christophe JAILLET wrote:
> > > > 'devm_pinctrl_get()' never returns NULL, so this test can be simplified.
> > > That's wrong. If CONFIG_PINCTRL is disabled devm_pinctrl_get returns
> > > NULL. But I think this shouldn't be considered an error, so your change
> > > is right, just the commit log is not.
> > With that said, in fact, I think that the test is correct as is.
> > If CONFIG_PINCTRL is disabled, we will display an info about a missing
> > functionality, but would still continue normally without it (i.e. return
> > PTR_ERR(NULL) = 0 = success), as stated in the comment in front of
> > 'i2c_imx_init_recovery_info':
> > "These alternative pinmux settings can be described in the device tree
> > by
> > a separate pinctrl state "gpio". If this is missing this is not a big
> > problem, the only implication is that we can't do bus recovery."
> >
> > So, I won't propose any v2 patch with an updated commit log.
> > Feel free to update it yourself and apply it if you don't share my analysis
> > above.
>
> Then the only issue (maybe?) is that the driver makes use of
> PTR_ERR(NULL) == 0 which I'm not sure is explicitly allowed.
I'll drop this patch for now. If somebody wants this applied, please
send a V2 with the issues here addressed.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-10-27 20:08 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-06 23:49 [PATCH] i2c: imx: Remove a useless test in 'i2c_imx_init_recovery_info()' Christophe JAILLET
2017-08-07 6:36 ` Uwe Kleine-König
2017-08-07 7:16 ` Julia Lawall
2017-08-08 6:44 ` Christophe JAILLET
2017-08-08 7:04 ` Julia Lawall
2017-08-08 7:40 ` Christophe JAILLET
2017-08-08 8:15 ` Uwe Kleine-König
2017-10-27 20:08 ` Wolfram Sang
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).