linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -mm] BusLogic gcc 4.1 warning fixes
@ 2006-05-10 17:28 Daniel Walker
  2006-05-11 17:12 ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Walker @ 2006-05-10 17:28 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

This at least makes the used away of the failure .
---


I just commented out BusLogic_AbortCommand because the code that uses it is 
commented out the same way .. It could just be removed .

Fixes the following warnings,

drivers/scsi/BusLogic.c: In function 'BusLogic_init':
drivers/scsi/BusLogic.c:2302: warning: ignoring return value of 'scsi_add_host', declared with attribute warn_unused_result
drivers/scsi/BusLogic.c: At top level:
drivers/scsi/BusLogic.c:2963: warning: 'BusLogic_AbortCommand' defined but not used

Signed-Off-By: Daniel Walker <dwalker@mvista.com>

Index: linux-2.6.16/drivers/scsi/BusLogic.c
===================================================================
--- linux-2.6.16.orig/drivers/scsi/BusLogic.c
+++ linux-2.6.16/drivers/scsi/BusLogic.c
@@ -2299,7 +2299,8 @@ static int __init BusLogic_init(void)
 				scsi_host_put(Host);
 			} else {
 				BusLogic_InitializeHostStructure(HostAdapter, Host);
-				scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL);
+				if (scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL))
+					printk(KERN_WARNING "BusLogic: scsi_add_host() failed!\n");
 				scsi_scan_host(Host);
 				BusLogicHostAdapterCount++;
 			}
@@ -2955,6 +2956,7 @@ static int BusLogic_QueueCommand(struct 
 }
 
 
+#if 0
 /*
   BusLogic_AbortCommand aborts Command if possible.
 */
@@ -3025,6 +3027,7 @@ static int BusLogic_AbortCommand(struct 
 	return SUCCESS;
 }
 
+#endif
 /*
   BusLogic_ResetHostAdapter resets Host Adapter if possible, marking all
   currently executing SCSI Commands as having been Reset.

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

* Re: [PATCH -mm] BusLogic gcc 4.1 warning fixes
  2006-05-10 17:28 [PATCH -mm] BusLogic gcc 4.1 warning fixes Daniel Walker
@ 2006-05-11 17:12 ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2006-05-11 17:12 UTC (permalink / raw)
  To: Daniel Walker; +Cc: linux-kernel, linux-scsi

Daniel Walker <dwalker@mvista.com> wrote:
>
> This at least makes the used away of the failure .
> ---
> 
> 
> I just commented out BusLogic_AbortCommand because the code that uses it is 
> commented out the same way .. It could just be removed .
> 
> Fixes the following warnings,
> 
> drivers/scsi/BusLogic.c: In function 'BusLogic_init':
> drivers/scsi/BusLogic.c:2302: warning: ignoring return value of 'scsi_add_host', declared with attribute warn_unused_result
> drivers/scsi/BusLogic.c: At top level:
> drivers/scsi/BusLogic.c:2963: warning: 'BusLogic_AbortCommand' defined but not used
> 
> Signed-Off-By: Daniel Walker <dwalker@mvista.com>
> 
> Index: linux-2.6.16/drivers/scsi/BusLogic.c
> ===================================================================
> --- linux-2.6.16.orig/drivers/scsi/BusLogic.c
> +++ linux-2.6.16/drivers/scsi/BusLogic.c
> @@ -2299,7 +2299,8 @@ static int __init BusLogic_init(void)
>  				scsi_host_put(Host);
>  			} else {
>  				BusLogic_InitializeHostStructure(HostAdapter, Host);
> -				scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL);
> +				if (scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL))
> +					printk(KERN_WARNING "BusLogic: scsi_add_host() failed!\n");
>  				scsi_scan_host(Host);
>  				BusLogicHostAdapterCount++;
>  			}
> @@ -2955,6 +2956,7 @@ static int BusLogic_QueueCommand(struct 
>  }

Methinks that if scsi_add_host() fails we'll need to do more serious things
here - we cannot just go ahead and pretend that it worked.

So it's best to leave the warning there for now.

The appropriate recovery code is just a few lines up from here - reusing
that might be appropriate.  And while you're there, this function should
return -Esomething if it failed, rather than pretending to work.


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

* [PATCH -mm] BusLogic gcc 4.1 warning fixes
@ 2006-05-11 20:30 Daniel Walker
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Walker @ 2006-05-11 20:30 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, alan


Here's another attempt . 

- Reworked all the very long lines in that block (this drivers full of them though)
- Returns an error in three places that it didn't before.
- Properly clean up after a scsi_add_host() failure .

Signed-Off-By: Daniel Walker <dwalker@mvista.com>

Index: linux-2.6.16/drivers/scsi/BusLogic.c
===================================================================
--- linux-2.6.16.orig/drivers/scsi/BusLogic.c
+++ linux-2.6.16/drivers/scsi/BusLogic.c
@@ -2177,6 +2177,7 @@ static int __init BusLogic_init(void)
 {
 	int BusLogicHostAdapterCount = 0, DriverOptionsIndex = 0, ProbeIndex;
 	struct BusLogic_HostAdapter *PrototypeHostAdapter;
+	int ret = 0;	
 
 #ifdef MODULE
 	if (BusLogic)
@@ -2282,26 +2283,50 @@ static int __init BusLogic_init(void)
 		   Create the Initial CCBs, Initialize the Host Adapter, and finally
 		   perform Target Device Inquiry.
 		 */
