[SCSI] Fix incorrect reporting of host protection capabilities
The advent of DIF Type 2 devices exposed some missing break statements in the protection mask switch constructs. However, rewriting the code to use an index into a small static array seemed like a more elegant solution. Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
This commit is contained in:
committed by
James Bottomley
parent
88197966e1
commit
b2b465e928
@@ -797,30 +797,23 @@ static inline unsigned int scsi_host_get_prot(struct Scsi_Host *shost)
|
|||||||
|
|
||||||
static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsigned int target_type)
|
static inline unsigned int scsi_host_dif_capable(struct Scsi_Host *shost, unsigned int target_type)
|
||||||
{
|
{
|
||||||
switch (target_type) {
|
static unsigned char cap[] = { 0,
|
||||||
case 1:
|
SHOST_DIF_TYPE1_PROTECTION,
|
||||||
if (shost->prot_capabilities & SHOST_DIF_TYPE1_PROTECTION)
|
SHOST_DIF_TYPE2_PROTECTION,
|
||||||
return target_type;
|
SHOST_DIF_TYPE3_PROTECTION };
|
||||||
case 2:
|
|
||||||
if (shost->prot_capabilities & SHOST_DIF_TYPE2_PROTECTION)
|
|
||||||
return target_type;
|
|
||||||
case 3:
|
|
||||||
if (shost->prot_capabilities & SHOST_DIF_TYPE3_PROTECTION)
|
|
||||||
return target_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return shost->prot_capabilities & cap[target_type] ? target_type : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int scsi_host_dix_capable(struct Scsi_Host *shost, unsigned int target_type)
|
static inline unsigned int scsi_host_dix_capable(struct Scsi_Host *shost, unsigned int target_type)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_BLK_DEV_INTEGRITY)
|
#if defined(CONFIG_BLK_DEV_INTEGRITY)
|
||||||
switch (target_type) {
|
static unsigned char cap[] = { SHOST_DIX_TYPE0_PROTECTION,
|
||||||
case 0: return shost->prot_capabilities & SHOST_DIX_TYPE0_PROTECTION;
|
SHOST_DIX_TYPE1_PROTECTION,
|
||||||
case 1: return shost->prot_capabilities & SHOST_DIX_TYPE1_PROTECTION;
|
SHOST_DIX_TYPE2_PROTECTION,
|
||||||
case 2: return shost->prot_capabilities & SHOST_DIX_TYPE2_PROTECTION;
|
SHOST_DIX_TYPE3_PROTECTION };
|
||||||
case 3: return shost->prot_capabilities & SHOST_DIX_TYPE3_PROTECTION;
|
|
||||||
}
|
return shost->prot_capabilities & cap[target_type];
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user