From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by dpdk.org (Postfix) with ESMTP id 244E7B365 for ; Fri, 18 Jul 2014 18:14:16 +0200 (CEST) Received: by mail-pa0-f47.google.com with SMTP id kx10so5708522pab.34 for ; Fri, 18 Jul 2014 09:15:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-type:content-disposition; bh=cnItj5UW/gci2AYAqtclxIq9xoUg4irSg5ECavVOYAE=; b=mIIEf+XGJaftyDK00w1FaaqLRmsvWU4H00uShBQV12HKD+gdZOP/KC0a5dRhQhzmTV 3NuHRMla27Ze4/npVoNQzq1LzK+itTvjlXRN4UlFUFoTkhcvfmphTCyMTsnk+/rVNVoC b3PSyXrXf9ICbR0FzBr4akdKJpd4Wbl23LzRoqfyZO2q+Zsd8Y9LeWZ/7tbMK7AAro7d O0hOsmrNCYRASluBOFjvDeHIyUbvRZLBP8ZDQJZK7l1YVjSCsejJYixId7CLt9QaF0ll pQkRmLr48ORFpUIN8HQBuQHSx8NJKBVKWeITcf59u7kg25BfwHB5bbXvc+ygm6gyy9OA gtbg== X-Gm-Message-State: ALoCoQk3atWI3aEAWxtNf42SSZoBNS9+5DgnSNtPUKikpGjKduZ/NCr1Z0Sv7+v4PUD28adMjixk X-Received: by 10.66.100.170 with SMTP id ez10mr6570361pab.12.1405700117537; Fri, 18 Jul 2014 09:15:17 -0700 (PDT) Received: from localhost (static-50-53-66-61.bvtn.or.frontiernet.net. [50.53.66.61]) by mx.google.com with ESMTPSA id ph6sm7979004pdb.93.2014.07.18.09.15.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jul 2014 09:15:16 -0700 (PDT) Message-Id: <20140718161519.551536376@networkplumber.org> User-Agent: quilt/0.63-1 Date: Fri, 18 Jul 2014 09:14:52 -0700 From: Stephen Hemminger To: Thomas Monjalon References: <20140718161447.020882834@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=igb_uio-error-handling.patch Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH 05/10] igb_uio: propogate error numbers in probe code X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jul 2014 16:14:17 -0000 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 --- 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