Re: [PATCH v2 01/15] net: rnpgbe: Add build support for rnpgbe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +++ b/Documentation/networking/device_drivers/ethernet/index.rst
> @@ -61,6 +61,7 @@ Contents:
>     wangxun/txgbevf
>     wangxun/ngbe
>     wangxun/ngbevf
> +   mucse/rnpgbe

This list is sorted. Please keep with the order.

Sorting happens all other the kernel. Please keep an eye out of it,
and ensure you insert into the correct location.

> +++ b/drivers/net/ethernet/Kconfig
> @@ -202,5 +202,6 @@ source "drivers/net/ethernet/wangxun/Kconfig"
>  source "drivers/net/ethernet/wiznet/Kconfig"
>  source "drivers/net/ethernet/xilinx/Kconfig"
>  source "drivers/net/ethernet/xircom/Kconfig"
> +source "drivers/net/ethernet/mucse/Kconfig"

Another sorted list.

> +#include <linux/types.h>
> +#include <linux/module.h>
> +#include <linux/pci.h>
> +#include <linux/netdevice.h>
> +#include <linux/string.h>
> +#include <linux/etherdevice.h>

It is also reasonably normal to sort includes.

> +static int rnpgbe_add_adapter(struct pci_dev *pdev)
> +{
> +	struct mucse *mucse = NULL;
> +	struct net_device *netdev;
> +	static int bd_number;
> +
> +	netdev = alloc_etherdev_mq(sizeof(struct mucse), 1);

If you only have one queue, you might as well use alloc_etherdev().

> +	if (!netdev)
> +		return -ENOMEM;
> +
> +	mucse = netdev_priv(netdev);
> +	mucse->netdev = netdev;
> +	mucse->pdev = pdev;
> +	mucse->bd_number = bd_number++;
> +	snprintf(mucse->name, sizeof(netdev->name), "%s%d",
> +		 rnpgbe_driver_name, mucse->bd_number);

That looks wrong. The point of the n in snprintf is to stop you
overwriting the end of the destination buffer. Hence you should be
passing the length of the destination buffer, not the source buffer.

I've not looked at how mucse->name is used, but why do you need yet
another name for the device? There is pdev->dev->name, and soon there
will be netdev->name. Having yet another name just makes it confusing.

	Andrew




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux