* [PATCH 0/2] fdsfsd
@ 2015-12-04 9:06 Phil Reid
2015-12-04 9:06 ` [PATCH 1/2] gpiolib: prevent fault 'Unable to handle kernel paging request at virtual address' Phil Reid
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Phil Reid @ 2015-12-04 9:06 UTC (permalink / raw)
To: gnurou, linux-gpio; +Cc: Phil Reid
Phil Reid (2):
gpiolib: prevent fault 'Unable to handle kernel paging request at
virtual address'
gpio-pca953x: Add set_multiple to allow multiple bits to be set in one
write.
drivers/gpio/gpio-pca953x.c | 38 ++++++++++++++++++++++++++++++++++++++
drivers/gpio/gpiolib.c | 2 +-
2 files changed, 39 insertions(+), 1 deletion(-)
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] gpiolib: prevent fault 'Unable to handle kernel paging request at virtual address'
2015-12-04 9:06 [PATCH 0/2] fdsfsd Phil Reid
@ 2015-12-04 9:06 ` Phil Reid
2015-12-04 9:06 ` [PATCH 2/2] gpio-pca953x: Add set_multiple to allow multiple bits to be set in one write Phil Reid
2015-12-04 9:21 ` [PATCH 0/2] gpiolib exception & gpio-pca953x set_multiple support Phil Reid
2 siblings, 0 replies; 4+ messages in thread
From: Phil Reid @ 2015-12-04 9:06 UTC (permalink / raw)
To: gnurou, linux-gpio; +Cc: Phil Reid
gpiod_request when gpio returns -EBUSY results in fault.
Changing to pr_warn fixes the problem.
Signed-off-by: Phil Reid <preid@electromag.com.au>
---
drivers/gpio/gpiolib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index a18f00f..0ef01b8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -961,7 +961,7 @@ int gpiod_request(struct gpio_desc *desc, const char *label)
done:
if (status)
- gpiod_dbg(desc, "%s: status %d\n", __func__, status);
+ pr_warn("%s: status %d\n", __func__, status);
return status;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] gpio-pca953x: Add set_multiple to allow multiple bits to be set in one write.
2015-12-04 9:06 [PATCH 0/2] fdsfsd Phil Reid
2015-12-04 9:06 ` [PATCH 1/2] gpiolib: prevent fault 'Unable to handle kernel paging request at virtual address' Phil Reid
@ 2015-12-04 9:06 ` Phil Reid
2015-12-04 9:21 ` [PATCH 0/2] gpiolib exception & gpio-pca953x set_multiple support Phil Reid
2 siblings, 0 replies; 4+ messages in thread
From: Phil Reid @ 2015-12-04 9:06 UTC (permalink / raw)
To: gnurou, linux-gpio; +Cc: Phil Reid
Tested with TCA6408 / TCA6416 devices.
Signed-off-by: Phil Reid <preid@electromag.com.au>
---
drivers/gpio/gpio-pca953x.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 2d4892c..7c7229c 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -352,6 +352,43 @@ exit:
mutex_unlock(&chip->i2c_lock);
}
+
+static void pca953x_gpio_set_multiple(struct gpio_chip *gc,
+ unsigned long *mask, unsigned long *bits)
+{
+ struct pca953x_chip *chip = to_pca(gc);
+ u8 reg_val[MAX_BANK];
+ int ret, offset = 0;
+ int bank_shift = fls((chip->gpio_chip.ngpio - 1) / BANK_SZ);
+ int bank;
+
+ switch (chip->chip_type) {
+ case PCA953X_TYPE:
+ offset = PCA953X_OUTPUT;
+ break;
+ case PCA957X_TYPE:
+ offset = PCA957X_OUT;
+ break;
+ }
+
+ memcpy(reg_val, chip->reg_output, NBANK(chip));
+ mutex_lock(&chip->i2c_lock);
+ for(bank=0; bank<NBANK(chip); bank++) {
+ unsigned bankmask = mask[bank/4] >> ((bank % 4) * 8);
+ if(bankmask) {
+ unsigned bankval = bits[bank/4] >> ((bank % 4) * 8);
+ reg_val[bank] = (reg_val[bank] & ~bankmask) | bankval;
+ }
+ }
+ ret = i2c_smbus_write_i2c_block_data(chip->client, offset << bank_shift, NBANK(chip), reg_val);
+ if (ret)
+ goto exit;
+
+ memcpy(chip->reg_output, reg_val, NBANK(chip));
+exit:
+ mutex_unlock(&chip->i2c_lock);
+}
+
static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
{
struct gpio_chip *gc;
@@ -362,6 +399,7 @@ static void pca953x_setup_gpio(struct pca953x_chip *chip, int gpios)
gc->direction_output = pca953x_gpio_direction_output;
gc->get = pca953x_gpio_get_value;
gc->set = pca953x_gpio_set_value;
+ gc->set_multiple = pca953x_gpio_set_multiple;
gc->can_sleep = true;
gc->base = chip->gpio_start;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] gpiolib exception & gpio-pca953x set_multiple support
2015-12-04 9:06 [PATCH 0/2] fdsfsd Phil Reid
2015-12-04 9:06 ` [PATCH 1/2] gpiolib: prevent fault 'Unable to handle kernel paging request at virtual address' Phil Reid
2015-12-04 9:06 ` [PATCH 2/2] gpio-pca953x: Add set_multiple to allow multiple bits to be set in one write Phil Reid
@ 2015-12-04 9:21 ` Phil Reid
2 siblings, 0 replies; 4+ messages in thread
From: Phil Reid @ 2015-12-04 9:21 UTC (permalink / raw)
To: Phil Reid, gnurou, linux-gpio
Sorry for the bad cover. Script got away from me.
Should have contained.
First patch prevents a fault that was occuring when the gpio bit was BUSY.
Call stack was as follows:
[<802dfbb8>] (strnlen) from [<802e1170>] (string+0x40/0x10c)
[<802e1170>] (string) from [<802e2fcc>] (vsnprintf+0x178/0x39c)
[<802e2fcc>] (vsnprintf) from [<802e34e0>] (pointer+0x2f0/0x548)
[<802e34e0>] (pointer) from [<802e2f80>] (vsnprintf+0x12c/0x39c)
[<802e2f80>] (vsnprintf) from [<802e374c>] (vscnprintf+0x14/0x2c)
[<802e374c>] (vscnprintf) from [<8006d9d0>] (vprintk_emit+0xd8/0x558)
[<8006d9d0>] (vprintk_emit) from [<8006dfd4>] (vprintk_default+0x34/0x3c)
[<8006dfd4>] (vprintk_default) from [<800e1284>] (printk+0x88/0x90)
[<800e1284>] (printk) from [<802fffc0>] (__dynamic_pr_debug+0x58/0x68)
[<802fffc0>] (__dynamic_pr_debug) from [<80309380>] (gpiod_request+0xf0/0x180)
[<80309380>] (gpiod_request) from [<803095f4>] (gpiod_get_index+0xd8/0x2fc)
[<803095f4>] (gpiod_get_index) from [<7f043be0>] (emit_gpiod_of_get+0x30/0xe4 [EmitDrv])
[<7f043be0>] (emit_gpiod_of_get [EmitDrv]) from [<7f043d0c>] (emit_gpiod_of_array_get+0x78/0xa0 [EmitDrv])
[<7f043d0c>] (emit_gpiod_of_array_get [EmitDrv]) from [<7f04945c>] (adc_mod_probe+0x128/0x338 [AdcMod])
[<7f04945c>] (adc_mod_probe [AdcMod]) from [<7f043228>] (emit_probe+0x12c/0x224 [EmitDrv])
[<7f043228>] (emit_probe [EmitDrv]) from [<7f043824>] (emit_iio_probe_alloc+0x6c/0xe0 [EmitDrv])
[<7f043824>] (emit_iio_probe_alloc [EmitDrv]) from [<7f04913c>] (adc_mod_drv_probe+0x24/0x28 [AdcMod])
[<7f04913c>] (adc_mod_drv_probe [AdcMod]) from [<80350980>] (platform_drv_probe+0x54/0xb4)
[<80350980>] (platform_drv_probe) from [<8034e754>] (driver_probe_device+0x2ec/0x45c)
[<8034e754>] (driver_probe_device) from [<8034e960>] (__driver_attach+0x9c/0xa0)
[<8034e960>] (__driver_attach) from [<8034c4d8>] (bus_for_each_dev+0x70/0xa4)
[<8034c4d8>] (bus_for_each_dev) from [<8034df98>] (driver_attach+0x2c/0x30)
[<8034df98>] (driver_attach) from [<8034dad0>] (bus_add_driver+0x1c8/0x27c)
[<8034dad0>] (bus_add_driver) from [<8034f4e4>] (driver_register+0x88/0x108)
[<8034f4e4>] (driver_register) from [<803508ac>] (__platform_driver_register+0x64/0x6c)
[<803508ac>] (__platform_driver_register) from [<7f04c048>] (adc_mod_init+0x48/0x6c [AdcMod])
[<7f04c048>] (adc_mod_init [AdcMod]) from [<8000984c>] (do_one_initcall+0xc8/0x200)
[<8000984c>] (do_one_initcall) from [<800e154c>] (do_init_module+0x70/0x1e0)
[<800e154c>] (do_init_module) from [<8009e59c>] (load_module+0x1cb4/0x2170)
[<8009e59c>] (load_module) from [<8009ec64>] (SyS_finit_module+0x8c/0xbc)
[<8009ec64>] (SyS_finit_module) from [<80010800>] (ret_fast_syscall+0x0/0x3c)
Code: e24cb004 e3510000 e241e001 0a000011 (e5d01000)
Second patch adds support for set multiple bits in one i2c transaction.
This speeds up setting 'sets' of output bits.
--
Regards
Phil Reid
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-12-04 9:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-04 9:06 [PATCH 0/2] fdsfsd Phil Reid
2015-12-04 9:06 ` [PATCH 1/2] gpiolib: prevent fault 'Unable to handle kernel paging request at virtual address' Phil Reid
2015-12-04 9:06 ` [PATCH 2/2] gpio-pca953x: Add set_multiple to allow multiple bits to be set in one write Phil Reid
2015-12-04 9:21 ` [PATCH 0/2] gpiolib exception & gpio-pca953x set_multiple support Phil Reid
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).