diff mbox

[15/29] scsi: aacraid: Create helper functions to get lun info

Message ID 20171221173420.8213-16-RaghavaAditya.Renukunta@microsemi.com (mailing list archive)
State Superseded
Headers show

Commit Message

Raghava Aditya Renukunta Dec. 21, 2017, 5:34 p.m. UTC
Created inline function to retrieve lun info for each device from the
phy luns structure.

Signed-off-by: Raghava Aditya Renukunta <RaghavaAditya.Renukunta@microsemi.com>
---
 drivers/scsi/aacraid/aachba.c | 59 ++++++++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 12 deletions(-)

Comments

Bart Van Assche Dec. 21, 2017, 6:40 p.m. UTC | #1
On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:
> +	return ((phys_luns->list_length[0]<<24) +

> +			(phys_luns->list_length[1]<<16) +

> +			(phys_luns->list_length[2]<<8) +

> +			(phys_luns->list_length[3])) / 24;


Please use get_unaligned_be32() instead of open-coding it.

Thanks,

Bart.
Raghava Aditya Renukunta Dec. 27, 2017, 1:24 a.m. UTC | #2
> -----Original Message-----

> From: Bart Van Assche [mailto:Bart.VanAssche@wdc.com]

> Sent: Thursday, December 21, 2017 10:41 AM

> To: jejb@linux.vnet.ibm.com; Raghava Aditya Renukunta

> <RaghavaAditya.Renukunta@microsemi.com>; linux-scsi@vger.kernel.org;

> martin.petersen@oracle.com

> Cc: dl-esc-Aacraid Linux Driver <aacraid@microsemi.com>;

> gpiccoli@linux.vnet.ibm.com; Tom White <tom.white@microsemi.com>;

> Scott Benesh <scott.benesh@microsemi.com>

> Subject: Re: [PATCH 15/29] scsi: aacraid: Create helper functions to get lun

> info

> 

> EXTERNAL EMAIL

> 

> 

> On Thu, 2017-12-21 at 09:34 -0800, Raghava Aditya Renukunta wrote:

> > +     return ((phys_luns->list_length[0]<<24) +

> > +                     (phys_luns->list_length[1]<<16) +

> > +                     (phys_luns->list_length[2]<<8) +

> > +                     (phys_luns->list_length[3])) / 24;

> 

> Please use get_unaligned_be32() instead of open-coding it.


Yes Will do Bart.
Thank you
Raghava Aditya
 

> Thanks,

> 

> Bart.
diff mbox

Patch

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index affa2f1..83d2576 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1847,7 +1847,48 @@  static int aac_get_safw_ciss_luns(struct aac_dev *dev, int rescan)
 mem_free_all:
 	kfree(phys_luns);
 	goto out;
+}
+
+static inline u32 aac_get_safw_phys_lun_count(struct aac_dev *dev)
+{
+	struct aac_ciss_phys_luns_resp *phys_luns;
+
+	phys_luns = dev->safw_phys_luns;
+
+	return ((phys_luns->list_length[0]<<24) +
+			(phys_luns->list_length[1]<<16) +
+			(phys_luns->list_length[2]<<8) +
+			(phys_luns->list_length[3])) / 24;
+}
 
+static inline u32 aac_get_safw_phys_bus(struct aac_dev *dev, int lun)
+{
+	return dev->safw_phys_luns->lun[lun].level2[1] & 0x3f;
+}
+
+static inline u32 aac_get_safw_phys_target(struct aac_dev *dev, int lun)
+{
+	return dev->safw_phys_luns->lun[lun].level2[0];
+}
+
+static inline u32 aac_get_safw_phys_expose_flag(struct aac_dev *dev, int lun)
+{
+	return dev->safw_phys_luns->lun[lun].bus >> 6;
+}
+
+static inline u32 aac_get_safw_phys_attribs(struct aac_dev *dev, int lun)
+{
+	return dev->safw_phys_luns->lun[lun].node_ident[9];
+}
+
+static inline u32 aac_get_safw_phys_nexus(struct aac_dev *dev, int lun)
+{
+	return *((u32 *)&dev->safw_phys_luns->lun[lun].node_ident[12]);
+}
+
+static inline u32 aac_get_safw_phys_device_type(struct aac_dev *dev, int lun)
+{
+	return dev->safw_phys_luns->lun[lun].node_ident[8];
 }
 
 /**
@@ -1865,22 +1906,16 @@  static void aac_set_safw_attr_all_targets(struct aac_dev *dev, int rescan)
 	u32 i, bus, target;
 	u8 expose_flag, attribs;
 	u8 devtype;
-	struct aac_ciss_phys_luns_resp *phys_luns;
-
-	phys_luns = dev->safw_phys_luns;
 
-	lun_count = ((phys_luns->list_length[0] << 24)
-			+ (phys_luns->list_length[1] << 16)
-			+ (phys_luns->list_length[2] << 8)
-			+ (phys_luns->list_length[3])) / 24;
+	lun_count = aac_get_safw_phys_lun_count(dev);
 
 	for (i = 0; i < lun_count; ++i) {
 
-		bus = phys_luns->lun[i].level2[1] & 0x3f;
-		target = phys_luns->lun[i].level2[0];
-		expose_flag = phys_luns->lun[i].bus >> 6;
-		attribs = phys_luns->lun[i].node_ident[9];
-		nexus = *((u32 *) &phys_luns->lun[i].node_ident[12]);
+		bus = aac_get_safw_phys_bus(dev, i);
+		target = aac_get_safw_phys_target(dev, i);
+		expose_flag = aac_get_safw_phys_expose_flag(dev, i);
+		attribs = aac_get_safw_phys_attribs(dev, i);
+		nexus = aac_get_safw_phys_nexus(dev, i);
 
 		if (bus >= AAC_MAX_BUSES || target >= AAC_MAX_TARGETS)
 			continue;