mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Judith Mendez <jm@ti.com>
To: Francesco Dolcini <francesco@dolcini.it>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
	Chandrasekar Ramakrishnan <rcsekar@samsung.com>,
	Wolfgang Grandegger <wg@grandegger.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<linux-can@vger.kernel.org>, <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>,
	<devicetree@vger.kernel.org>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	Simon Horman <simon.horman@corigine.com>
Subject: Re: [PATCH 2/2] can: m_can: Add hrtimer to generate software interrupt
Date: Thu, 6 Jul 2023 16:12:43 -0500	[thread overview]
Message-ID: <aaf12da2-fbe4-eb30-81de-1c4ee41c2d4b@ti.com> (raw)
In-Reply-To: <ZKciVy4juK55OUrG@francesco-nb.int.toradex.com>

Hi,

On 7/6/23 3:21 PM, Francesco Dolcini wrote:
> On Thu, Jul 06, 2023 at 10:20:59AM -0500, Judith Mendez wrote:
>> Hi Marc
>>
>> On 7/6/23 2:25 AM, Marc Kleine-Budde wrote:
>>> On 05.07.2023 14:53:56, Judith Mendez wrote:
>>>> Introduce timer polling method to MCAN since some SoCs may not
>>>> have M_CAN interrupt routed to A53 Linux and do not have
>>>> interrupt property in device tree M_CAN node.
>>>>
>>>> On AM62x SoC, MCANs on MCU domain do not have hardware interrupt
>>>> routed to A53 Linux, instead they will use timer polling method.
>>>>
>>>> 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 timer 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.
>>>>
>>>> Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Toradex Verdin AM62
>>>> Reviewed-by: Tony Lindgren <tony@atomide.com>
>>>> 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..76d11ce38220 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,28 @@ static int m_can_plat_probe(struct platform_device *pdev)
>>>>    		goto probe_fail;
>>>
>>> Please set "irq" to 0 during declaration.
>>
>> During declaration of irq, it is already set to 0:
>>
>> int irq, ret = 0;
> 
> The initialization here applies only to ret.
> 
> int irq = 0, ret = 0;

Understood, thanks!

> 
>>>>    	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");
>>>> +		if (irq == -EPROBE_DEFER) {
>>>> +			ret = -EPROBE_DEFER;
>>>> +			goto probe_fail;
>>>> +		}
>>>> +		if (irq < 0) {
>>>> +			ret = -EINVAL;
>>>
>>> Please return the original error value.
>>
>> The original value returned is -EINVAL:
>>
>> -	if (IS_ERR(addr) || irq < 0) {
>> -		ret = -EINVAL;
>>
>> Perhaps I am missing something here?
> 
> if (irq < 0) {
> 	ret = irq;
> 	...
> }
> 
> And you can also get rid of the explicit test for -EPROBE_DEFER this
> way simplifying the code.

I misunderstood, thanks!!

~ Judith

  reply	other threads:[~2023-07-06 21:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 19:53 [PATCH 0/2] Enable multiple MCAN on AM62x Judith Mendez
2023-07-05 19:53 ` [PATCH 1/2] dt-bindings: net: can: Remove interrupt properties for MCAN Judith Mendez
2023-07-05 19:53 ` [PATCH 2/2] can: m_can: Add hrtimer to generate software interrupt Judith Mendez
2023-07-06  7:25   ` Marc Kleine-Budde
2023-07-06 15:20     ` Judith Mendez
2023-07-06 20:21       ` Francesco Dolcini
2023-07-06 21:12         ` Judith Mendez [this message]
2023-07-06 20:48 ` [PATCH 0/2] Enable multiple MCAN on AM62x Francesco Dolcini
2023-07-06 21:13   ` Judith Mendez

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=aaf12da2-fbe4-eb30-81de-1c4ee41c2d4b@ti.com \
    --to=jm@ti.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=francesco@dolcini.it \
    --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=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

all inboxes | Powered by JetHome®