Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1782168pxj; Sat, 5 Jun 2021 02:59:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6Lj04ulae1gAM45827cUuNbt1uzNJ047Dl7Oa95tDPHVoIHBKCpZUwByiXzFJMXEOCpeT X-Received: by 2002:aa7:dc51:: with SMTP id g17mr9419533edu.43.1622887140384; Sat, 05 Jun 2021 02:59:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622887140; cv=none; d=google.com; s=arc-20160816; b=HSDKaLEEG6keH4zACvOiVqW0fCksEKARrUUnju9olGAaOsM9OmXE7q6OQeMQrlJsZY yt/H6dmeSzwNMw+EyLJ3RKnmXD5XxwEMCNdn4p1SHT5bSGulWnvBQ6fdmjQIwqcrt94B QVh1IFKjf/K6NOq7H3Uei7XpYl2rRBnusVCnM8BdlYGNvFRsauQw7a8wvytyHbQgqHgR gscs/kgkzdO3LI0GnkKYJyNfqfaoq/E1cM26NvLiW9n040z8SjYlbbkb1qnW4JzBNZao JXocHc5+hnXAd0Ntd46xAOPKqcBF94QaFAkotFhwA/LfnRHVCHi1IdcScR0sf2y9oPjv zvKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=tmLRryM4pcv1uQ17qgJfij4EVxkb5XUjwBye2gEucAI=; b=XZAWD+YS7NIo7KCipP+NHPIA4ZhHs6s9KMK2+EAPMRZiOpHENU7SdmpmciXQGePtqo hCyE9P7A6jLJvw9EBGSB5W8vBNzMZFAZJG700Md3X3cKI8RaXLrG6oxVCntmY1SvYtLU 4EJ2pufXYABoMAcmfq25kgS/RK0iJkJEtk6hZJWLG7BDr2hOopKpJdSs1muzzvDF1aup vybH7ShDHa7fQskBL0L31vmk1YS+v3hWpFkVfJve4GYVX11zq7K7PJKcQArmxNhrMsLQ YE1Pkd1ALabpo0mvXrY9zKTak9v9JoRpiHoGCQlK3l152BByt4IeA/b8WFU2j6A4d2uB 8nNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i22si6963661ejr.660.2021.06.05.02.58.37; Sat, 05 Jun 2021 02:59:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230025AbhFEJ6w (ORCPT + 99 others); Sat, 5 Jun 2021 05:58:52 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:4483 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbhFEJ6w (ORCPT ); Sat, 5 Jun 2021 05:58:52 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Fxw2c09bmzYd7L; Sat, 5 Jun 2021 17:54:16 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Sat, 5 Jun 2021 17:57:02 +0800 Received: from [10.67.102.67] (10.67.102.67) by dggemi759-chm.china.huawei.com (10.1.198.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Sat, 5 Jun 2021 17:57:02 +0800 Subject: Re: [RESEND net-next 1/2] net: hns3: add support for PTP To: Richard Cochran CC: , , , , , , References: <1622602664-20274-1-git-send-email-huangguangbin2@huawei.com> <1622602664-20274-2-git-send-email-huangguangbin2@huawei.com> <20210603131846.GB6216@hoboy.vegasvil.org> From: "huangguangbin (A)" Message-ID: <9dd4b064-216d-7bef-2399-aa2b2b0d170f@huawei.com> Date: Sat, 5 Jun 2021 17:57:02 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20210603131846.GB6216@hoboy.vegasvil.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.67] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggemi759-chm.china.huawei.com (10.1.198.145) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/6/3 21:18, Richard Cochran wrote: > On Wed, Jun 02, 2021 at 10:57:43AM +0800, Guangbin Huang wrote: > >> +static int hclge_ptp_create_clock(struct hclge_dev *hdev) >> +{ >> +#define HCLGE_PTP_NAME_LEN 32 >> + >> + struct hclge_ptp *ptp; >> + >> + ptp = devm_kzalloc(&hdev->pdev->dev, sizeof(*ptp), GFP_KERNEL); >> + if (!ptp) >> + return -ENOMEM; >> + >> + ptp->hdev = hdev; >> + snprintf(ptp->info.name, HCLGE_PTP_NAME_LEN, "%s", >> + HCLGE_DRIVER_NAME); >> + ptp->info.owner = THIS_MODULE; >> + ptp->info.max_adj = HCLGE_PTP_CYCLE_ADJ_MAX; >> + ptp->info.n_ext_ts = 0; >> + ptp->info.pps = 0; >> + ptp->info.adjfreq = hclge_ptp_adjfreq; >> + ptp->info.adjtime = hclge_ptp_adjtime; >> + ptp->info.gettimex64 = hclge_ptp_gettimex; >> + ptp->info.settime64 = hclge_ptp_settime; >> + >> + ptp->info.n_alarm = 0; >> + ptp->clock = ptp_clock_register(&ptp->info, &hdev->pdev->dev); >> + if (IS_ERR(ptp->clock)) { >> + dev_err(&hdev->pdev->dev, "%d failed to register ptp clock, ret = %ld\n", >> + ptp->info.n_alarm, PTR_ERR(ptp->clock)); >> + return PTR_ERR(ptp->clock); >> + } > > You must handle the case where NULL is returned. > > * ptp_clock_register() - register a PTP hardware clock driver > * > * @info: Structure describing the new clock. > * @parent: Pointer to the parent device of the new clock. > * > * Returns a valid pointer on success or PTR_ERR on failure. If PHC > * support is missing at the configuration level, this function > * returns NULL, and drivers are expected to gracefully handle that > * case separately. > Ok, thank you. >> + >> + ptp->io_base = hdev->hw.io_base + HCLGE_PTP_REG_OFFSET; >> + ptp->ts_cfg.rx_filter = HWTSTAMP_FILTER_NONE; >> + ptp->ts_cfg.tx_type = HWTSTAMP_TX_OFF; >> + hdev->ptp = ptp; >> + >> + return 0; >> +} > > Thanks, > Richard > . >