Skip to contentSkip to conversation

scsi: bfa: Use ARRAY_SIZE

PATCH In review Christoph Jaeger 2 participants 2 messages Aug 31, 2013 – Sep 5, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: bfa: Use ARRAY_SIZE

Use ARRAY_SIZE to calculate the size of an array.

---
 drivers/scsi/bfa/bfa_core.c |  2 +-
 drivers/scsi/bfa/bfa_fcs.c  | 10 ++++------
 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/scsi/bfa/bfa_core.c +1 -1
index 520540a..4cc8763 100644
@@ -1941,7 +1941,7 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids)
 		{BFA_PCI_VENDOR_ID_BROCADE, BFA_PCI_DEVICE_ID_CT_FC},
 	};
 
-	*npciids = sizeof(__pciids) / sizeof(__pciids[0]);
+	*npciids = ARRAY_SIZE(__pciids);
 	*pciids = __pciids;
 }
 
drivers/scsi/bfa/bfa_fcs.c +4 -6
index a3ab5cc..6a00008 100644
@@ -81,7 +81,7 @@ bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa, struct bfad_s *bfad,
 	bfa->fcs = BFA_TRUE;
 	fcbuild_init();
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->attach)
 			mod->attach(fcs);
@@ -97,7 +97,7 @@ bfa_fcs_init(struct bfa_fcs_s *fcs)
 	int	i;
 	struct bfa_fcs_mod_s  *mod;
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->modinit)
 			mod->modinit(fcs);
@@ -180,13 +180,11 @@ void
 bfa_fcs_exit(struct bfa_fcs_s *fcs)
 {
 	struct bfa_fcs_mod_s  *mod;
-	int		nmods, i;
+	int i;
 
 	bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
 
-	nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]);
-
-	for (i = 0; i < nmods; i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 
 		mod = &fcs_modules[i];
 		if (mod->modexit) {
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 73 lines

-----Original Message-----
From: [email protected] [mailto:linux-scsi- [email protected]] On Behalf Of Christoph Jaeger
Sent: Sunday, September 01, 2013 1:05 AM
To: James E.J. Bottomley
Cc: [email protected]; Christoph Jaeger
Subject: [PATCH] scsi: bfa: Use ARRAY_SIZE

Use ARRAY_SIZE to calculate the size of an array.

---
 drivers/scsi/bfa/bfa_core.c |  2 +-
 drivers/scsi/bfa/bfa_fcs.c  | 10 ++++------
 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/scsi/bfa/bfa_core.c index renamed from drivers/scsi/bfa/bfa_core.c +0 -0

520540a..4cc8763 100644

drivers/scsi/bfa/bfa_core.c +1 -1
@@ -1941,7 +1941,7 @@ bfa_get_pciids(struct bfa_pciid_s **pciids, int
 *npciids)
 		{BFA_PCI_VENDOR_ID_BROCADE,
 BFA_PCI_DEVICE_ID_CT_FC},
 	};
 
-	*npciids = sizeof(__pciids) / sizeof(__pciids[0]);
+	*npciids = ARRAY_SIZE(__pciids);
 	*pciids = __pciids;

}

drivers/scsi/bfa/bfa_fcs.c index renamed from drivers/scsi/bfa/bfa_fcs.c +0 -0

a3ab5cc..6a00008 100644

drivers/scsi/bfa/bfa_fcs.c +1 -1
@@ -81,7 +81,7 @@ bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
 struct bfad_s *bfad,
 	bfa->fcs = BFA_TRUE;
 	fcbuild_init();
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->attach)
drivers/scsi/bfa/bfa_fcs.c +3 -6
 			mod->attach(fcs);
@@ -97,7 +97,7 @@ bfa_fcs_init(struct bfa_fcs_s *fcs)
 	int	i;
 	struct bfa_fcs_mod_s  *mod;
 
-	for (i = 0; i < sizeof(fcs_modules) / sizeof(fcs_modules[0]); i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 		mod = &fcs_modules[i];
 		if (mod->modinit)
 			mod->modinit(fcs);
@@ -180,13 +180,11 @@ void
 bfa_fcs_exit(struct bfa_fcs_s *fcs)
 {
 	struct bfa_fcs_mod_s  *mod;
-	int		nmods, i;
+	int i;
 
 	bfa_wc_init(&fcs->wc, bfa_fcs_exit_comp, fcs);
 
-	nmods = sizeof(fcs_modules) / sizeof(fcs_modules[0]);
-
-	for (i = 0; i < nmods; i++) {
+	for (i = 0; i < ARRAY_SIZE(fcs_modules); i++) {
 
 		mod = &fcs_modules[i];
 		if (mod->modexit) {
--

1.8.3.1

Quoted 1 line

--

Thanks for the patch Chris. Changes looks good.