fdsfsd
cover fdsfsd
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(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 gpiolib: prevent fault 'Unable to handle kernel paging request at virtual address'
gpiod_request when gpio returns -EBUSY results in fault. Changing to pr_warn fixes the problem.
--- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib.c +1 -1
@@ -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; }
Signature · 1 line
1.8.3.1
PATCH 2/2 gpio-pca953x: Add set_multiple to allow multiple bits to be set in one write.
In reply to Phil ReidTested with TCA6408 / TCA6416 devices.
--- drivers/gpio/gpio-pca953x.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
drivers/gpio/gpio-pca953x.c +38 -0
@@ -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;
Signature · 1 line
1.8.3.1
Re: [PATCH 0/2] gpiolib exception & gpio-pca953x set_multiple support
In reply to Phil ReidSorry 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.
Signature · 2 lines
Regards Phil Reid