Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Matthew Wilcox and committed by
James Bottomley
d68f4321 13ac2d9c

+40 -79
+40 -79
drivers/scsi/advansys.c
··· 3168 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 - */ 3173 - static ADVEEP_3550_CONFIG Default_3550_EEPROM_Config; 3174 - static ADVEEP_38C0800_CONFIG Default_38C0800_EEPROM_Config; 3175 - static ADVEEP_38C1600_CONFIG Default_38C1600_EEPROM_Config; 3176 - 3177 - /* 3178 3171 * DvcGetPhyAddr() flag arguments 3179 3172 */ 3180 3173 #define ADV_IS_SCSIQ_FLAG 0x01 /* 'addr' is ASC_SCSI_REQ_Q pointer */ ··· 13176 13183 static unsigned short _adv_asc38C1600_size = sizeof(_adv_asc38C1600_buf); /* 0x1673 */ 13177 13184 static ADV_DCNT _adv_asc38C1600_chksum = 0x0604EF77UL; /* Expanded little-endian checksum. */ 13178 13185 13179 - /* a_init.c */ 13180 13186 /* 13181 13187 * EEPROM Configuration. 13182 13188 * ··· 15435 15443 AdvPortAddr iop_base; 15436 15444 ushort warn_code; 15437 15445 ADVEEP_3550_CONFIG eep_config; 15438 - int i; 15439 15446 15440 15447 iop_base = asc_dvc->iop_base; 15441 15448 ··· 15451 15460 /* 15452 15461 * Set EEPROM default values. 15453 15462 */ 15454 - for (i = 0; i < sizeof(ADVEEP_3550_CONFIG); i++) { 15455 - *((uchar *)&eep_config + i) = 15456 - *((uchar *)&Default_3550_EEPROM_Config + i); 15457 - } 15463 + memcpy(&eep_config, &Default_3550_EEPROM_Config, 15464 + sizeof(ADVEEP_3550_CONFIG)); 15458 15465 15459 15466 /* 15460 - * Assume the 6 byte board serial number that was read 15461 - * from EEPROM is correct even if the EEPROM checksum 15462 - * failed. 15467 + * Assume the 6 byte board serial number that was read from 15468 + * EEPROM is correct even if the EEPROM checksum failed. 15463 15469 */ 15464 15470 eep_config.serial_number_word3 = 15465 15471 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); ··· 15585 15597 AdvPortAddr iop_base; 15586 15598 ushort warn_code; 15587 15599 ADVEEP_38C0800_CONFIG eep_config; 15588 - int i; 15589 15600 uchar tid, termination; 15590 15601 ushort sdtr_speed = 0; 15591 15602 ··· 15604 15617 /* 15605 15618 * Set EEPROM default values. 15606 15619 */ 15607 - for (i = 0; i < sizeof(ADVEEP_38C0800_CONFIG); i++) { 15608 - *((uchar *)&eep_config + i) = 15609 - *((uchar *)&Default_38C0800_EEPROM_Config + i); 15610 - } 15620 + memcpy(&eep_config, &Default_38C0800_EEPROM_Config, 15621 + sizeof(ADVEEP_38C0800_CONFIG)); 15611 15622 15612 15623 /* 15613 - * Assume the 6 byte board serial number that was read 15614 - * from EEPROM is correct even if the EEPROM checksum 15615 - * failed. 15624 + * Assume the 6 byte board serial number that was read from 15625 + * EEPROM is correct even if the EEPROM checksum failed. 15616 15626 */ 15617 15627 eep_config.serial_number_word3 = 15618 15628 AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); ··· 15784 15800 AdvPortAddr iop_base; 15785 15801 ushort warn_code; 15786 15802 ADVEEP_38C1600_CONFIG eep_config; 15787 - int i; 15788 15803 uchar tid, termination; 15789 15804 ushort sdtr_speed = 0; 15790 15805 ··· 15804 15821 /* 15805 15822 * Set EEPROM default values. 15806 15823 */ 15807 - for (i = 0; i < sizeof(ADVEEP_38C1600_CONFIG); i++) { 15808 - if (i == 1 && PCI_FUNC(pdev->devfn) != 0) { 15809 - /* 15810 - * Set Function 1 EEPROM Word 0 MSB 15811 - * 15812 - * Clear the BIOS_ENABLE (bit 14) and INTAB (bit 11) 15813 - * EEPROM bits. 15814 - * 15815 - * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 and 15816 - * old Mac system booting problem. The Expansion ROM must 15817 - * be disabled in Function 1 for these systems. 15818 - * 15819 - */ 15820 - *((uchar *)&eep_config + i) = 15821 - ((* 15822 - ((uchar *)&Default_38C1600_EEPROM_Config 15823 - + 15824 - i)) & 15825 - (~ 15826 - (((ADV_EEPROM_BIOS_ENABLE | 15827 - ADV_EEPROM_INTAB) >> 8) & 0xFF))); 15824 + memcpy(&eep_config, &Default_38C1600_EEPROM_Config, 15825 + sizeof(ADVEEP_38C1600_CONFIG)); 15828 15826 15829 - /* 15830 - * Set the INTAB (bit 11) if the GPIO 0 input indicates 15831 - * the Function 1 interrupt line is wired to INTA. 15832 - * 15833 - * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input: 15834 - * 1 - Function 1 interrupt line wired to INT A. 15835 - * 0 - Function 1 interrupt line wired to INT B. 15836 - * 15837 - * Note: Adapter boards always have Function 0 wired to INTA. 15838 - * Put all 5 GPIO bits in input mode and then read 15839 - * their input values. 15840 - */ 15841 - AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 15842 - 0); 15843 - if (AdvReadByteRegister 15844 - (iop_base, IOPB_GPIO_DATA) & 0x01) { 15845 - /* Function 1 interrupt wired to INTA; Set EEPROM bit. */ 15846 - *((uchar *)&eep_config + i) |= 15847 - ((ADV_EEPROM_INTAB >> 8) & 0xFF); 15848 - } 15849 - } else { 15850 - *((uchar *)&eep_config + i) = 15851 - *((uchar *)&Default_38C1600_EEPROM_Config 15852 - + i); 15853 - } 15827 + if (PCI_FUNC(pdev->devfn) != 0) { 15828 + u8 ints; 15829 + /* 15830 + * Disable Bit 14 (BIOS_ENABLE) to fix SPARC Ultra 60 15831 + * and old Mac system booting problem. The Expansion 15832 + * ROM must be disabled in Function 1 for these systems 15833 + */ 15834 + eep_config.cfg_lsw &= ~ADV_EEPROM_BIOS_ENABLE; 15835 + /* 15836 + * Clear the INTAB (bit 11) if the GPIO 0 input 15837 + * indicates the Function 1 interrupt line is wired 15838 + * to INTB. 15839 + * 15840 + * Set/Clear Bit 11 (INTAB) from the GPIO bit 0 input: 15841 + * 1 - Function 1 interrupt line wired to INT A. 15842 + * 0 - Function 1 interrupt line wired to INT B. 15843 + * 15844 + * Note: Function 0 is always wired to INTA. 15845 + * Put all 5 GPIO bits in input mode and then read 15846 + * their input values. 15847 + */ 15848 + AdvWriteByteRegister(iop_base, IOPB_GPIO_CNTL, 0); 15849 + ints = AdvReadByteRegister(iop_base, IOPB_GPIO_DATA); 15850 + if ((ints & 0x01) == 0) 15851 + eep_config.cfg_lsw &= ~ADV_EEPROM_INTAB; 15854 15852 } 15855 15853 15856 15854 /* 15857 - * Assume the 6 byte board serial number that was read 15858 - * from EEPROM is correct even if the EEPROM checksum 15859 - * failed. 15855 + * Assume the 6 byte board serial number that was read from 15856 + * EEPROM is correct even if the EEPROM checksum failed. 15860 15857 */ 15861 15858 eep_config.serial_number_word3 = 15862 - AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); 15863 - 15859 + AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 1); 15864 15860 eep_config.serial_number_word2 = 15865 - AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2); 15866 - 15861 + AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 2); 15867 15862 eep_config.serial_number_word1 = 15868 - AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3); 15863 + AdvReadEEPWord(iop_base, ADV_EEP_DVC_CFG_END - 3); 15869 15864 15870 15865 AdvSet38C1600EEPConfig(iop_base, &eep_config); 15871 15866 }