Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp575965img; Wed, 20 Mar 2019 06:43:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoJ0jRL85U4SW1vuB8IttC9RQqlRIfr7d4Hcr5oVXSQ+HHfrx879QPehg5wJ9mqmYfPWl7 X-Received: by 2002:a63:d4f:: with SMTP id 15mr7478060pgn.162.1553089412534; Wed, 20 Mar 2019 06:43:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553089412; cv=none; d=google.com; s=arc-20160816; b=vydSYntefshruW9/EOofkkGe4fNAKH2p6lln5fQ3fUCl0J5ym0bBLOvUIufNQFLHgJ CS9T8AunPo49DtDVRtD9NxgfwQmkfZiPN9pO5DgCes/kUQuIKVz1pu3mvcuLphimrvy8 bs28F741/LZZaREM0c0zeCTB2yj+pGwb84l/jIY7TmJzhLSlm7jRs6ectm9g8aqCmjqJ 0H3d3OXpzEYm3K18tL3y0WZd0xMS/cOMklnqv+OJ4F6A34TSqyAe2AS7fVngwjIz5c1W uLwS6OhffPYKmcCXyw9YVRtqk+D7igbcW442lysTDfEHMuD2A1xkh9k2AZ6EKDBuuHam 7v2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=No7F+TFr4t3WGkzlfoLIbeS5GYNXc4YPUYMq2DktRnc=; b=YxMNNZs/e78B6aA9yCoLadutv4QWxfjYvu0V7f9wifLPiwkoBqUVu5jV250KpNyTGj qGzXyX2nBQ0KYR8RYFbw/JhMP2Ehdflq/P8m9Ph70u7/AOKVcvQE2nlNkViHZE08E+FR gqDiJyy3U08J7ukls7MtjfXFu/WDvsKrIinj1enZAKZqM4cxPWxHw9N443NVek2ixtGV V1vYcR5CVSLz/70L/xUL0KlDu5V4qb5DeEJrl9tYeaF+6v4NCSrAMTxkoZEXDHo4M/n2 w9LYgA7CND1xlGwVoJdBfR7SeBb+56hztXFeHTJ4TWAlFtuvBoFGs57F4W1U8HAIu7/m ZI+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=fpAlI1DZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x22si1890748plr.111.2019.03.20.06.43.17; Wed, 20 Mar 2019 06:43:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=fpAlI1DZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbfCTNmj (ORCPT + 99 others); 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