lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220917104311.1878250-2-yanaijie@huawei.com>
Date:   Sat, 17 Sep 2022 18:43:05 +0800
From:   Jason Yan <yanaijie@...wei.com>
To:     <martin.petersen@...cle.com>, <jejb@...ux.ibm.com>
CC:     <linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <hare@...e.com>, <hch@....de>, <bvanassche@....org>,
        <john.garry@...wei.com>, <jinpu.wang@...ud.ionos.com>,
        Jason Yan <yanaijie@...wei.com>
Subject: [PATCH 1/7] scsi: libsas: introduce sas address conversion and comparation helpers

Sas address conversion and comparation is widely used in libsas and
drivers. 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@...wei.com>
---
 include/scsi/libsas.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 2dbead74a2af..382aedf31fa4 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -648,6 +648,38 @@ static inline bool sas_is_internal_abort(struct sas_task *task)
 	return task->task_proto == SAS_PROTOCOL_INTERNAL_ABORT;
 }
 
+static inline unsigned long long ex_phy_addr(struct ex_phy *phy)
+{
+	return SAS_ADDR(phy->attached_sas_addr);
+}
+
+static inline unsigned long long dev_addr(struct domain_device *dev)
+{
+	return SAS_ADDR(dev->sas_addr);
+}
+
+static inline unsigned long long port_addr(struct asd_sas_port *port)
+{
+	return SAS_ADDR(port->sas_addr);
+}
+
+static inline bool dev_and_phy_addr_same(struct domain_device *dev,
+					 struct ex_phy *phy)
+{
+	return dev_addr(dev) == ex_phy_addr(phy);
+}
+
+static inline bool port_and_phy_addr_same(struct asd_sas_port *port,
+					  struct ex_phy *phy)
+{
+	return port_addr(port) == ex_phy_addr(phy);
+}
+
+static inline bool ex_phy_addr_same(struct ex_phy *phy1, struct ex_phy *phy2)
+{
+	return  ex_phy_addr(phy1) ==  ex_phy_addr(phy2);
+}
+
 struct sas_domain_function_template {
 	/* The class calls these to notify the LLDD of an event. */
 	void (*lldd_port_formed)(struct asd_sas_phy *);
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