diff mbox series

[v2,5/8] scsi: libsas: introduce sas address comparation helpers

Message ID 20220924073455.2186805-6-yanaijie@huawei.com (mailing list archive)
State Superseded
Headers show
Series scsi: libsas: sas address comparation refactor | expand

Commit Message

Jason Yan Sept. 24, 2022, 7:34 a.m. UTC
Sas address comparation is widely used in libsas. However they are all
opencoded and to avoid the line spill over 80 columns, are mostly split
into multi-lines. Introduce some helpers to prepare some refactor.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
---
 drivers/scsi/libsas/sas_internal.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

John Garry Sept. 26, 2022, 11:44 a.m. UTC | #1
On 24/09/2022 08:34, Jason Yan wrote:
> +static inline bool sas_phy_match_dev_addr(struct domain_device *dev,
> +					 struct ex_phy *phy)
> +{
> +	return SAS_ADDR(dev->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
> +}
> +
> +static inline bool sas_phy_match_port_addr(struct asd_sas_port *port,
> +					   struct ex_phy *phy)
> +{
> +	return SAS_ADDR(port->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
> +}
> +
> +static inline bool sas_phy_addr_same(struct ex_phy *p1, struct ex_phy *p2)

nit: please use "match" or "same" consistently in the naming. My 
preference was for "match" to be used.

Thanks,
John

> +{
> +	return  SAS_ADDR(p1->attached_sas_addr) == SAS_ADDR(p2->attached_sas_addr);
> +}
> +
Jason Yan Sept. 26, 2022, 12:16 p.m. UTC | #2
On 2022/9/26 19:44, John Garry wrote:
> On 24/09/2022 08:34, Jason Yan wrote:
>> +static inline bool sas_phy_match_dev_addr(struct domain_device *dev,
>> +                     struct ex_phy *phy)
>> +{
>> +    return SAS_ADDR(dev->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
>> +}
>> +
>> +static inline bool sas_phy_match_port_addr(struct asd_sas_port *port,
>> +                       struct ex_phy *phy)
>> +{
>> +    return SAS_ADDR(port->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
>> +}
>> +
>> +static inline bool sas_phy_addr_same(struct ex_phy *p1, struct ex_phy 
>> *p2)
> 
> nit: please use "match" or "same" consistently in the naming. My 
> preference was for "match" to be used.
> 

OK.

Thanks,
Jason

> Thanks,
> John
> 
>> +{
>> +    return  SAS_ADDR(p1->attached_sas_addr) == 
>> SAS_ADDR(p2->attached_sas_addr);
>> +}
>> +
> 
> .
diff mbox series

Patch

diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index 8d0ad3abc7b5..171ffad514ca 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -111,6 +111,23 @@  static inline void sas_smp_host_handler(struct bsg_job *job,
 }
 #endif
 
+static inline bool sas_phy_match_dev_addr(struct domain_device *dev,
+					 struct ex_phy *phy)
+{
+	return SAS_ADDR(dev->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
+}
+
+static inline bool sas_phy_match_port_addr(struct asd_sas_port *port,
+					   struct ex_phy *phy)
+{
+	return SAS_ADDR(port->sas_addr) == SAS_ADDR(phy->attached_sas_addr);
+}
+
+static inline bool sas_phy_addr_same(struct ex_phy *p1, struct ex_phy *p2)
+{
+	return  SAS_ADDR(p1->attached_sas_addr) == SAS_ADDR(p2->attached_sas_addr);
+}
+
 static inline void sas_fail_probe(struct domain_device *dev, const char *func, int err)
 {
 	pr_warn("%s: for %s device %016llx returned %d\n",