DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Thomas Monjalon <thomas.monjalon@6wind.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 05/10] igb_uio: propogate error numbers in probe code
Date: Fri, 18 Jul 2014 09:14:52 -0700	[thread overview]
Message-ID: <20140718161519.551536376@networkplumber.org> (raw)
In-Reply-To: <20140718161447.020882834@networkplumber.org>

[-- Attachment #1: igb_uio-error-handling.patch --]
[-- Type: text/plain, Size: 3145 bytes --]

It is good practice to propogate the return values of failing
functions so that more information can be reported. The failed result
of probe will make it out to errno and get printed by modprobe
and will aid in diagnosis of failures.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


--- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-18 08:42:22.856545033 -0700
+++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c	2014-07-18 08:42:47.500631562 -0700
@@ -518,7 +518,7 @@ igbuio_setup_bars(struct pci_dev *dev, s
 		}
 	}
 
-	return ((iom != 0) ? ret : ENOENT);
+	return (iom != 0) ? ret : -ENOENT;
 }
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
@@ -530,6 +530,7 @@ igbuio_pci_probe(struct pci_dev *dev, co
 {
 	struct rte_uio_pci_dev *udev;
 	struct msix_entry msix_entry;
+	int err;
 
 	udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL);
 	if (!udev)
@@ -539,7 +540,8 @@ igbuio_pci_probe(struct pci_dev *dev, co
 	 * enable device: ask low-level code to enable I/O and
 	 * memory
 	 */
-	if (pci_enable_device(dev)) {
+	err = pci_enable_device(dev);
+	if (err != 0) {
 		dev_err(&dev->dev, "Cannot enable PCI device\n");
 		goto fail_free;
 	}
@@ -548,7 +550,8 @@ igbuio_pci_probe(struct pci_dev *dev, co
 	 * reserve device's PCI memory regions for use by this
 	 * module
 	 */
-	if (pci_request_regions(dev, "igb_uio")) {
+	err = pci_request_regions(dev, "igb_uio");
+	if (err != 0) {
 		dev_err(&dev->dev, "Cannot request regions\n");
 		goto fail_disable;
 	}
@@ -557,14 +560,19 @@ igbuio_pci_probe(struct pci_dev *dev, co
 	pci_set_master(dev);
 
 	/* remap IO memory */
-	if (igbuio_setup_bars(dev, &udev->info))
+	err = igbuio_setup_bars(dev, &udev->info);
+	if (err != 0)
 		goto fail_release_iomem;
 
 	/* set 64-bit DMA mask */
-	if (pci_set_dma_mask(dev,  DMA_BIT_MASK(64))) {
+	err = pci_set_dma_mask(dev,  DMA_BIT_MASK(64));
+	if (err != 0) {
 		dev_err(&dev->dev, "Cannot set DMA mask\n");
 		goto fail_release_iomem;
-	} else if (pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(64))) {
+	}
+
+	err = pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(64));
+	if (err != 0) {
 		dev_err(&dev->dev, "Cannot set consistent DMA mask\n");
 		goto fail_release_iomem;
 	}
@@ -613,19 +621,22 @@ igbuio_pci_probe(struct pci_dev *dev, co
 	pci_set_drvdata(dev, udev);
 	igbuio_pci_irqcontrol(&udev->info, 0);
 
-	if (sysfs_create_group(&dev->dev.kobj, &dev_attr_grp))
+	err = sysfs_create_group(&dev->dev.kobj, &dev_attr_grp);
+	if (err != 0)
 		goto fail_release_iomem;
 
 	/* register uio driver */
-	if (uio_register_device(&dev->dev, &udev->info))
-		goto fail_release_iomem;
+	err = uio_register_device(&dev->dev, &udev->info);
+	if (err != 0)
+		goto fail_remove_group;
 
 	printk(KERN_INFO "uio device registered with irq %lx\n", udev->info.irq);
 
 	return 0;
 
-fail_release_iomem:
+fail_remove_group:
 	sysfs_remove_group(&dev->dev.kobj, &dev_attr_grp);
+fail_release_iomem:
 	igbuio_pci_release_iomem(&udev->info);
 	if (udev->mode == RTE_INTR_MODE_MSIX)
 		pci_disable_msix(udev->pdev);
@@ -635,7 +646,7 @@ fail_disable:
 fail_free:
 	kfree(udev);
 
-	return -ENODEV;
+	return err;
 }
 
 static void

  parent reply	other threads:[~2014-07-18 16:14 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18 16:14 [dpdk-dev] [PATCH 00/10] igb_uio related patches Stephen Hemminger
2014-07-18 16:14 ` [dpdk-dev] [PATCH 01/10] igb_uio: use kernel standard log message Stephen Hemminger
2014-07-18 16:14 ` [dpdk-dev] [PATCH 02/10] igb_uio: use standard uio naming Stephen Hemminger
2014-07-18 16:14 ` [dpdk-dev] [PATCH 03/10] igb_uio: dont wrap pci_num_vf function needlessly Stephen Hemminger
2014-07-23  8:20   ` Thomas Monjalon
2014-07-18 16:14 ` [dpdk-dev] [PATCH 04/10] igb_uio: msix cleanups Stephen Hemminger
2014-07-18 16:14 ` Stephen Hemminger [this message]
2014-07-18 16:14 ` [dpdk-dev] [PATCH 06/10] igb_uio: make irq mode param read-only Stephen Hemminger
2014-07-18 16:14 ` [dpdk-dev] [PATCH 07/10] igb_uio: fix IRQ mode handling Stephen Hemminger
2014-07-18 16:14 ` [dpdk-dev] [PATCH 08/10] igb_uio: add missing locking to config access Stephen Hemminger
2014-07-18 16:14 ` [dpdk-dev] [PATCH 09/10] igb_uio: allow msi mode Stephen Hemminger
2014-07-18 16:14 ` [dpdk-dev] [PATCH 10/10] igb_uio: fix check patch warnings Stephen Hemminger
2014-07-19  0:16 ` [dpdk-dev] [PATCH 00/10] igb_uio related patches Thomas Monjalon
2014-07-20  8:14   ` Yerden Zhumabekov
2014-07-21 10:28     ` Thomas Monjalon
2014-07-21 12:03       ` [dpdk-dev] [igb_uio PATCH 0/3] igb_uio: fixed typos and pci lock/unlock calls Yerden Zhumabekov
2014-07-21 12:03         ` [dpdk-dev] [igb_uio PATCH 1/3] igb_uio: fixed typos Yerden Zhumabekov
2014-07-21 12:03         ` [dpdk-dev] [igb_uio PATCH 2/3] igb_uio: pci_config_lock/pci_config_unlock wrappers Yerden Zhumabekov
2014-07-21 20:42           ` Stephen Hemminger
2014-07-21 20:50             ` Thomas Monjalon
2014-07-22 12:57             ` Thomas Monjalon
2014-07-21 12:03         ` [dpdk-dev] [igb_uio PATCH 3/3] igb_uio: renaming pci config lock/unlock functions Yerden Zhumabekov
2014-07-21 19:51         ` [dpdk-dev] [igb_uio PATCH 0/3] igb_uio: fixed typos and pci lock/unlock calls Thomas Monjalon
2014-07-22 13:07         ` Thomas Monjalon
2014-07-24 21:50           ` Thomas Monjalon
2014-07-25 16:51             ` Stephen Hemminger
2014-07-21 15:38       ` [dpdk-dev] [PATCH " Yerden Zhumabekov
2014-07-21 15:38         ` [dpdk-dev] [PATCH 1/3] igb_uio: fixed typos Yerden Zhumabekov
2014-07-21 15:38         ` [dpdk-dev] [PATCH 2/3] igb_uio: pci_config_lock/pci_config_unlock wrappers Yerden Zhumabekov
2014-07-21 15:38         ` [dpdk-dev] [PATCH 3/3] igb_uio: renaming pci config lock/unlock functions Yerden Zhumabekov
2014-07-21 19:54         ` [dpdk-dev] [PATCH 0/3] igb_uio: fixed typos and pci lock/unlock calls Thomas Monjalon

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=20140718161519.551536376@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=thomas.monjalon@6wind.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 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).