All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Aviad Krawczyk <aviad.krawczyk@huawei.com>
Cc: davem@davemloft.net, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, bc.y@huawei.com,
	victor.gissin@huawei.com, zhaochen6@huawei.com,
	tony.qu@huawei.com
Subject: Re: [PATCH net 01/20] net/hinic: Initialize hw interface
Date: Wed, 12 Jul 2017 17:29:33 +0200	[thread overview]
Message-ID: <20170712152933.GF2557@lunn.ch> (raw)
In-Reply-To: <281a172bd66298acb1a176a03a53710c1b777fb6.1499865197.git.aviad.krawczyk@huawei.com>

> +
> +#define HINIC_DRV_NAME		"HiNIC"
> +#define HINIC_DRV_VERSION	"1.0"

Hi Aviad

Please don't add a driver version. There was a discussion about this
recently, how pointless it is.

> +/**
> + * hinic_init_hwdev - Initialize the NIC HW
> + * @hwdev: the NIC HW device that is returned from the initialization
> + * @pdev: the NIC pci device
> + *
> + * Return 0 - Success, negative - Failure
> + *
> + * Initialize the NIC HW device and return a pointer to it in the first arg
> + **/
> +int hinic_init_hwdev(struct hinic_hwdev **hwdev, struct pci_dev *pdev)
> +{
> +	struct hinic_pfhwdev *pfhwdev;
> +	struct hinic_hwif *hwif;
> +	int err;
> +
> +	hwif = kzalloc(sizeof(*hwif), GFP_KERNEL);

Using the devm_ functions makes your cleanup code simpler when
handling memory.

> +/**
> + * nic_dev_init - Initialize the NIC device
> + * @pdev: the NIC pci device
> + *
> + * Return 0 - Success, negative - Failure
> + **/
> +static int nic_dev_init(struct pci_dev *pdev)
> +{
> +	struct hinic_dev *nic_dev;
> +	struct net_device *netdev;
> +	struct hinic_hwdev *hwdev;
> +	int err, num_qps;
> +
> +	err = hinic_init_hwdev(&hwdev, pdev);
> +	if (err) {
> +		dev_err(&pdev->dev, "Failed to initialize HW device\n");
> +		return err;
> +	}
> +
> +	num_qps = hinic_hwdev_num_qps(hwdev);
> +	if (num_qps <= 0) {
> +		dev_err(&pdev->dev, "Invalid number of QPS\n");
> +		err = -EINVAL;
> +		goto num_qps_err;
> +	}
> +
> +	netdev = alloc_etherdev_mq(sizeof(*nic_dev), num_qps);
> +	if (!netdev) {
> +		pr_err("Failed to allocate Ethernet device\n");

Above you used dev_err, here you used pr_err(). Please be consistent.

> +		err = -ENOMEM;
> +		goto alloc_etherdev_err;
> +	}
> +
> +	netdev->netdev_ops = &hinic_netdev_ops;
> +
> +	nic_dev = (struct hinic_dev *)netdev_priv(netdev);
> +	nic_dev->hwdev = hwdev;
> +	nic_dev->netdev = netdev;
> +	nic_dev->msg_enable = MSG_ENABLE_DEFAULT;
> +
> +	pci_set_drvdata(pdev, netdev);
> +
> +	netif_carrier_off(netdev);
> +
> +	err = register_netdev(netdev);
> +	if (err) {
> +		netif_err(nic_dev, probe, netdev, "Failed to register netdev\n");

probably not a good idea to use netif_err, if register_netdev just
failed. dev_err() would be better.

  reply	other threads:[~2017-07-12 15:29 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-12 14:17 [PATCH net 00/20] Huawei HiNIC Ethernet Driver Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 01/20] net/hinic: Initialize hw interface Aviad Krawczyk
2017-07-12 15:29   ` Andrew Lunn [this message]
2017-07-13 13:14     ` Aviad Krawczyk (A)
2017-07-12 14:17 ` [PATCH net 02/20] nic/hinic: Initialize hw device components Aviad Krawczyk
2017-07-12 15:34   ` Andrew Lunn
2017-07-12 14:17 ` [PATCH net 03/20] net/hinic: Initialize api cmd resources Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 04/20] net/hinic: Initialize api cmd hw Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 05/20] net/hinic: Add management messages Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 06/20] net/hinic: Add api cmd commands Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 07/20] net/hinic: Add aeqs Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 08/20] net/hinic: Add port management commands Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 09/20] net/hinic: Add Rx mode and link event handler Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 10/20] net/hinic: Add logical Txq and Rxq Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 11/20] net/hinic: Add wq Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 12/20] net/hinic: Add qp resources Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 13/20] net/hinic: Set qp context Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 14/20] net/hinic: Initialize cmdq Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 15/20] net/hinic: Add ceqs Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 16/20] net/hinic: Add cmdq commands Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 17/20] net/hinic: Add cmdq completion handler Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 18/20] net/hinic: Add Rx handler Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 19/20] net/hinic: Add Tx operation Aviad Krawczyk
2017-07-12 14:17 ` [PATCH net 20/20] net/hinic: Add ethtool and stats Aviad Krawczyk
2017-07-12 15:43   ` Andrew Lunn
2017-07-13 13:16     ` Aviad Krawczyk (A)
2017-07-12 15:10 ` [PATCH net 00/20] Huawei HiNIC Ethernet Driver David Miller

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=20170712152933.GF2557@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=aviad.krawczyk@huawei.com \
    --cc=bc.y@huawei.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tony.qu@huawei.com \
    --cc=victor.gissin@huawei.com \
    --cc=zhaochen6@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 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.