From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f49.google.com (mail-pb0-f49.google.com [209.85.160.49]) by dpdk.org (Postfix) with ESMTP id 9299D68B8 for ; Sat, 7 Jun 2014 01:50:58 +0200 (CEST) Received: by mail-pb0-f49.google.com with SMTP id jt11so3049783pbb.8 for ; Fri, 06 Jun 2014 16:51:12 -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=Ukb7yUuYhGEbIXmZHXsRExeUFlQL0nUsUQzBJP8plFI=; b=Kl+FUcvMmQVcYsVqvEEBkzaPa89M3Vfj07kN5A+awj2nmFF/x3F4rXX3mgI1ZFxDWd PFojqNA6vL/M4SimmWLHb8dbD71SnDNly0/JZU5bHPfu7n0/TeM5D6vSM/FX5LUOdRZi viXUQVIJO9ABGyH7z99W0ymdOfmrSlq3qzGMyo8PrV9F0mMwdq1Q8K5PBYM2MA8NABWL 9m4qVQhN4M0ebM89A3eWEFIgwfnJFHP7V2YlOrx2hJXqaEclb9IAQVrHR/CT19ieYhnI jr2g1uKPJgPfANqJjEChp8FUl1FutPUss203SUbUPqpH0qkKwdbb5PIEp0EnUXBD6MjH FFfA== X-Gm-Message-State: ALoCoQmNd3mqES+tcHJ/xpJfrT08hMtVLuyOD6pKUb8KTEy+s8uf098Mh+poewYw4O26QQ9spTkV X-Received: by 10.68.194.202 with SMTP id hy10mr6039146pbc.94.1402098671889; Fri, 06 Jun 2014 16:51:11 -0700 (PDT) Received: from localhost (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id om6sm40888856pbc.43.2014.06.06.16.51.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jun 2014 16:51:11 -0700 (PDT) Message-Id: <20140606235110.128026435@networkplumber.org> User-Agent: quilt/0.63-1 Date: Fri, 06 Jun 2014 16:50:34 -0700 From: Stephen Hemminger To: Alan Carew References: <20140606235028.189345212@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 v2 06/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, 06 Jun 2014 23:50:59 -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 +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -442,7 +442,7 @@ } } - return ((iom != 0) ? ret : ENOENT); + return (iom != 0) ? ret : -ENOENT; } #if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) @@ -453,6 +453,7 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { struct rte_uio_pci_dev *udev; + int err; udev = kzalloc(sizeof(struct rte_uio_pci_dev), GFP_KERNEL); if (!udev) @@ -462,7 +463,8 @@ * 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; } @@ -471,7 +473,8 @@ * 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; } @@ -480,14 +483,19 @@ 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; } @@ -536,12 +544,14 @@ break; } - 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; pci_set_drvdata(dev, udev); @@ -550,8 +560,9 @@ 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 == IGBUIO_MSIX_INTR_MODE) pci_disable_msix(udev->pdev); @@ -561,7 +572,7 @@ fail_free: kfree(udev); - return -ENODEV; + return err; } static void