From patchwork Wed Jun 16 09:14:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 12324601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8116DC48BE5 for ; Wed, 16 Jun 2021 09:18:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E39A61107 for ; Wed, 16 Jun 2021 09:18:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4E39A61107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ke/6uIRPTUc6jz3qsUu8/ffgQAA0Aben+ktV4ReY0Lk=; b=a9fFKO3rhbVbSg 7gUqHC18tDNTe6EK49JSySU5OVwM2rida186wE6daDn1J9FCkGeL/XJsw53HhcxZrCmmeZE9sgk9Z 3KoHMbXUR2CxFX8e24vOGNjPr3itCebtHwI9EpFbCg5Hyq75oSnuvZ3oFGBXMu94fpRuyvtezMQK7 Jy+TgUZmFZmM+dR3lx1PhvsThiIEaeq4c6/+UHfSwFHwB51ReLBrIHN6Z3BEXgLdzEp+6ajTusedF 07bmaLroFtyW4Z2w5xdC+QQivz5jPPMgoF+pOrNYBR5+lcNv4TyH5EOazQ1IhJT91pOSQlYs/6BMM Emg9GMsECWYEIWRUrtYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltRei-005Y7d-6U; Wed, 16 Jun 2021 09:16:16 +0000 Received: from mail-eopbgr150073.outbound.protection.outlook.com ([40.107.15.73] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltRdu-005Xmb-8f for linux-arm-kernel@lists.infradead.org; Wed, 16 Jun 2021 09:15:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ieMOd+ARO1qTxMoQB9msDin4YxiS7S7RujlzV8Dm8PsBhW1NSzxvy3wEPYg+hyU8vFYa7helqjyZ5Yd+Gc4HsAc5IZGroTh53GpD0XODm5YsP0HHh2BDCSrlNkbEGjVTk65YIiRIAPp13GQfXoeeZVmJ4RAN27sMV9SS0woBJTr5WQzhDlcP80T5MtiVbhvKkdJpdIZDzoJtaJcmlMGVLnqQ4gfneR2q7gSVrMYz/n8Pe3VEWstFAitpvy+pPwfqwueo/ktUsrtlVzlzxyHmqDyFpgEGpZy7MfRi8ofZXOkQQw8QLCl1rm2PZDanj5rxNGBcOfQV/7hdwKhrgQ6IRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GUl1y4Jg7eMgXIC0FjWdnqzMrqLRLNIwrz3uZb/tj9o=; b=OFYbgunRCJ/nhEnbUaijZgqk5WZFQMG0uI7JcXOtl/bPCOSHzpsxMKjMFUIb7oNsVAHjCVHWCJwsK3gHfIs+anpSB7LWrtO4lyzH4DqJIYqeXhI0rrSpyWQo5uMXdpnaul0o7I8Sp3Hg5eFs51vtHBavNqegsMUIK2W4dICIxaRwVU3gT1NlgVbPhffsHQ7gIEm72s8ZjGJN//riuTZG/ic5n2maCTOJZlq/z+3eadRXdOjSu/J97cMGz5Fi96IhR5GgO5CIibcksglFUMHhliym+4fUy2dYL3cQNvYc9UHvxDLV5AWI06s8rHtmjE+kVuzOhYrOuHnVBdHUYkqcqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GUl1y4Jg7eMgXIC0FjWdnqzMrqLRLNIwrz3uZb/tj9o=; b=mN5oqSojA8sUN5GgVKVB7HOp20seVjDxcm+NUJ/XY0XGe/v8rEv0MIHS123OCRV7R1w+QSHU8qVsQYlpAyQ6WmGjmWaW5r6IdzO9jga/vIT0aFZ4qNnbc2RNZmvtM6zkgFU7/SVaHbnhxQ0IXwqyBJWiXyfwAEarqLPEP/MbqTw= Authentication-Results: davemloft.net; dkim=none (message not signed) header.d=none;davemloft.net; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) by VI1PR04MB4735.eurprd04.prod.outlook.com (2603:10a6:803:53::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.22; Wed, 16 Jun 2021 09:15:23 +0000 Received: from VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::d48b:48ed:c060:78de]) by VI1PR04MB6800.eurprd04.prod.outlook.com ([fe80::d48b:48ed:c060:78de%7]) with mapi id 15.20.4242.016; Wed, 16 Jun 2021 09:15:23 +0000 From: Joakim Zhang To: davem@davemloft.net, kuba@kernel.org, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, mcoquelin.stm32@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com Subject: [PATCH net 1/2] net: fec_ptp: add clock rate zero check Date: Wed, 16 Jun 2021 17:14:25 +0800 Message-Id: <20210616091426.13694-2-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210616091426.13694-1-qiangqing.zhang@nxp.com> References: <20210616091426.13694-1-qiangqing.zhang@nxp.com> X-Originating-IP: [119.31.174.71] X-ClientProxiedBy: SG2PR02CA0081.apcprd02.prod.outlook.com (2603:1096:4:90::21) To VI1PR04MB6800.eurprd04.prod.outlook.com (2603:10a6:803:133::16) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0081.apcprd02.prod.outlook.com (2603:1096:4:90::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.18 via Frontend Transport; Wed, 16 Jun 2021 09:15:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69ac9730-82e5-4917-ccb7-08d930a74568 X-MS-TrafficTypeDiagnostic: VI1PR04MB4735: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:88; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9n96qghcHXq3Lkr6lpUNTaRoqkkARIF1x5aFBAb1jbb32hHguaVUxxk9TYmXdq8UMSpQc+stRRyzcX6qvi4FFWLosEioDr1JFfgR+WOKv3SeurxOOyxfowQ4sxD4yyhEk8UoO3dsXHPtNivV2OrlCxHYEFrAD4+Pwp6NJ8polUZKkYtCGbeqOvNAsA+/0+A5XX+139RgHHEdn1QTW+EuMvwVCZ+/IoU0XxfK7+gSsQD6NmMLmvfH2RQsAUAnAsBUWSD+y2Orvcc0QLzxTMiUP0u3P0Wzf4OKtaVDw+PhAatYXc1y5b8Ta8ZGt79NmWgciiEkswrmrRv/A5lyJUMk9KYytx3sVELLZJxWd1NfP0GHYGoVmAFcYNtGBCNCpV5RUgZ/CMcvytnBPlby+4uOyZFwCgpNRQJdPgH74AHN10A8voF0UWZAYqqznmkKmio8NfHUlacyEhwOqwH1wQ+gXRrKIlQRzhQaV36p+ZIcusIh26/ShzcHx5+PNEGX8STFvJjR7vNq2tNC/JfTU4XLs+Ka9T0XxTcxhMPYCcWvezhHTzHuOcWPVjMcgwOLCcOt2yjhRA2ewvGhf23RMh9+wcoICy8yWRJn1kAJFSU1l1e29Eddvs047tTKaPMMjgV1gLmxv087LD4p1YRJr+heOqSkWYBzq+F3JqgHmanScmiuEwt4ITUPV3z3Oxy1Uupn X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB6800.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(376002)(39860400002)(346002)(396003)(136003)(2906002)(36756003)(1076003)(186003)(38100700002)(26005)(83380400001)(16526019)(6512007)(8936002)(38350700002)(6506007)(66476007)(956004)(6486002)(86362001)(2616005)(5660300002)(8676002)(4326008)(316002)(7416002)(66946007)(4744005)(478600001)(66556008)(52116002)(69590400013); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R9uFp25LTkmoujxbVOZ72RypVA9+vvZlqSqGryRAEU7w7IJBQLjiG9RDjiHsWqkjwdT6raITBCigZNd0slc5b2agrUrcnw+vZ7pP/YVlA5gO1tBI5Kpus4Nofp1z+D7jqzb1lDcI2dFcb/t97naKd9P4rgAXukIzwqNlr1GzeJVMs5ev7sveIX+Hqc13OZqJY9fgpZigIbxqCfJTPTsHXsKs0CBpv/fM0TTxcncg3kNRn5s0wsqXi39EXuYD+s0i58UXs2fkwfHjuBnAAaCTkgsPveQRGHeFPupEzX1kSFemrvsp5yFnrCwfGIwOuCJY8D0nyrFk8xi13S78/kCmMFQpzAaFvd/vx4ssIbUSGQZxTDa+3+d2ibyWgDZAz7ZPkjPQsd0hjHwf+N4oV4EFnNMLv9eWzq5HCScYLM5XW3JnyJo0SV6HWF/bTwr3lmPlXPPTfxuUkw/Pud/lp0fQrw5WksGYgL9cFIQSdCQFdQJnf2wM23zp6PT0ol4CdxV67nE/bqxYof6TJ0ELCLvBL2hAlhBbiiacYRi3FnRp4htF3vrx4Zil5yHj95FCeDbK8pT4VD+iUU0LLa6oyUD0Hb4RsfON6X6MceZgQtpNwswCjCaLoR3C3VNN4kn3UJhIuknq4f9T2GrFCsULHnNmbBpyvf6oxxzoC1i8csqWTCaU6uvcVN5UmjSFpn68f9w06wDPf7VEPX8/G0fyVzz3IbxQQIxXiqqthPwY7H8FS+YqbSaxej8NiraG06/erSdKTEt+QOusJY1D3ckaXFPGTyKtqdPbRprB+kGI7TZzJp4WiU4t1wiDFkEKrm7jRcIY3uDSOsNb89KW8p3OLVKLXrZtQJdUvDu3xUuNBiFM4say8sj2xvdSPFyfbB3vCU0T2xSmQL3p2nN14aCtSuntt7gibhiY4kiuTHA8JVu/6w60wXEYbTVQXMi6qazf2v1F/XZ8pAvuXnK7o2OURbNFxDe1Qhe6SV/qASzbz0curhTHal5bXGkJGsgVTooWW363hDH2Yr6pjQcrYBNmV16igEpCT2pc9cQtsFfeOeQWKqheV9NqZXESxt3VZ1IfMo8ioZuLA/vymwBjkEG/8Ps3+fBi+AAPZY7uujh+31bNWmY9iZ808HN5UlQ8QEk5ANfOSH5i/ax3agMocpLhV1Bt+SRm/Zs/EjMTugEeuK/uX767JeVcUpfdlY3CSkQYN3t0UFhxyudIhsmZsShNRuHjcNCOAPhz8uvr6gkQO1f7Hcmynzx/qG5v8+kTuks+ZbmDGhUVq3lQ8Yru56Zq2opncDxnrfIbPoFtoSqeru3HWTiWxCSrcN0ggPhB9nq3rETL X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69ac9730-82e5-4917-ccb7-08d930a74568 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB6800.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jun 2021 09:15:23.4740 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1OJ6HLmOPIE8UJvGxzNx1PS7lU5sn3gyQCQw4GFu9NKw9cgD33pKgcV68ejS3ZGILyQ8QErZ3FkmcCiv6Ev0nQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4735 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210616_021526_378752_A9ADB5F2 X-CRM114-Status: UNSURE ( 9.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Fugang Duan Add clock rate zero check to fix coverity issue of "divide by 0". Fixes: commit 85bd1798b24a ("net: fec: fix spin_lock dead lock") Signed-off-by: Fugang Duan Signed-off-by: Joakim Zhang --- drivers/net/ethernet/freescale/fec_ptp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c index 1753807cbf97..7326a0612823 100644 --- a/drivers/net/ethernet/freescale/fec_ptp.c +++ b/drivers/net/ethernet/freescale/fec_ptp.c @@ -604,6 +604,10 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx) fep->ptp_caps.enable = fec_ptp_enable; fep->cycle_speed = clk_get_rate(fep->clk_ptp); + if (!fep->cycle_speed) { + fep->cycle_speed = NSEC_PER_SEC; + dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n"); + } fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed; spin_lock_init(&fep->tmreg_lock);