Commit d68f4321 authored by Matthew Wilcox's avatar Matthew Wilcox Committed by James Bottomley

[SCSI] advansys: use memcpy instead of open-coded loop

Use memcpy to initialise eep_config instead of a loop.  For
AdvInitFrom38C1600EEP where we need to modify the default EEPROM
configuration, do it after the loop, and do it using the structure
definition, not by finding the right byte.  I think it was wrong for
big-endian machines.

Also delete some non-useful comments and prototypes.
Signed-off-by: default avatarMatthew Wilcox <matthew@wil.cx>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 13ac2d9c
...@@ -3167,13 +3167,6 @@ do { \ ...@@ -3167,13 +3167,6 @@ do { \
#define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */ #define QHSTA_M_FROZEN_TIDQ 0x46 /* TID Queue frozen. */
#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */ #define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
/*
* Default EEPROM Configuration structure defined in a_init.c.
*/
static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config;
static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config;
static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
/* /*
* DvcGetPhyAddr() flag arguments * DvcGetPhyAddr() flag arguments
*/ */
...@@ -13183,7 +13176,6 @@ static unsigned char _adv_asc38C1600_buf[] = { ...@@ -13183,7 +13176,6 @@ static unsigned char _adv_asc38C1600_buf[] = {
static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */ static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */ static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
/* a_init.c */
/* /*
* EEPROM Configuration. * EEPROM Configuration.
* *
...@@ -15443,7 +15435,6 @@ static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc) ...@@ -15443,7 +15435,6 @@ static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
AdvPortAddr iop_base; AdvPortAddr iop_base;
ushort warn_code; ushort warn_code;
ADVEEP_3550_CONFIG eep_config; ADVEEP_3550_CONFIG eep_config;
int i;
iop_base = asc_dvc->iop_base; iop_base = asc_dvc->iop_base;
...@@ -15460,15 +15451,12 @@ static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc) ...@@ -15460,15 +15451,12 @@ static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
/* /*
* Set EEPROM default values. * Set EEPROM default values.
*/ */
for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++) { memcpy(&eep_config, &Default_3550_EEPROM_Config,
*((uchar *)&eep_config + i) = sizeof(ADVEEP_3550_CONFIG));
*((uchar *)&Default_3550_EEPROM_Config + i);
}
/* /*
* Assume the 6 byte board serial number that was read * Assume the 6 byte board serial number that was read from
* from EEPROM is correct even if the EEPROM checksum * EEPROM is correct even if the EEPROM checksum failed.
* failed.
*/ */
eep_config.serial_number_word3 = eep_config.serial_number_word3 =
AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
...@@ -15597,7 +15585,6 @@ static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc) ...@@ -15597,7 +15585,6 @@ static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
AdvPortAddr iop_base; AdvPortAddr iop_base;
ushort warn_code; ushort warn_code;
ADVEEP_38C0800_CONFIG eep_config; ADVEEP_38C0800_CONFIG eep_config;
int i;
uchar tid, termination; uchar tid, termination;
ushort sdtr_speed = 0; ushort sdtr_speed = 0;
...@@ -15617,15 +15604,12 @@ static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc) ...@@ -15617,15 +15604,12 @@ static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
/* /*
* Set EEPROM default values. * Set EEPROM default values.
*/ */
for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++) { memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
*((uchar *)&eep_config + i) = sizeof(ADVEEP_38C0800_CONFIG));
*((uchar *)&Default_38C0800_EEPROM_Config + i);
}
/* /*
* Assume the 6 byte board serial number that was read * Assume the 6 byte board serial number that was read from
* from EEPROM is correct even if the EEPROM checksum * EEPROM is correct even if the EEPROM checksum failed.
* failed.
*/ */
eep_config.serial_number_word3 = eep_config.serial_number_word3 =
AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
...@@ -15800,7 +15784,6 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc) ...@@ -15800,7 +15784,6 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
AdvPortAddr iop_base; AdvPortAddr iop_base;
ushort warn_code; ushort warn_code;
ADVEEP_38C1600_CONFIG eep_config; ADVEEP_38C1600_CONFIG eep_config;
int i;
uchar tid, termination; uchar tid, termination;
ushort sdtr_speed = 0; ushort sdtr_speed = 0;
...@@ -15821,68 +15804,46 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc) ...@@ -15821,68 +15804,46 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
/* /*
* Set EEPROM default values. * Set EEPROM default values.
*/ */
for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++) { memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
if (i == 1 && PCI_FUNC(pdev->devfn) != 0) { sizeof(ADVEEP_38C1600_CONFIG));
/*
* Set Function 1 EEPROM Word 0 MSB
*
* Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
* EEPROM bits.
*
* Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
* old Mac system booting problem. The Expansion ROM must
* be disabled in Function 1 for these systems.
*
*/
*((uchar *)&eep_config + i) =
((*
((uchar *)&Default_38C1600_EEPROM_Config
+
i)) &
(~
(((ADV_EEPROM_BIOS_ENABLE |
ADV_EEPROM_INTAB) >> 8) & 0xFF)));
/* if (PCI_FUNC(pdev->devfn) != 0) {
* Set the INTAB (bit 11) if the GPIO 0 input indicates u8 ints;
* the Function 1 interrupt line is wired to INTA. /*
* * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
* Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input: * and old Mac system booting problem. The Expansion
* 1 - Function 1 interrupt line wired to INT A. * ROM must be disabled in Function 1 for these systems
* 0 - Function 1 interrupt line wired to INT B. */
* eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
* Note: Adapter boards always have Function 0 wired to INTA. /*
* Put all 5 GPIO bits in input mode and then read * Clear the INTAB (bit 11) if the GPIO 0 input
* their input values. * indicates the Function 1 interrupt line is wired
*/ * to INTB.
AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, *
0); * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
if (AdvReadByteRegister * 1 - Function 1 interrupt line wired to INT A.
(iop_base, IOPB_GPIO_DATA) & 0x01) { * 0 - Function 1 interrupt line wired to INT B.
/* Function 1 interrupt wired to INTA; Set EEPROM bit. */ *
*((uchar *)&eep_config + i) |= * Note: Function 0 is always wired to INTA.
((ADV_EEPROM_INTAB >> 8) & 0xFF); * Put all 5 GPIO bits in input mode and then read
} * their input values.
} else { */
*((uchar *)&eep_config + i) = AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
*((uchar *)&Default_38C1600_EEPROM_Config ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
+ i); if ((ints & 0x01) == 0)
} eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
} }
/* /*
* Assume the 6 byte board serial number that was read * Assume the 6 byte board serial number that was read from
* from EEPROM is correct even if the EEPROM checksum * EEPROM is correct even if the EEPROM checksum failed.
* failed.
*/ */
eep_config.serial_number_word3 = eep_config.serial_number_word3 =
AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
eep_config.serial_number_word2 = eep_config.serial_number_word2 =
AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2); AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
eep_config.serial_number_word1 = eep_config.serial_number_word1 =
AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3); AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
AdvSet38C1600EEPConfig(iop_base, &eep_config); AdvSet38C1600EEPConfig(iop_base, &eep_config);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment