mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 15:27:29 +00:00
scsi: libsas: Stop hardcoding SAS address length
Many times we use 8 for SAS address length, while we already have a macro for this - SAS_ADDR_SIZE. Replace instances of this with the macro. However, don't touch the SAS address array sizes sas.h, as these are defined according to the SAS spec. Some missing whitespaces are also added, and whitespace indentation in sas_hash_addr() is also fixed (see sas_hash_addr()). Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
01d4e3a2fc
commit
7b27c5fe24
3 changed files with 30 additions and 27 deletions
|
@ -87,25 +87,27 @@ EXPORT_SYMBOL_GPL(sas_free_task);
|
|||
/*------------ SAS addr hash -----------*/
|
||||
void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
|
||||
{
|
||||
const u32 poly = 0x00DB2777;
|
||||
u32 r = 0;
|
||||
int i;
|
||||
const u32 poly = 0x00DB2777;
|
||||
u32 r = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
int b;
|
||||
for (b = 7; b >= 0; b--) {
|
||||
r <<= 1;
|
||||
if ((1 << b) & sas_addr[i]) {
|
||||
if (!(r & 0x01000000))
|
||||
r ^= poly;
|
||||
} else if (r & 0x01000000)
|
||||
r ^= poly;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < SAS_ADDR_SIZE; i++) {
|
||||
int b;
|
||||
|
||||
hashed[0] = (r >> 16) & 0xFF;
|
||||
hashed[1] = (r >> 8) & 0xFF ;
|
||||
hashed[2] = r & 0xFF;
|
||||
for (b = (SAS_ADDR_SIZE - 1); b >= 0; b--) {
|
||||
r <<= 1;
|
||||
if ((1 << b) & sas_addr[i]) {
|
||||
if (!(r & 0x01000000))
|
||||
r ^= poly;
|
||||
} else if (r & 0x01000000) {
|
||||
r ^= poly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hashed[0] = (r >> 16) & 0xFF;
|
||||
hashed[1] = (r >> 8) & 0xFF;
|
||||
hashed[2] = r & 0xFF;
|
||||
}
|
||||
|
||||
int sas_register_ha(struct sas_ha_struct *sas_ha)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue