All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: Igor Russkikh <Igor.Russkikh@aquantia.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	Egor Pomozov <Egor.Pomozov@aquantia.com>,
	Dmitry Bezrukov <Dmitry.Bezrukov@aquantia.com>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	Simon Edelhaus <sedelhaus@marvell.com>,
	Sergey Samoilenko <Sergey.Samoilenko@aquantia.com>
Subject: Re: [PATCH v2 net-next 01/12] net: aquantia: PTP skeleton declarations and callbacks
Date: Sat, 12 Oct 2019 11:49:35 -0700	[thread overview]
Message-ID: <20191012184935.GI3165@localhost> (raw)
In-Reply-To: <91d1e1181a01005ef04610241bffb9032f4669b8.1570531332.git.igor.russkikh@aquantia.com>

On Tue, Oct 08, 2019 at 10:56:36AM +0000, Igor Russkikh wrote:

> diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> new file mode 100644
> index 000000000000..d5a28904f708
> --- /dev/null
> +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
> @@ -0,0 +1,93 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/* Aquantia Corporation Network Driver
> + * Copyright (C) 2014-2019 Aquantia Corporation. All rights reserved
> + */
> +
> +/* File aq_ptp.c:
> + * Definition of functions for Linux PTP support.
> + */
> +
> +#include <linux/ptp_clock_kernel.h>
> +#include <linux/clocksource.h>
> +
> +#include "aq_nic.h"
> +#include "aq_ptp.h"
> +
> +struct aq_ptp_s {
> +	struct aq_nic_s *aq_nic;
> +

Nit: no blank line here.

> +	struct ptp_clock *ptp_clock;
> +	struct ptp_clock_info ptp_info;
> +};
> +
> +static struct ptp_clock_info aq_ptp_clock = {
> +	.owner		= THIS_MODULE,
> +	.name		= "atlantic ptp",
> +	.n_ext_ts	= 0,
> +	.pps		= 0,
> +	.n_per_out     = 0,
> +	.n_pins        = 0,
> +	.pin_config    = NULL,

Nit: use tabs to align columns (here some are spaces).

> +};
> +
> +int aq_ptp_init(struct aq_nic_s *aq_nic, unsigned int idx_vec)
> +{
> +	struct hw_atl_utils_mbox mbox;
> +	struct ptp_clock *clock;
> +	struct aq_ptp_s *aq_ptp;
> +	int err = 0;
> +
> +	hw_atl_utils_mpi_read_stats(aq_nic->aq_hw, &mbox);
> +
> +	if (!(mbox.info.caps_ex & BIT(CAPS_EX_PHY_PTP_EN))) {
> +		aq_nic->aq_ptp = NULL;
> +		return 0;
> +	}
> +
> +	aq_ptp = kzalloc(sizeof(*aq_ptp), GFP_KERNEL);
> +	if (!aq_ptp) {
> +		err = -ENOMEM;
> +		goto err_exit;
> +	}
> +
> +	aq_ptp->aq_nic = aq_nic;
> +
> +	aq_ptp->ptp_info = aq_ptp_clock;
> +	clock = ptp_clock_register(&aq_ptp->ptp_info, &aq_nic->ndev->dev);
> +	if (!clock) {
> +		netdev_err(aq_nic->ndev, "ptp_clock_register failed\n");
> +		err = 0;
> +		goto err_exit;
> +	}

You need to test for PTR_ERR and NULL:

 * 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.

> +	aq_ptp->ptp_clock = clock;
> +
> +	aq_nic->aq_ptp = aq_ptp;
> +
> +	return 0;
> +
> +err_exit:
> +	kfree(aq_ptp);
> +	aq_nic->aq_ptp = NULL;
> +	return err;
> +}

Thanks,
Richard

  reply	other threads:[~2019-10-12 18:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-08 10:56 [PATCH v2 net-next 00/12] net: aquantia: PTP support for AQC devices Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 01/12] net: aquantia: PTP skeleton declarations and callbacks Igor Russkikh
2019-10-12 18:49   ` Richard Cochran [this message]
2019-10-12 18:56   ` Richard Cochran
2019-10-08 10:56 ` [PATCH v2 net-next 02/12] net: aquantia: unify styling of bit enums Igor Russkikh
2019-10-14 15:50   ` Andrew Lunn
2019-10-08 10:56 ` [PATCH v2 net-next 03/12] net: aquantia: add basic ptp_clock callbacks Igor Russkikh
2019-10-12 19:02   ` Richard Cochran
2019-10-14 11:43     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 04/12] net: aquantia: add PTP rings infrastructure Igor Russkikh
2019-10-14 16:14   ` Andrew Lunn
2019-10-15  9:02     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 05/12] net: aquantia: styling fixes on ptp related functions Igor Russkikh
2019-10-14 16:16   ` Andrew Lunn
2019-10-08 10:56 ` [PATCH v2 net-next 06/12] net: aquantia: implement data PTP datapath Igor Russkikh
2019-10-14 16:36   ` Andrew Lunn
2019-10-15  9:09     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 07/12] net: aquantia: rx filters for ptp Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 08/12] net: aquantia: add support for ptp ioctls Igor Russkikh
2019-10-14 16:23   ` Andrew Lunn
2019-10-15  9:06     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 09/12] net: aquantia: implement get_ts_info ethtool Igor Russkikh
2019-10-12 19:07   ` Richard Cochran
2019-10-14 11:45     ` Igor Russkikh
2019-10-08 10:56 ` [PATCH v2 net-next 10/12] net: aquantia: add support for Phy access Igor Russkikh
2019-10-15 12:19   ` Andrew Lunn
2019-10-16 13:12     ` Igor Russkikh
2019-10-16 19:38       ` Andrew Lunn
2019-10-08 10:56 ` [PATCH v2 net-next 11/12] net: aquantia: add support for PIN funcs Igor Russkikh
2019-10-12 19:25   ` Richard Cochran
2019-10-15 12:35   ` Andrew Lunn
2019-10-08 10:57 ` [PATCH v2 net-next 12/12] net: aquantia: adding atlantic ptp maintainer Igor Russkikh

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=20191012184935.GI3165@localhost \
    --to=richardcochran@gmail.com \
    --cc=Dmitry.Bezrukov@aquantia.com \
    --cc=Egor.Pomozov@aquantia.com \
    --cc=Igor.Russkikh@aquantia.com \
    --cc=Sergey.Samoilenko@aquantia.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=sedelhaus@marvell.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.