linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: Guangbin Huang <huangguangbin2@huawei.com>
Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, salil.mehta@huawei.com,
	lipeng321@huawei.com, tanhuazhong@huawei.com
Subject: Re: [RESEND net-next 1/2] net: hns3: add support for PTP
Date: Thu, 3 Jun 2021 06:18:46 -0700	[thread overview]
Message-ID: <20210603131846.GB6216@hoboy.vegasvil.org> (raw)
In-Reply-To: <1622602664-20274-2-git-send-email-huangguangbin2@huawei.com>

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.

> +
> +	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

  parent reply	other threads:[~2021-06-03 13:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02  2:57 [RESEND net-next 0/2] net: hns3: add support for PTP Guangbin Huang
2021-06-02  2:57 ` [RESEND net-next 1/2] " Guangbin Huang
2021-06-03 13:14   ` Richard Cochran
2021-06-05  9:54     ` huangguangbin (A)
2021-06-05 15:51       ` Richard Cochran
2021-06-07  2:20         ` huangguangbin (A)
2021-06-03 13:18   ` Richard Cochran [this message]
2021-06-05  9:57     ` huangguangbin (A)
2021-06-03 13:22   ` Richard Cochran
2021-06-05 10:37     ` huangguangbin (A)
2021-06-05 15:53       ` Richard Cochran
2021-06-07  2:44         ` huangguangbin (A)
2021-06-02  2:57 ` [RESEND net-next 2/2] net: hns3: add debugfs support for ptp info Guangbin Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210603131846.GB6216@hoboy.vegasvil.org \
    --to=richardcochran@gmail.com \
    --cc=davem@davemloft.net \
    --cc=huangguangbin2@huawei.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lipeng321@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=salil.mehta@huawei.com \
    --cc=tanhuazhong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).