netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Judith Mendez <jm@ti.com>
To: Simon Horman <simon.horman@corigine.com>
Cc: Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
	<linux-can@vger.kernel.org>,
	Wolfgang Grandegger <wg@grandegger.com>,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Schuyler Patton <spatton@ti.com>, Tero Kristo <kristo@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>, <devicetree@vger.kernel.org>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Tony Lindgren <tony@atomide.com>
Subject: Re: [PATCH v7 2/2] can: m_can: Add hrtimer to generate software interrupt
Date: Wed, 24 May 2023 16:29:01 -0500	[thread overview]
Message-ID: <8985ea03-a7dc-a0bc-a238-3099caadf740@ti.com> (raw)
In-Reply-To: <ZGyfAhp8op4GMElN@corigine.com>

Hello Simon,

On 5/23/23 6:09 AM, Simon Horman wrote:
> On Mon, May 22, 2023 at 09:37:49PM -0500, Judith Mendez wrote:
>> Add an hrtimer to MCAN class device. Each MCAN will have its own
>> hrtimer instantiated if there is no hardware interrupt found in
>> device tree M_CAN node.
>>
>> The hrtimer will generate a software interrupt every 1 ms. In
>> hrtimer callback, we check if there is a transaction pending by
>> reading a register, then process by calling the isr if there is.
>>
>> Signed-off-by: Judith Mendez <jm@ti.com>
> 
> ...
> 
>> diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
>> index 94dc82644113..b639c9e645d3 100644
>> --- a/drivers/net/can/m_can/m_can_platform.c
>> +++ b/drivers/net/can/m_can/m_can_platform.c
>> @@ -5,6 +5,7 @@
>>   //
>>   // Copyright (C) 2018-19 Texas Instruments Incorporated - http://www.ti.com/
>>   
>> +#include <linux/hrtimer.h>
>>   #include <linux/phy/phy.h>
>>   #include <linux/platform_device.h>
>>   
>> @@ -96,12 +97,30 @@ static int m_can_plat_probe(struct platform_device *pdev)
>>   		goto probe_fail;
>>   
>>   	addr = devm_platform_ioremap_resource_byname(pdev, "m_can");
>> -	irq = platform_get_irq_byname(pdev, "int0");
>> -	if (IS_ERR(addr) || irq < 0) {
>> -		ret = -EINVAL;
>> +	if (IS_ERR(addr)) {
>> +		ret = PTR_ERR(addr);
>>   		goto probe_fail;
>>   	}
>>   
>> +	if (device_property_present(mcan_class->dev, "interrupts") ||
>> +	    device_property_present(mcan_class->dev, "interrupt-names")) {
>> +		irq = platform_get_irq_byname(pdev, "int0");
>> +		mcan_class->polling = false;
>> +		if (irq == -EPROBE_DEFER) {
>> +			ret = -EPROBE_DEFER;
>> +			goto probe_fail;
>> +		}
>> +		if (irq < 0) {
>> +			ret = -ENXIO;
>> +			goto probe_fail;
>> +		}
>> +	} else {
>> +		mcan_class->polling = true;
>> +		dev_dbg(mcan_class->dev, "Polling enabled, initialize hrtimer");
>> +		hrtimer_init(&mcan_class->hrtimer, CLOCK_MONOTONIC,
>> +			     HRTIMER_MODE_REL_PINNED);
>> +	}
> 
> Hi Judith,
> 
> it seems that with this change irq is only set in the first arm of
> the above conditional. But later on it is used unconditionally.
> That is, it may be used uninitialised.
> 
> Reported by gcc-12 as:
> 
>   drivers/net/can/m_can/m_can_platform.c: In function 'm_can_plat_probe':
>   drivers/net/can/m_can/m_can_platform.c:150:30: warning: 'irq' may be used uninitialized [-Wmaybe-uninitialized]
>     150 |         mcan_class->net->irq = irq;
>         |         ~~~~~~~~~~~~~~~~~~~~~^~~~~
>   drivers/net/can/m_can/m_can_platform.c:86:13: note: 'irq' was declared here
>      86 |         int irq, ret = 0;
>         |             ^~~
> 

Maybe a good solution is to initialize irq=0 here.

>> +
>>   	/* message ram could be shared */
>>   	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram");
>>   	if (!res) {
>> -- 
>> 2.17.1


~Judith

  reply	other threads:[~2023-05-24 21:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-23  2:37 [PATCH v7 0/2] Enable multiple MCAN on AM62x Judith Mendez
2023-05-23  2:37 ` [PATCH v7 1/2] dt-bindings: net: can: Remove interrupt properties for MCAN Judith Mendez
2023-05-23 16:58   ` Conor Dooley
2023-05-23  2:37 ` [PATCH v7 2/2] can: m_can: Add hrtimer to generate software interrupt Judith Mendez
2023-05-23  6:35   ` Marc Kleine-Budde
2023-05-24 21:20     ` Judith Mendez
2023-05-23 11:09   ` Simon Horman
2023-05-24 21:29     ` Judith Mendez [this message]
2023-05-25  7:23       ` Simon Horman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8985ea03-a7dc-a0bc-a238-3099caadf740@ti.com \
    --to=jm@ti.com \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=kristo@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rcsekar@samsung.com \
    --cc=robh+dt@kernel.org \
    --cc=simon.horman@corigine.com \
    --cc=socketcan@hartkopp.net \
    --cc=spatton@ti.com \
    --cc=tony@atomide.com \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).