aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/advansys.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2007-07-26 11:58:12 -0400
committerJames Bottomley <jejb@mulgrave.localdomain>2007-10-12 14:39:52 -0400
commitd68f4321357165346fb15ef41dbbf9dce7894f29 (patch)
tree81511511970607a4f7fb0ffb6e9b470df769991e /drivers/scsi/advansys.c
parent13ac2d9c791469d4af51aa65653ab0fbd0916fcc (diff)
[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: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/advansys.c')
-rw-r--r--drivers/scsi/advansys.c119
1 files changed, 40 insertions, 79 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 986c52a7b95e..19c2d19f254c 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -3168,13 +3168,6 @@ do { \
3168#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */ 3168#define QHSTA_M_SGBACKUP_ERROR 0x47 /* Scatter-Gather backup error */
3169 3169
3170/* 3170/*
3171 * Default EEPROM Configuration structure defined in a_init.c.
3172 */
3173static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config;
3174static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config;
3175static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config;
3176
3177/*
3178 * DvcGetPhyAddr() flag arguments 3171 * DvcGetPhyAddr() flag arguments
3179 */ 3172 */
3180#define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */ 3173#define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */
@@ -13183,7 +13176,6 @@ static unsigned char _adv_asc38C1600_buf[] = {
13183static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */ 13176static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */
13184static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */ 13177static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */
13185 13178
13186/* a_init.c */
13187/* 13179/*
13188 * EEPROM Configuration. 13180 * EEPROM Configuration.
13189 * 13181 *
@@ -15443,7 +15435,6 @@ static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
15443 AdvPortAddr iop_base; 15435 AdvPortAddr iop_base;
15444 ushort warn_code; 15436 ushort warn_code;
15445 ADVEEP_3550_CONFIG eep_config; 15437 ADVEEP_3550_CONFIG eep_config;
15446 int i;
15447 15438
15448 iop_base = asc_dvc->iop_base; 15439 iop_base = asc_dvc->iop_base;
15449 15440
@@ -15460,15 +15451,12 @@ static int __devinit AdvInitFrom3550EEP(ADV_DVC_VAR *asc_dvc)
15460 /* 15451 /*
15461 * Set EEPROM default values. 15452 * Set EEPROM default values.
15462 */ 15453 */
15463 for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++) { 15454 memcpy(&eep_config, &Default_3550_EEPROM_Config,
15464 *((uchar *)&eep_config + i) = 15455 sizeof(ADVEEP_3550_CONFIG));
15465 *((uchar *)&Default_3550_EEPROM_Config + i);
15466 }
15467 15456
15468 /* 15457 /*
15469 * Assume the 6 byte board serial number that was read 15458 * Assume the 6 byte board serial number that was read from
15470 * from EEPROM is correct even if the EEPROM checksum 15459 * EEPROM is correct even if the EEPROM checksum failed.
15471 * failed.
15472 */ 15460 */
15473 eep_config.serial_number_word3 = 15461 eep_config.serial_number_word3 =
15474 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); 15462 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
@@ -15597,7 +15585,6 @@ static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
15597 AdvPortAddr iop_base; 15585 AdvPortAddr iop_base;
15598 ushort warn_code; 15586 ushort warn_code;
15599 ADVEEP_38C0800_CONFIG eep_config; 15587 ADVEEP_38C0800_CONFIG eep_config;
15600 int i;
15601 uchar tid, termination; 15588 uchar tid, termination;
15602 ushort sdtr_speed = 0; 15589 ushort sdtr_speed = 0;
15603 15590
@@ -15617,15 +15604,12 @@ static int __devinit AdvInitFrom38C0800EEP(ADV_DVC_VAR *asc_dvc)
15617 /* 15604 /*
15618 * Set EEPROM default values. 15605 * Set EEPROM default values.
15619 */ 15606 */
15620 for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++) { 15607 memcpy(&eep_config, &Default_38C0800_EEPROM_Config,
15621 *((uchar *)&eep_config + i) = 15608 sizeof(ADVEEP_38C0800_CONFIG));
15622 *((uchar *)&Default_38C0800_EEPROM_Config + i);
15623 }
15624 15609
15625 /* 15610 /*
15626 * Assume the 6 byte board serial number that was read 15611 * Assume the 6 byte board serial number that was read from
15627 * from EEPROM is correct even if the EEPROM checksum 15612 * EEPROM is correct even if the EEPROM checksum failed.
15628 * failed.
15629 */ 15613 */
15630 eep_config.serial_number_word3 = 15614 eep_config.serial_number_word3 =
15631 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); 15615 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
@@ -15800,7 +15784,6 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
15800 AdvPortAddr iop_base; 15784 AdvPortAddr iop_base;
15801 ushort warn_code; 15785 ushort warn_code;
15802 ADVEEP_38C1600_CONFIG eep_config; 15786 ADVEEP_38C1600_CONFIG eep_config;
15803 int i;
15804 uchar tid, termination; 15787 uchar tid, termination;
15805 ushort sdtr_speed = 0; 15788 ushort sdtr_speed = 0;
15806 15789
@@ -15821,68 +15804,46 @@ static int __devinit AdvInitFrom38C1600EEP(ADV_DVC_VAR *asc_dvc)
15821 /* 15804 /*
15822 * Set EEPROM default values. 15805 * Set EEPROM default values.
15823 */ 15806 */
15824 for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++) { 15807 memcpy(&eep_config, &Default_38C1600_EEPROM_Config,
15825 if (i == 1 && PCI_FUNC(pdev->devfn) != 0) { 15808 sizeof(ADVEEP_38C1600_CONFIG));
15826 /*
15827 * Set Function 1 EEPROM Word 0 MSB
15828 *
15829 * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11)
15830 * EEPROM bits.
15831 *
15832 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and
15833 * old Mac system booting problem. The Expansion ROM must
15834 * be disabled in Function 1 for these systems.
15835 *
15836 */
15837 *((uchar *)&eep_config + i) =
15838 ((*
15839 ((uchar *)&Default_38C1600_EEPROM_Config
15840 +
15841 i)) &
15842 (~
15843 (((ADV_EEPROM_BIOS_ENABLE |
15844 ADV_EEPROM_INTAB) >> 8) & 0xFF)));
15845 15809
15846 /* 15810 if (PCI_FUNC(pdev->devfn) != 0) {
15847 * Set the INTAB (bit 11) if the GPIO 0 input indicates 15811 u8 ints;
15848 * the Function 1 interrupt line is wired to INTA. 15812 /*
15849 * 15813 * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60
15850 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input: 15814 * and old Mac system booting problem. The Expansion
15851 * 1 - Function 1 interrupt line wired to INT A. 15815 * ROM must be disabled in Function 1 for these systems
15852 * 0 - Function 1 interrupt line wired to INT B. 15816 */
15853 * 15817 eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE;
15854 * Note: Adapter boards always have Function 0 wired to INTA. 15818 /*
15855 * Put all 5 GPIO bits in input mode and then read 15819 * Clear the INTAB (bit 11) if the GPIO 0 input
15856 * their input values. 15820 * indicates the Function 1 interrupt line is wired
15857 */ 15821 * to INTB.
15858 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 15822 *
15859 0); 15823 * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input:
15860 if (AdvReadByteRegister 15824 * 1 - Function 1 interrupt line wired to INT A.
15861 (iop_base, IOPB_GPIO_DATA) & 0x01) { 15825 * 0 - Function 1 interrupt line wired to INT B.
15862 /* Function 1 interrupt wired to INTA; Set EEPROM bit. */ 15826 *
15863 *((uchar *)&eep_config + i) |= 15827 * Note: Function 0 is always wired to INTA.
15864 ((ADV_EEPROM_INTAB >> 8) & 0xFF); 15828 * Put all 5 GPIO bits in input mode and then read
15865 } 15829 * their input values.
15866 } else { 15830 */
15867 *((uchar *)&eep_config + i) = 15831 AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0);
15868 *((uchar *)&Default_38C1600_EEPROM_Config 15832 ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA);
15869 + i); 15833 if ((ints & 0x01) == 0)
15870 } 15834 eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB;
15871 } 15835 }
15872 15836
15873 /* 15837 /*
15874 * Assume the 6 byte board serial number that was read 15838 * Assume the 6 byte board serial number that was read from
15875 * from EEPROM is correct even if the EEPROM checksum 15839 * EEPROM is correct even if the EEPROM checksum failed.
15876 * failed.
15877 */ 15840 */
15878 eep_config.serial_number_word3 = 15841 eep_config.serial_number_word3 =
15879 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); 15842 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1);
15880
15881 eep_config.serial_number_word2 = 15843 eep_config.serial_number_word2 =
15882 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2); 15844 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2);
15883
15884 eep_config.serial_number_word1 = 15845 eep_config.serial_number_word1 =
15885 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3); 15846 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3);
15886 15847
15887 AdvSet38C1600EEPConfig(iop_base, &eep_config); 15848 AdvSet38C1600EEPConfig(iop_base, &eep_config);
15888 } 15849 }