Skip to contentSkip to conversation

gpio: pca953x: Use ARRAY_SIZE instead of reinventing it

PATCH In review Axel Lin 4 participants 4 messages Jun 22, 2013 – Aug 18, 2013 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 gpio: pca953x: Use ARRAY_SIZE instead of reinventing it

---
 drivers/gpio/pca953x.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpio/pca953x.c +1 -4
index be13745..7371cd4 100644
@@ -47,9 +47,6 @@ struct pca953x_chip_ngpio {
 static struct pca953x_chip_ngpio pca953x_chip_ngpios[] =
     CONFIG_SYS_I2C_PCA953X_WIDTH;
 
-#define NUM_CHIP_GPIOS (sizeof(pca953x_chip_ngpios) / \
-			sizeof(struct pca953x_chip_ngpio))
-
 /*
  * Determine the number of GPIO pins supported. If we don't know we assume
  * 8 pins.
@@ -58,7 +55,7 @@ static int pca953x_ngpio(uint8_t chip)
 {
 	int i;
 
-	for (i = 0; i < NUM_CHIP_GPIOS; i++)
+	for (i = 0; i < ARRAY_SIZE(pca953x_chip_ngpios); i++)
 		if (pca953x_chip_ngpios[i].chip == chip)
 			return pca953x_chip_ngpios[i].ngpio;
 
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 gpio: pca953x: Use ARRAY_SIZE instead of reinventing it

Quoted 4 lines · Axel Lin
---
 drivers/gpio/pca953x.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130622/a71889f5/attachment.pgp>

#2 lore raw

PATCH 1/1 gpio: pca953x: Use ARRAY_SIZE instead of reinventing it

In reply to Axel Lin

Dear Axel Lin,

Quoted 20 lines
---
 drivers/gpio/pca953x.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpio/pca953x.c +0 -3
index be13745..7371cd4 100644
@@ -47,9 +47,6 @@ struct pca953x_chip_ngpio {
 static struct pca953x_chip_ngpio pca953x_chip_ngpios[] =
     CONFIG_SYS_I2C_PCA953X_WIDTH;
 
-#define NUM_CHIP_GPIOS (sizeof(pca953x_chip_ngpios) / \
-			sizeof(struct pca953x_chip_ngpio))
-
 /*
  * Determine the number of GPIO pins supported. If we don't know we assume
  * 8 pins.

drivers/gpio/pca953x.c static int pca953x_ngpio(uint8_t chip) · line 60

Quoted 7 lines
drivers/gpio/pca953x.c +1 -1
@@ -58,7 +55,7 @@ static int pca953x_ngpio(uint8_t chip)
 {
 	int i;
 
-	for (i = 0; i < NUM_CHIP_GPIOS; i++)
+	for (i = 0; i < ARRAY_SIZE(pca953x_chip_ngpios); i++)
 		if (pca953x_chip_ngpios[i].chip == chip)
 			return pca953x_chip_ngpios[i].ngpio;

Absolutelly

Best regards,
Marek Vasut

#3 lore raw
In reply to Axel Lin
Quoted 7 lines · Axel Lin

---
drivers/gpio/pca953x.c | 5 +----

 1 file changed, 1 insertion(+), 4 deletions(-)

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130818/a0cc4409/attachment.pgp>