linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.6 patch] SCSI dc395x.c: make a function static
@ 2004-11-15  1:56 Adrian Bunk
  2004-11-15 20:22 ` Jamie Lenehan
  0 siblings, 1 reply; 5+ messages in thread
From: Adrian Bunk @ 2004-11-15  1:56 UTC (permalink / raw)
  To: oliver, aliakc, lenehan; +Cc: James.Bottomley, linux-scsi, linux-kernel

The patch below makes the needlessly global function adapter_init_chip 
static.


Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.10-rc1-mm5-full/drivers/scsi/dc395x.c.old	2004-11-13 20:58:56.000000000 +0100
+++ linux-2.6.10-rc1-mm5-full/drivers/scsi/dc395x.c	2004-11-13 20:59:09.000000000 +0100
@@ -4447,7 +4447,7 @@
  *
  * @acb: The adapter which we are to init.
  **/
-void __init adapter_init_chip(struct AdapterCtlBlk *acb)
+static void __init adapter_init_chip(struct AdapterCtlBlk *acb)
 {
         struct NvRamType *eeprom = &acb->eeprom;
         


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

* Re: [2.6 patch] SCSI dc395x.c: make a function static
  2004-11-15  1:56 [2.6 patch] SCSI dc395x.c: make a function static Adrian Bunk
@ 2004-11-15 20:22 ` Jamie Lenehan
  2004-11-15 20:26   ` [2.6 patch] SCSI dc395x.c: store pci device pointer Jamie Lenehan
  0 siblings, 1 reply; 5+ messages in thread
From: Jamie Lenehan @ 2004-11-15 20:22 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: aliakc, James.Bottomley, linux-scsi

On Mon, Nov 15, 2004 at 02:56:09AM +0100, Adrian Bunk wrote:
> The patch below makes the needlessly global function adapter_init_chip 
> static.

James,

please apply this patch.

Thanks.
Jamie.

> Signed-off-by: Adrian Bunk <bunk@stusta.de>
> 
> --- linux-2.6.10-rc1-mm5-full/drivers/scsi/dc395x.c.old	2004-11-13 20:58:56.000000000 +0100
> +++ linux-2.6.10-rc1-mm5-full/drivers/scsi/dc395x.c	2004-11-13 20:59:09.000000000 +0100
> @@ -4447,7 +4447,7 @@
>   *
>   * @acb: The adapter which we are to init.
>   **/
> -void __init adapter_init_chip(struct AdapterCtlBlk *acb)
> +static void __init adapter_init_chip(struct AdapterCtlBlk *acb)
>  {
>          struct NvRamType *eeprom = &acb->eeprom;
>          
> 

-- 
 Jamie Lenehan <lenehan@twibble.org>

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

* [2.6 patch] SCSI dc395x.c: store pci device pointer
  2004-11-15 20:22 ` Jamie Lenehan
@ 2004-11-15 20:26   ` Jamie Lenehan
  2004-11-15 20:28     ` [2.6 patch] SCSI dc395x.c: Fix type for irq and io ports Jamie Lenehan
  0 siblings, 1 reply; 5+ messages in thread
From: Jamie Lenehan @ 2004-11-15 20:26 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-scsi

Store the PCI device pointer into the adapter control block. This is
used in the pci_map_*/pci_unmap_* calls and previously it would have
been set to NULL. This appears to be no problem for x86 but is a
problem for sparc64.

Signed-off-by: Jamie Lenehan <lenehan@twibble.org>

diff -du -r a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
--- a/drivers/scsi/dc395x.c	2004-06-30 20:10:13.939701006 +1000
+++ b/drivers/scsi/dc395x.c	2004-06-30 20:10:38.683969224 +1000
@@ -4820,6 +4820,7 @@
 	}
  	acb = (struct AdapterCtlBlk*)scsi_host->hostdata;
  	acb->scsi_host = scsi_host;
