From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 31A0BC43381 for ; Wed, 20 Mar 2019 13:42:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F301A2184D for ; Wed, 20 Mar 2019 13:42:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="fpAlI1DZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbfCTNmj (ORCPT ); Wed, 20 Mar 2019 09:42:39 -0400 Received: from mail-eopbgr810055.outbound.protection.outlook.com ([40.107.81.55]:21321 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727141AbfCTNmj (ORCPT ); Wed, 20 Mar 2019 09:42:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=No7F+TFr4t3WGkzlfoLIbeS5GYNXc4YPUYMq2DktRnc=; b=fpAlI1DZb1cG51NFhaMzZ7jmECurQJwUdcf9mHkYvzPgUTTofaYPOdlnYQKrGsGuHpVtbl32KUKbXfq4QsBBSAbX+1TdPvJtBMjqJIGgMEpzyjCD13aAZvlyEHxh+Fb2mcj9YfwFH1kmwo5Gw6/tBQZqTqWaOi/CNKgAXmOg6gU= Received: from SN4PR0201CA0013.namprd02.prod.outlook.com (2603:10b6:803:2b::23) by BLUPR02MB1652.namprd02.prod.outlook.com (2a01:111:e400:525f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15; Wed, 20 Mar 2019 13:42:36 +0000 Received: from BL2NAM02FT034.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::204) by SN4PR0201CA0013.outlook.office365.com (2603:10b6:803:2b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1709.13 via Frontend Transport; Wed, 20 Mar 2019 13:42:35 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; gmail.com; dkim=none (message not signed) header.d=none;gmail.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by BL2NAM02FT034.mail.protection.outlook.com (10.152.77.161) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1730.9 via Frontend Transport; Wed, 20 Mar 2019 13:42:35 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1h6bUI-0000VU-Ty; Wed, 20 Mar 2019 06:42:34 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1h6bUD-0008V6-QC; Wed, 20 Mar 2019 06:42:29 -0700 Received: from xsj-pvapsmtp01 (xsj-pvapsmtp01.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id x2KDgS54012466; Wed, 20 Mar 2019 06:42:28 -0700 Received: from [172.23.37.92] (helo=xhdharinik40.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1h6bUB-0008UV-OK; Wed, 20 Mar 2019 06:42:28 -0700 From: Harini Katakam To: , CC: , , , , Subject: [PATCH] net: macb: Add null check for PCLK and HCLK Date: Wed, 20 Mar 2019 19:12:22 +0530 Message-ID: <1553089342-2789-1-git-send-email-harini.katakam@xilinx.com> X-Mailer: git-send-email 2.7.4 X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(396003)(39850400004)(376002)(346002)(2980300002)(199004)(189003)(4326008)(478600001)(336012)(426003)(36386004)(81156014)(81166006)(2906002)(8676002)(486006)(50466002)(2616005)(476003)(126002)(44832011)(36756003)(48376002)(186003)(77096007)(26005)(9786002)(316002)(8936002)(50226002)(51416003)(107886003)(63266004)(16586007)(7696005)(106002)(110136005)(54906003)(106466001)(305945005)(5660300002)(47776003)(356004)(6666004);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR02MB1652;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;LANG:en;PTR:unknown-60-83.xilinx.com;A:1;MX:1; MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 943f78d6-edea-484c-bbf1-08d6ad39e939 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4608103)(4709054)(2017052603328)(7153060);SRVR:BLUPR02MB1652; X-MS-TrafficTypeDiagnostic: BLUPR02MB1652: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-Forefront-PRVS: 098291215C X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: KBnRFgQRLILjRP1SI2sJCk+fYvOc4pyTGOtpqWH+7tXvVjZC9KvKQbvzP+Ii0C6aF5aa28rv1QoEWcBTHzAV9rN6IRhmKRrE6Q1rWXvduZ2O0Taam153YvvCl0cpRy+UY34tbfBtQVKhmuHM+nrcdOo1i0x4xu9XvjOSdOfmF4mgW7RZ4S/VeEzVFZKGxAbaqEXCUk8dHOAQ6X6ustEnAsqRIpLjA/6w1slyaF9c9t8tqrfw+XDx24r/BxggPoMYUULvZq9F5zbqAyKIdvI6JYxWv4RSpL3OsObkGn+0K+9mTAksEk/I3Ly1EfDnZqn5T5GXVXsNjB9eERJpVJXwSiGI9JxFSMqiMAdSj2Mn4ivaqOlcadseobm4aisVJej1+oeE1us9u1sx6aFAEBuuxUBAYlbrRh6scUn3QvZAyuY= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2019 13:42:35.5378 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 943f78d6-edea-484c-bbf1-08d6ad39e939 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB1652 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Both PCLK and HCLK are "required" clocks according to macb devicetree documentation. There is a chance that devm_clk_get doesn't return a negative error but just a NULL clock structure instead. In such a case the driver proceeds as usual and uses pclk value 0 to calculate MDC divisor which is incorrect. Hence fix the same in clock initialization. Signed-off-by: Harini Katakam --- Changes from RFC: Use IS_ERR_OR_NULL Add error for NULL condition drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 98c2352..a44171f 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3370,14 +3370,20 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk, *hclk = devm_clk_get(&pdev->dev, "hclk"); } - if (IS_ERR(*pclk)) { + if (IS_ERR_OR_NULL(*pclk)) { err = PTR_ERR(*pclk); + if (!err) + err = -ENODEV; + dev_err(&pdev->dev, "failed to get macb_clk (%u)\n", err); return err; } - if (IS_ERR(*hclk)) { + if (IS_ERR_OR_NULL(*hclk)) { err = PTR_ERR(*hclk); + if (!err) + err = -ENODEV; + dev_err(&pdev->dev, "failed to get hclk (%u)\n", err); return err; } -- 2.7.4