netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: Tony Prisk <linux@prisktech.co.nz>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHv8 3/3] net: velocity: Add platform device support to VIA velocity driver
Date: Sat, 18 May 2013 20:55:26 +0200	[thread overview]
Message-ID: <20130518185526.GA25486@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <1368853187-17823-4-git-send-email-linux@prisktech.co.nz>

Tony Prisk <linux@prisktech.co.nz> :
[...]
> diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
> index 5996cee..d8d5bc5 100644
> --- a/drivers/net/ethernet/via/via-velocity.c
> +++ b/drivers/net/ethernet/via/via-velocity.c
[...]
> @@ -84,6 +88,16 @@
>  static int velocity_nics;
>  static int msglevel = MSG_LEVEL_INFO;
>  
> +static void velocity_set_power_state(struct velocity_info *vptr, char state)
> +{
> +	void *addr = vptr->mac_regs;

Your choice but it's only used once.

[...]
> @@ -1353,9 +1366,12 @@ static void velocity_init_registers(struct velocity_info *vptr,
>  		velocity_soft_reset(vptr);
>  		mdelay(5);
>  
> -		mac_eeprom_reload(regs);
> -		for (i = 0; i < 6; i++)
> -			writeb(vptr->netdev->dev_addr[i], &(regs->PAR[i]));
> +		if (!vptr->no_eeprom) {
> +			mac_eeprom_reload(regs);
> +			for (i = 0; i < 6; i++)
> +				writeb(vptr->netdev->dev_addr[i],
> +							&(regs->PAR[i]));
> +		}

velocity_init_registers would not suffer from a local vptr->netdev variable.

If you change this code, you may replace &(regs->PAR[i]) with regs->PAR + i.

[...]
> @@ -2730,19 +2773,19 @@ static int velocity_found1(struct pci_dev *pdev,
>  	 * can support more than MAX_UNITS.
>  	 */
>  	if (velocity_nics >= MAX_UNITS) {
> -		dev_notice(&pdev->dev, "already found %d NICs.\n",
> -			   velocity_nics);
> +		dev_notice(dev, "already found %d NICs.\n", velocity_nics);
>  		return -ENODEV;
>  	}
>  
> -	dev = alloc_etherdev(sizeof(struct velocity_info));
> -	if (!dev)
> +	netdev = alloc_etherdev(sizeof(struct velocity_info));
> +	if (!netdev)
>  		goto out;
>  
>  	/* Chain it all together */
>  
> -	SET_NETDEV_DEV(dev, &pdev->dev);
> -	vptr = netdev_priv(dev);
> +	SET_NETDEV_DEV(netdev, dev);
> +	vptr = netdev_priv(netdev);
> +	memset(vptr, 0, sizeof(struct velocity_info));

memset is not needed (alloc_etherdev indirectly uses kzalloc).

[...]
> +static int velocity_pci_probe(struct pci_dev *pdev,
> +			   const struct pci_device_id *ent)

It does not seem to line up as it should.

> +{
> +	int ret;
> +	const struct velocity_info_tbl *info =
> +					&chip_info_table[ent->driver_data];

Long lines ought to come first.

> +
> +	ret = pci_enable_device(pdev);
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = pci_request_regions(pdev, VELOCITY_NAME);
> +	if (ret < 0) {
> +		dev_err(&pdev->dev, "No PCI resources.\n");
> +		pci_disable_device(pdev);
> +		return ret;
> +	}
> +
> +	ret = velocity_probe(&pdev->dev, pdev->irq, info, BUS_PCI);
> +	if (ret < 0) {
> +		pci_release_regions(pdev);
> +		pci_disable_device(pdev);
> +	}

Please use gotos for the error paths.

[...]
> @@ -3270,7 +3409,11 @@ static void velocity_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo
>  	struct velocity_info *vptr = netdev_priv(dev);
>  	strlcpy(info->driver, VELOCITY_NAME, sizeof(info->driver));

You may sneak an empty line after the declaration.

>  	strlcpy(info->version, VELOCITY_VERSION, sizeof(info->version));
> -	strlcpy(info->bus_info, pci_name(vptr->pdev), sizeof(info->bus_info));
> +	if (vptr->bustype == BUS_PCI)
> +		strlcpy(info->bus_info, pci_name(vptr->pdev),
> +						sizeof(info->bus_info));
> +	else
> +		strlcpy(info->bus_info, "platform", sizeof(info->bus_info));

	strlcpy(info->bus_info, vptr->pdev ? pci_name(vptr->pdev) : "platform",
		sizeof(info->bus_info));

>  static void velocity_ethtool_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
> @@ -3563,9 +3706,15 @@ static int __init velocity_init_module(void)
>  	int ret;
>  
>  	velocity_register_notifier();
> -	ret = pci_register_driver(&velocity_driver);
> +
> +	ret = pci_register_driver(&velocity_pci_driver);
> +	if (ret < 0)
> +		velocity_unregister_notifier();
> +
> +	ret = platform_driver_register(&velocity_platform_driver);
>  	if (ret < 0)
>  		velocity_unregister_notifier();
> +

I'd rather velocity_unregister_notifier iif both driver registrations
failed.

[...]
> diff --git a/drivers/net/ethernet/via/via-velocity.h b/drivers/net/ethernet/via/via-velocity.h
> index c38bbae..1d94612 100644
> --- a/drivers/net/ethernet/via/via-velocity.h
> +++ b/drivers/net/ethernet/via/via-velocity.h
[...]
> @@ -1433,10 +1433,17 @@ struct velocity_opt {
>  
>  #define GET_RD_BY_IDX(vptr, idx)   (vptr->rd_ring[idx])
>  
> +enum velocity_bus_type {
> +	BUS_PCI,
> +	BUS_PLATFORM,
> +};
> +
>  struct velocity_info {
> -	struct device *dev;
>  	struct pci_dev *pdev;
> +	struct device *dev;

Please don't move the fields you added.

>  	struct net_device *netdev;
> +	enum velocity_bus_type bustype;

velocity_bus_type is not really needed since you always have pdev to
check against.

-- 
Ueimor

      reply	other threads:[~2013-05-18 18:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-18  4:59 [PATCHv8 0/3] Add support for velocity network driver on platform devices Tony Prisk
2013-05-18  4:59 ` [PATCHv8 1/3] net: velocity: Rename vptr->dev to vptr->netdev Tony Prisk
2013-05-18  4:59 ` [PATCHv8 2/3] net: velocity: Convert to generic dma functions Tony Prisk
2013-05-18  4:59 ` [PATCHv8 3/3] net: velocity: Add platform device support to VIA velocity driver Tony Prisk
2013-05-18 18:55   ` Francois Romieu [this message]

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=20130518185526.GA25486@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@prisktech.co.nz \
    --cc=netdev@vger.kernel.org \
    /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).