Skip to content

Commit 54091ee

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: libsas: Refactor dev_is_sata()
Use a switch statement in dev_is_sata() to make the code more readable (and probably slightly better than a series of or conditions). Also have this inline function return a boolean instead of an integer. No functional changes. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20250725015818.171252-2-dlemoal@kernel.org Reviewed-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Jason Yan <yanaijie@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 19272b3 commit 54091ee

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

include/scsi/sas_ata.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@
1515

1616
#ifdef CONFIG_SCSI_SAS_ATA
1717

18-
static inline int dev_is_sata(struct domain_device *dev)
18+
static inline bool dev_is_sata(struct domain_device *dev)
1919
{
20-
return dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM ||
21-
dev->dev_type == SAS_SATA_PM_PORT || dev->dev_type == SAS_SATA_PENDING;
20+
switch (dev->dev_type) {
21+
case SAS_SATA_DEV:
22+
case SAS_SATA_PENDING:
23+
case SAS_SATA_PM:
24+
case SAS_SATA_PM_PORT:
25+
return true;
26+
default:
27+
return false;
28+
}
2229
}
2330

2431
int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy);
@@ -49,9 +56,9 @@ static inline void sas_ata_disabled_notice(void)
4956
pr_notice_once("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n");
5057
}
5158

52-
static inline int dev_is_sata(struct domain_device *dev)
59+
static inline bool dev_is_sata(struct domain_device *dev)
5360
{
54-
return 0;
61+
return false;
5562
}
5663
static inline int sas_ata_init(struct domain_device *dev)
5764
{

0 commit comments

Comments
 (0)