public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* fix a few missing return value checks in scsi
@ 2003-12-31 13:59 Arjan van de Ven
  2003-12-31 14:35 ` Jeff Garzik
  0 siblings, 1 reply; 3+ messages in thread
From: Arjan van de Ven @ 2003-12-31 13:59 UTC (permalink / raw)
  To: linux-scsi


[-- Attachment #1.1: Type: text/plain, Size: 193 bytes --]

Hi,

The attached patch adds a few error checks for the pci dma_mask setting
routines, which after all can fail and thus need their return code
checked.

Greetings,
   Arjan van de Ven

[-- Attachment #1.2: pci.patch --]
[-- Type: text/x-patch, Size: 2652 bytes --]

--- linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm.c.OLD	2003-12-19 16:26:15.000000000 -0500
+++ linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm.c	2003-12-19 16:29:17.000000000 -0500
@@ -1408,12 +1408,18 @@
 	 * our dma mask when doing allocations.
 	 */
 	if (ahc->dev_softc != NULL)
-		ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF);
+		if (ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) {
+			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 	*vaddr = pci_alloc_consistent(ahc->dev_softc,
 				      dmat->maxsize, &map->bus_addr);
 	if (ahc->dev_softc != NULL)
-		ahc_pci_set_dma_mask(ahc->dev_softc,
-				     ahc->platform_data->hw_dma_mask);
+		if (ahc_pci_set_dma_mask(ahc->dev_softc,
+				     ahc->platform_data->hw_dma_mask)) {
+			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 	/*
 	 * At least in 2.2.14, malloc is a slab allocator so all
--- linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c.OLD	2003-12-19 16:30:32.000000000 -0500
+++ linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c	2003-12-19 16:31:43.000000000 -0500
@@ -168,7 +168,10 @@
 		ahc->flags |= AHC_39BIT_ADDRESSING;
 		ahc->platform_data->hw_dma_mask = mask_39bit;
 	} else {
-		ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF);
+		if (ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
+			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
+                	return (-ENODEV);
+		}
 		ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
 	}
 #endif
--- linux-2.6.0-test11/drivers/scsi/aic7xxx/aic79xx_osm.c.OLD	2003-12-19 16:34:01.000000000 -0500
+++ linux-2.6.0-test11/drivers/scsi/aic7xxx/aic79xx_osm.c	2003-12-19 16:35:11.000000000 -0500
@@ -1776,12 +1776,18 @@
 	 * our dma mask when doing allocations.
 	 */
 	if (ahd->dev_softc != NULL)
-		ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF);
+		if (ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) {
+			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 	*vaddr = pci_alloc_consistent(ahd->dev_softc,
 				      dmat->maxsize, &map->bus_addr);
 	if (ahd->dev_softc != NULL)
-		ahd_pci_set_dma_mask(ahd->dev_softc,
-				     ahd->platform_data->hw_dma_mask);
+		if (ahd_pci_set_dma_mask(ahd->dev_softc,
+				     ahd->platform_data->hw_dma_mask)) {
+			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
+			return (ENODEV);
+		}
 #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
 	/*
 	 * At least in 2.2.14, malloc is a slab allocator so all

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fix a few missing return value checks in scsi
  2003-12-31 13:59 fix a few missing return value checks in scsi Arjan van de Ven
@ 2003-12-31 14:35 ` Jeff Garzik
  2003-12-31 14:38   ` Arjan van de Ven
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2003-12-31 14:35 UTC (permalink / raw)
  To: arjanv; +Cc: linux-scsi

Arjan van de Ven wrote:
> Hi,
> 
> The attached patch adds a few error checks for the pci dma_mask setting
> routines, which after all can fail and thus need their return code
> checked.
> 
> Greetings,
>    Arjan van de Ven
> 
> 
> ------------------------------------------------------------------------
> 
> --- linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm.c.OLD	2003-12-19 16:26:15.000000000 -0500
> +++ linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm.c	2003-12-19 16:29:17.000000000 -0500
> @@ -1408,12 +1408,18 @@
>  	 * our dma mask when doing allocations.
>  	 */
>  	if (ahc->dev_softc != NULL)
> -		ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF);
> +		if (ahc_pci_set_dma_mask(ahc->dev_softc, 0xFFFFFFFF)) {
> +			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
> +			return (ENODEV);
> +		}
>  	*vaddr = pci_alloc_consistent(ahc->dev_softc,
>  				      dmat->maxsize, &map->bus_addr);
>  	if (ahc->dev_softc != NULL)
> -		ahc_pci_set_dma_mask(ahc->dev_softc,
> -				     ahc->platform_data->hw_dma_mask);
> +		if (ahc_pci_set_dma_mask(ahc->dev_softc,
> +				     ahc->platform_data->hw_dma_mask)) {
> +			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
> +			return (ENODEV);
> +		}
>  #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
>  	/*
>  	 * At least in 2.2.14, malloc is a slab allocator so all
> --- linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c.OLD	2003-12-19 16:30:32.000000000 -0500
> +++ linux-2.6.0-test11/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c	2003-12-19 16:31:43.000000000 -0500
> @@ -168,7 +168,10 @@
>  		ahc->flags |= AHC_39BIT_ADDRESSING;
>  		ahc->platform_data->hw_dma_mask = mask_39bit;
>  	} else {
> -		ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF);
> +		if (ahc_pci_set_dma_mask(pdev, 0xFFFFFFFF)) {
> +			printk(KERN_WARNING "aic7xxx: No suitable DMA available.\n");
> +                	return (-ENODEV);
> +		}
>  		ahc->platform_data->hw_dma_mask = 0xFFFFFFFF;
>  	}
>  #endif
> --- linux-2.6.0-test11/drivers/scsi/aic7xxx/aic79xx_osm.c.OLD	2003-12-19 16:34:01.000000000 -0500
> +++ linux-2.6.0-test11/drivers/scsi/aic7xxx/aic79xx_osm.c	2003-12-19 16:35:11.000000000 -0500
> @@ -1776,12 +1776,18 @@
>  	 * our dma mask when doing allocations.
>  	 */
>  	if (ahd->dev_softc != NULL)
> -		ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF);
> +		if (ahd_pci_set_dma_mask(ahd->dev_softc, 0xFFFFFFFF)) {
> +			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
> +			return (ENODEV);
> +		}
>  	*vaddr = pci_alloc_consistent(ahd->dev_softc,
>  				      dmat->maxsize, &map->bus_addr);
>  	if (ahd->dev_softc != NULL)
> -		ahd_pci_set_dma_mask(ahd->dev_softc,
> -				     ahd->platform_data->hw_dma_mask);
> +		if (ahd_pci_set_dma_mask(ahd->dev_softc,
> +				     ahd->platform_data->hw_dma_mask)) {
> +			printk(KERN_WARNING "aic79xx: No suitable DMA available.\n");
> +			return (ENODEV);
> +		}
>  #else /* LINUX_VERSION_CODE < KERNEL_VERSION(2,3,0) */
>  	/*
>  	 * At least in 2.2.14, malloc is a slab allocator so all


No offense to you personally, but this is a bunch of crap.  aic7xxx 
needs to use the standard kernel APIs for pci_set_dma_mask and 
pci_set_consistent_dma_mask...

We don't need a wrapper for every kernel API function :(

	Jeff




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fix a few missing return value checks in scsi
  2003-12-31 14:35 ` Jeff Garzik
@ 2003-12-31 14:38   ` Arjan van de Ven
  0 siblings, 0 replies; 3+ messages in thread
From: Arjan van de Ven @ 2003-12-31 14:38 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-scsi

On Wed, Dec 31, 2003 at 09:35:26AM -0500, Jeff Garzik wrote:
> 
> 
> No offense to you personally, but this is a bunch of crap.  aic7xxx 
> needs to use the standard kernel APIs for pci_set_dma_mask and 
> pci_set_consistent_dma_mask...
> 
> We don't need a wrapper for every kernel API function :(

that's an entirely different argument that I entirely agree with....

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-12-31 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-31 13:59 fix a few missing return value checks in scsi Arjan van de Ven
2003-12-31 14:35 ` Jeff Garzik
2003-12-31 14:38   ` Arjan van de Ven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox