All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Keith Busch <keith.busch@intel.com>
Cc: linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	linux-nvme@lists.infradead.org, Jens Axboe <axboe@fb.com>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH 2/2] nvme/pci: Enable SR-IOV capabilities
Date: Mon, 23 May 2016 12:06:52 -0500	[thread overview]
Message-ID: <20160523170652.GA12826@localhost> (raw)
In-Reply-To: <1463521199-16604-2-git-send-email-keith.busch@intel.com>

On Tue, May 17, 2016 at 03:39:59PM -0600, Keith Busch wrote:
> Registers a standard boiler-plate SR-IOV configure callback for NVMe.
> 
> Signed-off-by: Keith Busch <keith.busch@intel.com>
> ---
>  drivers/nvme/host/pci.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index fbe8cc2..8379b9a 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2033,6 +2033,18 @@ static void nvme_remove(struct pci_dev *pdev)
>  	nvme_put_ctrl(&dev->ctrl);
>  }
>  
> +static int nvme_sriov_configure(struct pci_dev *pdev, int numvfs)
> +{
> +	int ret = 0;
> +
> +	if (numvfs == 0)
> +		pci_disable_sriov(pdev);
> +	else
> +		ret = pci_enable_sriov(pdev, numvfs);
> +
> +	return ret ? ret : numvfs;
> +}

I do not subscribe to the belief that every function should have a
single exit.  In this case, I think it makes the function much harder
to understand than this:

  if (numvfs == 0)
    pci_disable_sriov(pdev);
    return 0;
  }

  return pci_enable_sriov(pdev, numvfs);

>  #ifdef CONFIG_PM_SLEEP
>  static int nvme_suspend(struct device *dev)
>  {
> @@ -2127,6 +2139,7 @@ static struct pci_driver nvme_driver = {
>  	.driver		= {
>  		.pm	= &nvme_dev_pm_ops,
>  	},
> +	.sriov_configure = nvme_sriov_configure,
>  	.err_handler	= &nvme_err_handler,
>  };
>  
> -- 
> 2.7.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: helgaas@kernel.org (Bjorn Helgaas)
Subject: [PATCH 2/2] nvme/pci: Enable SR-IOV capabilities
Date: Mon, 23 May 2016 12:06:52 -0500	[thread overview]
Message-ID: <20160523170652.GA12826@localhost> (raw)
In-Reply-To: <1463521199-16604-2-git-send-email-keith.busch@intel.com>

On Tue, May 17, 2016@03:39:59PM -0600, Keith Busch wrote:
> Registers a standard boiler-plate SR-IOV configure callback for NVMe.
> 
> Signed-off-by: Keith Busch <keith.busch at intel.com>
> ---
>  drivers/nvme/host/pci.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index fbe8cc2..8379b9a 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2033,6 +2033,18 @@ static void nvme_remove(struct pci_dev *pdev)
>  	nvme_put_ctrl(&dev->ctrl);
>  }
>  
> +static int nvme_sriov_configure(struct pci_dev *pdev, int numvfs)
> +{
> +	int ret = 0;
> +
> +	if (numvfs == 0)
> +		pci_disable_sriov(pdev);
> +	else
> +		ret = pci_enable_sriov(pdev, numvfs);
> +
> +	return ret ? ret : numvfs;
> +}

I do not subscribe to the belief that every function should have a
single exit.  In this case, I think it makes the function much harder
to understand than this:

  if (numvfs == 0)
    pci_disable_sriov(pdev);
    return 0;
  }

  return pci_enable_sriov(pdev, numvfs);

>  #ifdef CONFIG_PM_SLEEP
>  static int nvme_suspend(struct device *dev)
>  {
> @@ -2127,6 +2139,7 @@ static struct pci_driver nvme_driver = {
>  	.driver		= {
>  		.pm	= &nvme_dev_pm_ops,
>  	},
> +	.sriov_configure = nvme_sriov_configure,
>  	.err_handler	= &nvme_err_handler,
>  };
>  
> -- 
> 2.7.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-05-23 17:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17 21:39 [PATCH 1/2] pci: Error disabling SR-IOV if in VFs assigned Keith Busch
2016-05-17 21:39 ` Keith Busch
2016-05-17 21:39 ` [PATCH 2/2] nvme/pci: Enable SR-IOV capabilities Keith Busch
2016-05-17 21:39   ` Keith Busch
2016-05-23 10:52   ` Christoph Hellwig
2016-05-23 10:52     ` Christoph Hellwig
2016-05-23 17:06   ` Bjorn Helgaas [this message]
2016-05-23 17:06     ` Bjorn Helgaas
2016-05-23 17:09     ` Christoph Hellwig
2016-05-23 17:09       ` Christoph Hellwig
2016-05-23 17:21     ` Keith Busch
2016-05-23 17:21       ` Keith Busch
2016-05-23 21:51       ` Bjorn Helgaas
2016-05-23 21:51         ` Bjorn Helgaas
2016-05-17 22:08 ` [PATCH 1/2] pci: Error disabling SR-IOV if in VFs assigned Alex Williamson
2016-05-17 22:08   ` Alex Williamson
2016-05-23 10:55   ` Christoph Hellwig
2016-05-23 10:55     ` Christoph Hellwig
2016-05-23 15:07     ` Alex Williamson
2016-05-23 15:07       ` Alex Williamson
2016-05-23 15:10       ` Christoph Hellwig
2016-05-23 15:10         ` Christoph Hellwig
2016-06-13 21:14 ` Bjorn Helgaas
2016-06-13 21:14   ` Bjorn Helgaas
2016-06-13 21:28   ` Keith Busch
2016-06-13 21:28     ` Keith Busch
2016-06-13 21:57     ` Keith Busch
2016-06-13 21:57       ` Keith Busch
2016-06-13 22:26       ` Bjorn Helgaas
2016-06-13 22:26         ` Bjorn Helgaas
2016-06-13 22:35         ` Keith Busch
2016-06-13 22:35           ` Keith Busch
2016-06-15 10:26           ` Christoph Hellwig
2016-06-15 10:26             ` Christoph Hellwig
2016-06-15 15:38             ` Bjorn Helgaas
2016-06-15 15:38               ` Bjorn Helgaas

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=20160523170652.GA12826@localhost \
    --to=helgaas@kernel.org \
    --cc=axboe@fb.com \
    --cc=bhelgaas@google.com \
    --cc=hch@infradead.org \
    --cc=keith.busch@intel.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pci@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 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.