-		if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) &&
-		    BusLogic_ReportHostAdapterConfiguration(HostAdapter) && BusLogic_AcquireResources(HostAdapter) && BusLogic_CreateInitialCCBs(HostAdapter) && BusLogic_InitializeHostAdapter(HostAdapter) && BusLogic_TargetDeviceInquiry(HostAdapter)) {
+		if (BusLogic_ReadHostAdapterConfiguration(HostAdapter) && 
+		    BusLogic_ReportHostAdapterConfiguration(HostAdapter) && 
+		    BusLogic_AcquireResources(HostAdapter) && 
+		    BusLogic_CreateInitialCCBs(HostAdapter) && 
+		    BusLogic_InitializeHostAdapter(HostAdapter) && 
+		    BusLogic_TargetDeviceInquiry(HostAdapter)) {
 			/*
 			   Initialization has been completed successfully.  Release and
 			   re-register usage of the I/O Address range so that the Model
 			   Name of the Host Adapter will appear, and initialize the SCSI
 			   Host structure.
 			 */
-			release_region(HostAdapter->IO_Address, HostAdapter->AddressCount);
-			if (!request_region(HostAdapter->IO_Address, HostAdapter->AddressCount, HostAdapter->FullModelName)) {
-				printk(KERN_WARNING "BusLogic: Release and re-register of " "port 0x%04lx failed \n", (unsigned long) HostAdapter->IO_Address);
+			release_region(HostAdapter->IO_Address, 
+				       HostAdapter->AddressCount);
+			if (!request_region(HostAdapter->IO_Address, 
+					    HostAdapter->AddressCount, 
+					    HostAdapter->FullModelName)) {
+				printk(KERN_WARNING 
+					"BusLogic: Release and re-register of " 
+					"port 0x%04lx failed \n", 
+					(unsigned long)HostAdapter->IO_Address);
 				BusLogic_DestroyCCBs(HostAdapter);
 				BusLogic_ReleaseResources(HostAdapter);
 				list_del(&HostAdapter->host_list);
 				scsi_host_put(Host);
+				ret = -ENOMEM;
 			} else {
-				BusLogic_InitializeHostStructure(HostAdapter, Host);
-				scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL);
-				scsi_scan_host(Host);
-				BusLogicHostAdapterCount++;
+				BusLogic_InitializeHostStructure(HostAdapter, 
+								 Host);
+				if (scsi_add_host(Host, HostAdapter->PCI_Device 
+						? &HostAdapter->PCI_Device->dev 
+						  : NULL)) {
+					printk(KERN_WARNING 
+					       "BusLogic: scsi_add_host()"
+					       "failed!\n");
+					BusLogic_DestroyCCBs(HostAdapter);
+					BusLogic_ReleaseResources(HostAdapter);
+					list_del(&HostAdapter->host_list);
+					scsi_host_put(Host);
+					ret = -ENODEV;
+				} else {
+					scsi_scan_host(Host);
+					BusLogicHostAdapterCount++;
+				}
 			}
 		} else {
 			/*
@@ -2316,12 +2341,13 @@ static int __init BusLogic_init(void)
 			BusLogic_ReleaseResources(HostAdapter);
 			list_del(&HostAdapter->host_list);
 			scsi_host_put(Host);
+			ret = -ENODEV;
 		}
 	}
 	kfree(PrototypeHostAdapter);
 	kfree(BusLogic_ProbeInfoList);
 	BusLogic_ProbeInfoList = NULL;
-	return 0;
+	return ret;
 }
 
 
@@ -2955,6 +2981,7 @@ static int BusLogic_QueueCommand(struct 
 }
 
 
+#if 0
 /*
   BusLogic_AbortCommand aborts Command if possible.
 */
@@ -3025,6 +3052,7 @@ static int BusLogic_AbortCommand(struct 
 	return SUCCESS;
 }
 
+#endif
 /*
   BusLogic_ResetHostAdapter resets Host Adapter if possible, marking all
   currently executing SCSI Commands as having been Reset.

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

* Re: [PATCH -mm] BusLogic gcc 4.1 warning fixes
  2006-05-10  2:55 Daniel Walker
  2006-05-10  8:26 ` Christoph Hellwig
@ 2006-05-10 10:44 ` Alan Cox
  1 sibling, 0 replies; 6+ messages in thread
From: Alan Cox @ 2006-05-10 10:44 UTC (permalink / raw)
  To: Daniel Walker; +Cc: akpm, linux-kernel

On Maw, 2006-05-09 at 19:55 -0700, Daniel Walker wrote:
> I just commented out BusLogic_AbortCommand because the code that uses it is 
> commented out the same way .. It could just be removed .

Adds another leak in the failure case.
Agree about the AbortCommand function.


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

* Re: [PATCH -mm] BusLogic gcc 4.1 warning fixes
  2006-05-10  2:55 Daniel Walker
@ 2006-05-10  8:26 ` Christoph Hellwig
  2006-05-10 10:44 ` Alan Cox
  1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2006-05-10  8:26 UTC (permalink / raw)
  To: Daniel Walker; +Cc: akpm, linux-kernel

On Tue, May 09, 2006 at 07:55:56PM -0700, Daniel Walker wrote:
> I just commented out BusLogic_AbortCommand because the code that uses it is 
> commented out the same way .. It could just be removed .
> 
> Fixes the following warnings,
> 
> drivers/scsi/BusLogic.c: In function 'BusLogic_init':
> drivers/scsi/BusLogic.c:2302: warning: ignoring return value of 'scsi_add_host', declared with attribute warn_unused_result
> drivers/scsi/BusLogic.c: At top level:
> drivers/scsi/BusLogic.c:2963: warning: 'BusLogic_AbortCommand' defined but not used

this needs real error handling instead of just returning.  freeing resources
and so on.  similar for the other patches I guess.


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

* [PATCH -mm] BusLogic gcc 4.1 warning fixes
@ 2006-05-10  2:55 Daniel Walker
  2006-05-10  8:26 ` Christoph Hellwig
  2006-05-10 10:44 ` Alan Cox
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Walker @ 2006-05-10  2:55 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel

I just commented out BusLogic_AbortCommand because the code that uses it is 
commented out the same way .. It could just be removed .

Fixes the following warnings,

drivers/scsi/BusLogic.c: In function 'BusLogic_init':
drivers/scsi/BusLogic.c:2302: warning: ignoring return value of 'scsi_add_host', declared with attribute warn_unused_result
drivers/scsi/BusLogic.c: At top level:
drivers/scsi/BusLogic.c:2963: warning: 'BusLogic_AbortCommand' defined but not used

Signed-Off-By: Daniel Walker <dwalker@mvista.com>

Index: linux-2.6.16/drivers/scsi/BusLogic.c
===================================================================
--- linux-2.6.16.orig/drivers/scsi/BusLogic.c
+++ linux-2.6.16/drivers/scsi/BusLogic.c
@@ -2299,7 +2299,8 @@ static int __init BusLogic_init(void)
 				scsi_host_put(Host);
 			} else {
 				BusLogic_InitializeHostStructure(HostAdapter, Host);
-				scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL);
+				if (scsi_add_host(Host, HostAdapter->PCI_Device ? &HostAdapter->PCI_Device->dev : NULL))
+					return -ENODEV;
 				scsi_scan_host(Host);
 				BusLogicHostAdapterCount++;
 			}
@@ -2955,6 +2956,7 @@ static int BusLogic_QueueCommand(struct 
 }
 
 
+#if 0
 /*
   BusLogic_AbortCommand aborts Command if possible.
 */
@@ -3025,6 +3027,7 @@ static int BusLogic_AbortCommand(struct 
 	return SUCCESS;
 }
 
+#endif
 /*
   BusLogic_ResetHostAdapter resets Host Adapter if possible, marking all
   currently executing SCSI Commands as having been Reset.

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

end of thread, other threads:[~2006-05-11 20:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-10 17:28 [PATCH -mm] BusLogic gcc 4.1 warning fixes Daniel Walker
2006-05-11 17:12 ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2006-05-11 20:30 Daniel Walker
2006-05-10  2:55 Daniel Walker
2006-05-10  8:26 ` Christoph Hellwig
2006-05-10 10:44 ` Alan Cox

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).