Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30967586rwd; Thu, 6 Jul 2023 13:30:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFAY+Boq16+w3qpaCOPxjYXwjxWoUh6FWHcXFpPVBHspe/ACusXTD/GMJL7i02zzmEOsJpl X-Received: by 2002:a17:90b:11c5:b0:264:a78:65cc with SMTP id gv5-20020a17090b11c500b002640a7865ccmr2773556pjb.45.1688675431607; Thu, 06 Jul 2023 13:30:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688675431; cv=none; d=google.com; s=arc-20160816; b=LZGyW1nl+lYj2lxClWreByy+8wIH+ajwPdPBO3FhtrRPP53EToxQjDzKDpJ7kjMNUb lze3RPhAsXXP8rsYPqsSOHoHTcw8YmCpUBGmBK8ge1PEBsvmgsy6xXzQ9K/FLRxXblto 3UOO3jmmwkd4axO76wghrB+Wp7jxIP9XgW8mKuzZFtf5Yv2sh46nX/ns9XMKfop5s5hq pvl1yVfYXjFfeMdkqdlRhXd+qpV3XGEbzW+AxvRwJjFkhsoQxbZGkWgBrGrSxTrepVl1 NSEO8TzYoa4R/oB7AB5ztEM/RGf1EavVG+9V7u+cqEXa1mL34BjElKwKzllBCdK9N0O8 QJzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=UYq7wrQ7amiMH/9U2D+tqo0zif83ljXKJ9o7AkPaAD8=; fh=L3gBlEoWCE9fHc0mV7PKHi1HcZfHE9psED0yWanEH54=; b=qzm/pbkdNiSok8wbx25YtrKSgEQJNkC/67KRsh1lAMAlldw3J7aDvK2IDugulwZnsd ZlKB6JnUKVw2AN3e1N17MPlHbrJV9pNcGYrm99261RuWhTr8Z99ijbvIEhBMhudtEZWm TTdTqv35Lc/Ovuu7dNeXaoqIyLZwzxuRH+256Oij4BNIGgD6d12ptUZJAoSykuou1XY3 zI2Ws1B4TFD+ZpSpFlr0L8aQGSjYTa1hLTEvTp34cO4XCP499CUr2yr5N5OQ2QV4KtSQ BFV/wOtNvDaCpMRZAaa6hAxNmyCCO+X+UJfSRDhqowDmF+nH8jdQQJsxHv8SblMiCozV kCDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id np10-20020a17090b4c4a00b00258996c09e4si491254pjb.22.2023.07.06.13.30.16; Thu, 06 Jul 2023 13:30:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231965AbjGFUVy (ORCPT + 99 others); Thu, 6 Jul 2023 16:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbjGFUVw (ORCPT ); Thu, 6 Jul 2023 16:21:52 -0400 Received: from mail11.truemail.it (mail11.truemail.it [IPv6:2001:4b7e:0:8::81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3937E1996; Thu, 6 Jul 2023 13:21:50 -0700 (PDT) Received: from francesco-nb.int.toradex.com (93-49-2-63.ip317.fastwebnet.it [93.49.2.63]) by mail11.truemail.it (Postfix) with ESMTPA id DC821209B4; Thu, 6 Jul 2023 22:21:47 +0200 (CEST) Date: Thu, 6 Jul 2023 22:21:43 +0200 From: Francesco Dolcini To: Judith Mendez Cc: Marc Kleine-Budde , Chandrasekar Ramakrishnan , Wolfgang Grandegger , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Schuyler Patton , Tero Kristo , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, Oliver Hartkopp , Simon Horman Subject: Re: [PATCH 2/2] can: m_can: Add hrtimer to generate software interrupt Message-ID: References: <20230705195356.866774-1-jm@ti.com> <20230705195356.866774-3-jm@ti.com> <20230706-unstopped-skedaddle-7168f2b12189-mkl@pengutronix.de> <0ba17779-9cd9-6cb2-a79c-6b14b73a42db@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0ba17779-9cd9-6cb2-a79c-6b14b73a42db@ti.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 # Toradex Verdin AM62 > > > Reviewed-by: Tony Lindgren > > > Signed-off-by: Judith Mendez > > > --- ... > > > 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 > > > #include > > > #include > > > @@ -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; > > > 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. Francesco