Skip to contentSkip to conversation

gpio-pca953x driver and PCA9536 chip

RFC PATCH In review Janusz Użycki 3 participants 4 messages Aug 31, 2015 – Sep 7, 2015 1 message not in the archive GPIO

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 gpio-pca953x driver and PCA9536 chip

Hi,

The driver sets register #02 (inversion) to 0x01 instead of 0x00 on my board.
Reason: device_pca953x_init() does not initialize val buffer because NBANK() returns for PCA9536 ngpio=4 value 0 instead of 1.

My proposed code-patch for 3.14.17 is below.
Because I don't work on stable/next I can't deliver complete/ready patch. Please for comments.

best regards
Janusz

drivers/gpio/gpio-pca953x.c +1 -1
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(i2c, pca953x_id);
 #define MAX_BANK 5
 #define BANK_SZ 8
 
-#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
+#define NBANK(chip) DIV_ROUND_UP(chip->gpio_chip.ngpio, BANK_SZ)
 
 struct pca953x_chip {
        unsigned gpio_start;

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 55E4641D.7050603-cjVIcFy54eMe9JSWTWOYM+658FiBabzs@public.gmane.org

#2 lore raw

W dniu 2015-08-31 o 16:26, Janusz Użycki pisze:

Quoted 16 lines

Hi,

The driver sets register #02 (inversion) to 0x01 instead of 0x00 on my board.
Reason: device_pca953x_init() does not initialize val buffer because NBANK() returns for PCA9536 ngpio=4 value 0 instead of 1.

My proposed code-patch for 3.14.17 is below.
Because I don't work on stable/next I can't deliver complete/ready patch. Please for comments.

best regards
Janusz

drivers/gpio/gpio-pca953x.c MODULE_DEVICE_TABLE(i2c, pca953x_id); · line 81

Quoted 8 lines
drivers/gpio/gpio-pca953x.c +1 -1
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(i2c, pca953x_id);
 #define MAX_BANK 5
 #define BANK_SZ 8
 
-#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
+#define NBANK(chip) DIV_ROUND_UP(chip->gpio_chip.ngpio, BANK_SZ)
 
 struct pca953x_chip {
        unsigned gpio_start;

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Janusz Użycki

Adding linux-gpio and some people that have been patching this driver to TO-line.

Grygorii et al, does this look correct? Anyone who can test and send a patch for mainline?

Yours,
Linus Walleij

Quoted 18 lines · Janusz Użycki

Hi,

The driver sets register #02 (inversion) to 0x01 instead of 0x00 on my board.
Reason: device_pca953x_init() does not initialize val buffer because NBANK() returns
for PCA9536 ngpio=4 value 0 instead of 1.

My proposed code-patch for 3.14.17 is below.
Because I don't work on stable/next I can't deliver complete/ready patch. Please for comments.

best regards
Janusz

drivers/gpio/gpio-pca953x.c MODULE_DEVICE_TABLE(i2c, pca953x_id); · line 81

Quoted 8 lines
drivers/gpio/gpio-pca953x.c +1 -1
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(i2c, pca953x_id);
 #define MAX_BANK 5
 #define BANK_SZ 8
 
-#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
+#define NBANK(chip) DIV_ROUND_UP(chip->gpio_chip.ngpio, BANK_SZ)
 
 struct pca953x_chip {
        unsigned gpio_start;

--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 32 lines · Linus Walleij

Adding linux-gpio and some people that have been patching this driver to TO-line.

Grygorii et al, does this look correct? Anyone who can test and send a patch for mainline?

Yours,
Linus Walleij

Quoted 21 lines · Janusz Użycki

Hi,

The driver sets register #02 (inversion) to 0x01 instead of 0x00 on my board.
Reason: device_pca953x_init() does not initialize val buffer because NBANK() returns
for PCA9536 ngpio=4 value 0 instead of 1.

My proposed code-patch for 3.14.17 is below.
Because I don't work on stable/next I can't deliver complete/ready patch. Please for comments.

best regards
Janusz

drivers/gpio/gpio-pca953x.c +0 -0
@@ -75,7 +75,7 @@ MODULE_DEVICE_TABLE(i2c, pca953x_id);
  #define MAX_BANK 5
  #define BANK_SZ 8
 
Quoted 5 lines

drivers/gpio/gpio-pca953x.c MODULE_DEVICE_TABLE(i2c, pca953x_id); · line 81

Quoted 5 lines
drivers/gpio/gpio-pca953x.c +1 -1
-#define NBANK(chip) (chip->gpio_chip.ngpio / BANK_SZ)
+#define NBANK(chip) DIV_ROUND_UP(chip->gpio_chip.ngpio, BANK_SZ)
 
  struct pca953x_chip {
         unsigned gpio_start;

Seems yes, but I can't test it - have no such HW now.
As per code, NBANK(chip) expected to return number of 8-bit banks, but now it returns NBANK-1.

Additional info:
- Corresponding code was changed by Gregory CLEMENT
commit: f5f0b7aa897ebf6b0d077356a787526212460dd7

Signature · 6 lines
regards,
-grygorii
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html