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,66 +15804,44 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc) ...@@ -15821,66 +15804,44 @@ 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));
if (PCI_FUNC(pdev->devfn) != 0) {
u8 ints;
/* /*
* Set Function 1 EEPROM Word 0 MSB * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
* * and old Mac system booting problem. The Expansion
* Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11) * ROM must be disabled in Function 1 for these systems
* 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) = eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
((*
((uchar *)&Default_38C1600_EEPROM_Config
+
i)) &
(~
(((ADV_EEPROM_BIOS_ENABLE |
ADV_EEPROM_INTAB) >> 8) & 0xFF)));
/* /*
* Set the INTAB (bit 11) if the GPIO 0 input indicates * Clear the INTAB (bit 11) if the GPIO 0 input
* the Function 1 interrupt line is wired to INTA. * indicates the Function 1 interrupt line is wired
* to INTB.
* *
* Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input: * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
* 1 - Function 1 interrupt line wired to INT A. * 1 - Function 1 interrupt line wired to INT A.
* 0 - Function 1 interrupt line wired to INT B. * 0 - Function 1 interrupt line wired to INT B.
* *
* Note: Adapter boards always have Function 0 wired to INTA. * Note: Function 0 is always wired to INTA.
* Put all 5 GPIO bits in input mode and then read * Put all 5 GPIO bits in input mode and then read
* their input values. * their input values.
*/ */
AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
0); ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
if (AdvReadByteRegister if ((ints & 0x01) == 0)
(iop_base, IOPB_GPIO_DATA) & 0x01) { eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
/* Function 1 interrupt wired to INTA; Set EEPROM bit. */
*((uchar *)&eep_config + i) |=
((ADV_EEPROM_INTAB >> 8) & 0xFF);
}
} else {
*((uchar *)&eep_config + i) =
*((uchar *)&Default_38C1600_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);
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);
......
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