+ 	acb->dev = dev;
 
 	/* initialise the adapter and everything we need */
  	if (adapter_init(acb, io_port_base, io_port_len, irq)) {

-- 
 Jamie Lenehan <lenehan@twibble.org>

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

* [2.6 patch] SCSI dc395x.c: Fix type for irq and io ports
  2004-11-15 20:26   ` [2.6 patch] SCSI dc395x.c: store pci device pointer Jamie Lenehan
@ 2004-11-15 20:28     ` Jamie Lenehan
  2004-11-15 20:30       ` [2.6 patch] SCSI dc395x.c: Call pci_disable during cleanup Jamie Lenehan
  0 siblings, 1 reply; 5+ messages in thread
From: Jamie Lenehan @ 2004-11-15 20:28 UTC (permalink / raw)
  To: linux-scsi; +Cc: dc395x

Store the port and irq in unsigned long and unsigned int's instead of
as u16's and u8's. The later was fine on x86 but not on sparc64.

Signed-off-by: Jamie Lenehan <lenehan@twibble.org>

diff -du -r a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
--- a/drivers/scsi/dc395x.c	2004-06-30 20:11:42.631830402 +1000
+++ b/drivers/scsi/dc395x.c	2004-06-30 20:11:49.038417547 +1000
@@ -295,8 +295,8 @@
 struct AdapterCtlBlk {
 	struct Scsi_Host *scsi_host;
 
-	u16 io_port_base;
-	u16 io_port_len;
+	unsigned long io_port_base;
+	unsigned long io_port_len;
 
 	struct list_head dcb_list;		/* head of going dcb list */
 	struct DeviceCtlBlk *dcb_run_robin;
@@ -311,7 +311,7 @@
 
 	u8 sel_timeout;
 
-	u8 irq_level;
+	unsigned int irq_level;
 	u8 tag_max_num;
 	u8 acb_flag;
 	u8 gmode2;
@@ -3931,7 +3931,7 @@
  *
  * @io_port: base I/O address
  **/
-static void __init trms1040_wait_30us(u16 io_port)
+static void __init trms1040_wait_30us(unsigned long io_port)
 {
 	/* ScsiPortStallExecution(30); wait 30 us */
 	outb(5, io_port + TRM_S1040_GEN_TIMER);
@@ -3948,7 +3948,7 @@
  * @cmd:	SB + op code (command) to send
  * @addr:	address to send
  **/
-static void __init trms1040_write_cmd(u16 io_port, u8 cmd, u8 addr)
+static void __init trms1040_write_cmd(unsigned long io_port, u8 cmd, u8 addr)
 {
 	int i;
 	u8 send_data;
@@ -3993,7 +3993,7 @@
  * @addr:	offset into EEPROM
  * @byte:	bytes to write
  **/
-static void __init trms1040_set_data(u16 io_port, u8 addr, u8 byte)
+static void __init trms1040_set_data(unsigned long io_port, u8 addr, u8 byte)
 {
 	int i;
 	u8 send_data;
@@ -4047,7 +4047,7 @@
  * @eeprom:	the data to write
  * @io_port:	the base io port
  **/
-static void __init trms1040_write_all(struct NvRamType *eeprom, u16 io_port)
+static void __init trms1040_write_all(struct NvRamType *eeprom, unsigned long io_port)
 {
 	u8 *b_eeprom = (u8 *)eeprom;
 	u8 addr;
@@ -4087,7 +4087,7 @@
  *
  * Returns the the byte read.
  **/
-static u8 __init trms1040_get_data(u16 io_port, u8 addr)
+static u8 __init trms1040_get_data(unsigned long io_port, u8 addr)
 {
 	int i;
 	u8 read_byte;
@@ -4125,7 +4125,7 @@
  * @eeprom:	where to store the data
  * @io_port:	the base io port
  **/
-static void __init trms1040_read_all(struct NvRamType *eeprom, u16 io_port)
+static void __init trms1040_read_all(struct NvRamType *eeprom, unsigned long io_port)
 {
 	u8 *b_eeprom = (u8 *)eeprom;
 	u8 addr;
@@ -4155,7 +4155,7 @@
  * @eeprom:	caller allocated strcuture to read the eeprom data into
  * @io_port:	io port to read from
  **/
-static void __init check_eeprom(struct NvRamType *eeprom, u16 io_port)
+static void __init check_eeprom(struct NvRamType *eeprom, unsigned long io_port)
 {
 	u16 *w_eeprom = (u16 *)eeprom;
 	u16 w_addr;
@@ -4500,11 +4500,11 @@
  * Returns 0 if the initialization succeeds, any other value on
  * failure.
  **/
-static int __init adapter_init(struct AdapterCtlBlk *acb, u32 io_port,
-		u32 io_port_len, u8 irq)
+static int __init adapter_init(struct AdapterCtlBlk *acb,
+	unsigned long io_port, u32 io_port_len, unsigned int irq)
 {
 	if (!request_region(io_port, io_port_len, DC395X_NAME)) {
-		dprintkl(KERN_ERR, "Failed to reserve IO region 0x%x\n", io_port);
+		dprintkl(KERN_ERR, "Failed to reserve IO region 0x%lx\n", io_port);
 		goto failed;
 	}
 	/* store port base to indicate we have registered it */
@@ -4520,7 +4520,7 @@
 	acb->irq_level = irq;
 
 	/* get eeprom configuration information and command line settings etc */
-	check_eeprom(&acb->eeprom, (u16)io_port);
+	check_eeprom(&acb->eeprom, io_port);
  	print_eeprom_settings(&acb->eeprom);
 
 	/* setup adapter control block */	
@@ -4638,8 +4638,8 @@
 	SPRINTF("SCSI Host Nr %i, ", host->host_no);
 	SPRINTF("DC395U/UW/F DC315/U %s\n",
 		(acb->config & HCC_WIDE_CARD) ? "Wide" : "");
-	SPRINTF("io_port_base 0x%04x, ", acb->io_port_base);
-	SPRINTF("irq_level 0x%02x, ", acb->irq_level);
+	SPRINTF("io_port_base 0x%04lx, ", acb->io_port_base);
+	SPRINTF("irq_level 0x%04x, ", acb->irq_level);
 	SPRINTF(" SelTimeout %ims\n", (1638 * acb->sel_timeout) / 1000);
 
 	SPRINTF("MaxID %i, MaxLUN %i, ", host->max_id, host->max_lun);
@@ -4794,9 +4794,9 @@
 {
 	struct Scsi_Host *scsi_host;
 	struct AdapterCtlBlk *acb;
-	unsigned int io_port_base;
+	unsigned long io_port_base;
 	unsigned int io_port_len;
-	u8 irq;
+	unsigned int irq;
 	
 	dprintkdbg(DBG_0, "Init one instance (%s)\n", pci_name(dev));
 	banner_display();
@@ -4809,7 +4809,7 @@
 	io_port_base = pci_resource_start(dev, 0) & PCI_BASE_ADDRESS_IO_MASK;
 	io_port_len = pci_resource_len(dev, 0);
 	irq = dev->irq;
-	dprintkdbg(DBG_0, "IO_PORT=%04x, IRQ=%x\n", io_port_base, dev->irq);
+	dprintkdbg(DBG_0, "IO_PORT=0x%04lx, IRQ=0x%x\n", io_port_base, dev->irq);
 
 	/* allocate scsi host information (includes out adapter) */
 	scsi_host = scsi_host_alloc(&dc395x_driver_template,

-- 
 Jamie Lenehan <lenehan@twibble.org>

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

* [2.6 patch] SCSI dc395x.c: Call pci_disable during cleanup.
  2004-11-15 20:28     ` [2.6 patch] SCSI dc395x.c: Fix type for irq and io ports Jamie Lenehan
@ 2004-11-15 20:30       ` Jamie Lenehan
  0 siblings, 0 replies; 5+ messages in thread
From: Jamie Lenehan @ 2004-11-15 20:30 UTC (permalink / raw)
  To: linux-scsi; +Cc: dc395x

Call pci_disable_device if initialisation fails and during cleanup.

Signed-off-by: Jamie Lenehan <lenehan@twibble.org>

diff -du -r a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
--- a/drivers/scsi/dc395x.c	2004-06-30 20:33:16.815742524 +1000
+++ b/drivers/scsi/dc395x.c	2004-06-30 20:37:59.465770335 +1000
@@ -4789,8 +4789,8 @@
 static int __devinit dc395x_init_one(struct pci_dev *dev,
 		const struct pci_device_id *id)
 {
-	struct Scsi_Host *scsi_host;
-	struct AdapterCtlBlk *acb;
+	struct Scsi_Host *scsi_host = NULL;
+	struct AdapterCtlBlk *acb = NULL;
 	unsigned long io_port_base;
 	unsigned int io_port_len;
 	unsigned int irq;
@@ -4813,7 +4813,7 @@
 				    sizeof(struct AdapterCtlBlk));
 	if (!scsi_host) {
 		dprintkl(KERN_INFO, "scsi_host_alloc failed\n");
-		return -ENOMEM;
+		goto fail;
 	}
  	acb = (struct AdapterCtlBlk*)scsi_host->hostdata;
  	acb->scsi_host = scsi_host;
@@ -4822,8 +4822,7 @@
 	/* initialise the adapter and everything we need */
  	if (adapter_init(acb, io_port_base, io_port_len, irq)) {
 		dprintkl(KERN_INFO, "adapter init failed\n");
-		scsi_host_put(scsi_host);
-		return -ENODEV;
+		goto fail;
 	}
 
 	pci_set_master(dev);
@@ -4831,14 +4830,20 @@
 	/* get the scsi mid level to scan for new devices on the bus */
 	if (scsi_add_host(scsi_host, &dev->dev)) {
 		dprintkl(KERN_ERR, "scsi_add_host failed\n");
-		adapter_uninit(acb);
-		scsi_host_put(scsi_host);
-		return -ENODEV;
+		goto fail;
 	}
 	pci_set_drvdata(dev, scsi_host);
 	scsi_scan_host(scsi_host);
         	
 	return 0;
+
+fail:
+	if (acb != NULL)
+		adapter_uninit(acb);
+	if (scsi_host != NULL)
+		scsi_host_put(scsi_host);
+	pci_disable_device(dev);
+	return -ENODEV;
 }
 
 
@@ -4857,6 +4862,7 @@
 
 	scsi_remove_host(scsi_host);
 	adapter_uninit(acb);
+	pci_disable_device(dev);
 	scsi_host_put(scsi_host);
 	pci_set_drvdata(dev, NULL);
 }

-- 
 Jamie Lenehan <lenehan@twibble.org>

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

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

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-15  1:56 [2.6 patch] SCSI dc395x.c: make a function static Adrian Bunk
2004-11-15 20:22 ` Jamie Lenehan
2004-11-15 20:26   ` [2.6 patch] SCSI dc395x.c: store pci device pointer Jamie Lenehan
2004-11-15 20:28     ` [2.6 patch] SCSI dc395x.c: Fix type for irq and io ports Jamie Lenehan
2004-11-15 20:30       ` [2.6 patch] SCSI dc395x.c: Call pci_disable during cleanup Jamie Lenehan

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