]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: libsas: Refactor dev_is_sata()
authorDamien Le Moal <dlemoal@kernel.org>
Fri, 25 Jul 2025 01:58:14 +0000 (10:58 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 25 Jul 2025 13:03:56 +0000 (09:03 -0400)
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>
include/scsi/sas_ata.h

index 92e27e7bf08819d739f2e42f1bb0884d473f8b01..8dddd0036f99b56f97fb9d5e58e7dd476304f51b 100644 (file)
 
 #ifdef CONFIG_SCSI_SAS_ATA
 
-static inline int dev_is_sata(struct domain_device *dev)
+static inline bool dev_is_sata(struct domain_device *dev)
 {
-       return dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM ||
-              dev->dev_type == SAS_SATA_PM_PORT || dev->dev_type == SAS_SATA_PENDING;
+       switch (dev->dev_type) {
+       case SAS_SATA_DEV:
+       case SAS_SATA_PENDING:
+       case SAS_SATA_PM:
+       case SAS_SATA_PM_PORT:
+               return true;
+       default:
+               return false;
+       }
 }
 
 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)
        pr_notice_once("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n");
 }
 
-static inline int dev_is_sata(struct domain_device *dev)
+static inline bool dev_is_sata(struct domain_device *dev)
 {
-       return 0;
+       return false;
 }
 static inline int sas_ata_init(struct domain_device *dev)
 {