iio: stmpe-adc: Add compatible name
PATCH 1/5 iio: stmpe-adc: Add compatible name
From: Philippe Schenker <[email protected]>
Add the compatible name to the driver so it gets loaded when the proper node in DT is detected.
---
drivers/iio/adc/stmpe-adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/adc/stmpe-adc.c +6 -1
@@ -354,9 +354,14 @@ static struct platform_driver stmpe_adc_driver = { .pm = &stmpe_adc_pm_ops, }, }; -module_platform_driver (stmpe_adc_driver); +static const struct of_device_id stmpe_adc_ids[] = { + { .compatible ="st,stmpe-adc" , }, + { }, +}; +MODULE_DEVICE_TABLE (of, stmpe_adc_ids); +MODULE_AUTHOR ("Stefan Agner <[email protected]>" );MODULE_DESCRIPTION ("STMPEXXX ADC driver" );MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.21.0
PATCH 2/5 iio: stmpe-adc: Reinit completion struct on begin conversion
From: Philippe Schenker <[email protected]>
In some cases, the wait_completion got interrupted. This caused the error-handling to mutex_unlock the function. The before turned on interrupt then got called anyway. In the ISR then completion() was called causing wrong adc-values returned in a following adc-readout.
Reinitialise completion struct to make sure the counter is zero when beginning a new adc-conversion.
---
drivers/iio/adc/stmpe-adc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/iio/adc/stmpe-adc.c +4 -0
@@ -65,6 +65,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info,mutex_lock (&info->lock); +reinit_completion (&info->completion); + info->channel = (u8 )chan->channel;if (info->channel >STMPE_ADC_LAST_NR ) {
@@ -105,6 +107,8 @@ static int stmpe_read_temp(struct stmpe_adc *info,mutex_lock (&info->lock); +reinit_completion (&info->completion); + info->channel = (u8 )chan->channel;if (info->channel !=STMPE_TEMP_CHANNEL ) {
Signature · 1 line
2.21.0
Jonathan Cameron
maintainerRe: [PATCH 2/5] iio: stmpe-adc: Reinit completion struct on begin conversion
Quoted 11 lines · On Tue, 7 May 2019 16:36:12 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
In some cases, the
wait_completiongot interrupted. This caused the error-handling tomutex_unlockthe function. The before turned on interrupt then got called anyway. In the ISR thencompletion()was called causing wrong adc-values returned in a following adc-readout.Reinitialise completion struct to make sure the counter is zero when beginning a new adc-conversion.
Signed-off-by Philippe Schenker <[email protected]>
Hi Philippe,
To me this looks like a fix that we should consider applying to stable. However, as it is in the middle of this series I'm not going to take it via the fast route (during rc's). If people want to backport it they will have to wait until after the next merge window.
If anyone has an urgent need, then shout in the next week and I'll pull this version out and we can restructure the set.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 27 lines
---
drivers/iio/adc/stmpe-adc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/iio/adc/stmpe-adc.c +4
-0@@ -65,6 +65,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info,mutex_lock (&info->lock); +reinit_completion (&info->completion); + info->channel = (u8 )chan->channel;if (info->channel >STMPE_ADC_LAST_NR ) {@@ -105,6 +107,8 @@ static int stmpe_read_temp(struct stmpe_adc *info,mutex_lock (&info->lock); +reinit_completion (&info->completion); + info->channel = (u8 )chan->channel;if (info->channel !=STMPE_TEMP_CHANNEL ) {
Re: [PATCH 2/5] iio: stmpe-adc: Reinit completion struct on begin conversion
Quoted 23 lines · Jonathan Cameron
Quoted 11 lines · On Tue, 7 May 2019 16:36:12 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
In some cases, the
wait_completiongot interrupted. This caused the error-handling tomutex_unlockthe function. The before turned on interrupt then got called anyway. In the ISR thencompletion()was called causing wrong adc-values returned in a following adc-readout.Reinitialise completion struct to make sure the counter is zero when beginning a new adc-conversion.
Signed-off-by Philippe Schenker <[email protected]>Hi Philippe,
To me this looks like a fix that we should consider applying to stable. However, as it is in the middle of this series I'm not going to take it via the fast route (during rc's). If people want to backport it they will have to wait until after the next merge window.
If anyone has an urgent need, then shout in the next week and I'll pull this version out and we can restructure the set.
Quoted 6 lines
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Hi Jonathan! I don't think that's necessary. As long as it gets into stable at some point. Our customer use downstream anyway. Where I'm about to apply it now.
Thanks,
Philippe
Quoted 21 lines
Quoted 21 lines
---
drivers/iio/adc/stmpe-adc.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/iio/adc/stmpe-adc.c +2
-0@@ -65,6 +65,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info,mutex_lock (&info->lock); +reinit_completion (&info->completion); + info->channel = (u8 )chan->channel;if (info->channel >STMPE_ADC_LAST_NR ) {@@ -105,6 +107,8 @@ static int stmpe_read_temp(struct stmpe_adc *info,
Quoted 7 lines
drivers/iio/adc/stmpe-adc.c static int stmpe_read_temp(struct stmpe_adc *info, · line 114
Quoted 7 lines
drivers/iio/adc/stmpe-adc.c +2
-0mutex_lock (&info->lock); +reinit_completion (&info->completion); + info->channel = (u8 )chan->channel;if (info->channel !=STMPE_TEMP_CHANNEL ) {
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/5 iio: stmpe-adc: Enable all stmpe-adc interrupts just once
In reply to Philippe SchenkerFrom: Philippe Schenker <[email protected]>
This commit will enable the interrupts of all channels handled by this driver only once in the probe function.
This will improve performance because one byte less has to be written over i2c on each read out of the adc. On the fastest ADC mode this will improve read out speed by 15%.
---
drivers/iio/adc/stmpe-adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/adc/stmpe-adc.c +3 -3
@@ -74,9 +74,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info,return -EINVAL ; } -stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_EN , -STMPE_ADC_CH (info->channel)); -stmpe_reg_write (info->stmpe,STMPE_REG_ADC_CAPT ,STMPE_ADC_CH (info->channel));
@@ -336,6 +333,9 @@ static int stmpe_adc_probe(struct platform_device *pdev)if (ret)return ret; +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_EN , + ~(norequest_mask &0xFF )); +return devm_iio_device_register (&pdev->dev, indio_dev); }
Signature · 1 line
2.21.0
Jonathan Cameron
maintainerRe: [PATCH 3/5] iio: stmpe-adc: Enable all stmpe-adc interrupts just once
Quoted 10 lines · On Tue, 7 May 2019 16:36:13 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
This commit will enable the interrupts of all channels handled by this driver only once in the probe function.
This will improve performance because one byte less has to be written over i2c on each read out of the adc. On the fastest ADC mode this will improve read out speed by 15%.
Signed-off-by Philippe Schenker <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 29 lines
---
drivers/iio/adc/stmpe-adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/adc/stmpe-adc.c +3
-3@@ -74,9 +74,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info,return -EINVAL ; } -stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_EN , -STMPE_ADC_CH (info->channel)); -stmpe_reg_write (info->stmpe,STMPE_REG_ADC_CAPT ,STMPE_ADC_CH (info->channel));@@ -336,6 +333,9 @@ static int stmpe_adc_probe(struct platform_device *pdev)if (ret)return ret; +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_EN , + ~(norequest_mask &0xFF )); +return devm_iio_device_register (&pdev->dev, indio_dev); }
PATCH 4/5 iio: stmpe-adc: Use wait_for_completion_timeout
In reply to Philippe SchenkerFrom: Philippe Schenker <[email protected]>
Use wait_for_completion_timeout instead ofwait_for_completion_interuptible_timeout.
The interruptible variant gets constantly interrupted if a user program is compiled with the -pg option.
The killable variant was not used due to the fact that a second program, reading on this device, that gets killed is then also killing that wait.
---
drivers/iio/adc/stmpe-adc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/iio/adc/stmpe-adc.c +4 -14
@@ -77,17 +77,11 @@ static int stmpe_read_voltage(struct stmpe_adc *info,stmpe_reg_write (info->stmpe,STMPE_REG_ADC_CAPT ,STMPE_ADC_CH (info->channel)); - *val = info->value; - - ret =wait_for_completion_interruptible_timeout - (&info->completion,STMPE_ADC_TIMEOUT ); + ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) {mutex_unlock (&info->lock); -if (ret ==0 ) -return -ETIMEDOUT ; -else -return ret; +return -ETIMEDOUT ; } *val = info->value;
@@ -116,15 +110,11 @@ static int stmpe_read_temp(struct stmpe_adc *info,stmpe_reg_write (info->stmpe,STMPE_REG_TEMP_CTRL ,STMPE_START_ONE_TEMP_CONV ); - ret =wait_for_completion_interruptible_timeout - (&info->completion,STMPE_ADC_TIMEOUT ); + ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) {mutex_unlock (&info->lock); -if (ret ==0 ) -return -ETIMEDOUT ; -else -return ret; +return -ETIMEDOUT ; }/*
Signature · 1 line
2.21.0
Jonathan Cameron
maintainerRe: [PATCH 4/5] iio: stmpe-adc: Use wait_for_completion_timeout
Quoted 5 lines · On Tue, 7 May 2019 16:36:14 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
Use
wait_for_completion_timeoutinstead ofwait_for_completion_interuptible_timeout.
Quoted 7 lines
The interruptible variant gets constantly interrupted if a user program is compiled with the -pg option.
The killable variant was not used due to the fact that a second program, reading on this device, that gets killed is then also killing that wait.Signed-off-by Philippe Schenker <[email protected]>
Hi Phillippe
This one clashed a little bit with our earlier patch to remove the unnecessary assignment. I've applied it by hand but please check it.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 47 lines
---
drivers/iio/adc/stmpe-adc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)drivers/iio/adc/stmpe-adc.c +4
-14@@ -77,17 +77,11 @@ static int stmpe_read_voltage(struct stmpe_adc *info,stmpe_reg_write (info->stmpe,STMPE_REG_ADC_CAPT ,STMPE_ADC_CH (info->channel)); - *val = info->value; - - ret =wait_for_completion_interruptible_timeout - (&info->completion,STMPE_ADC_TIMEOUT ); + ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) {mutex_unlock (&info->lock); -if (ret ==0 ) -return -ETIMEDOUT ; -else -return ret; +return -ETIMEDOUT ; } *val = info->value;@@ -116,15 +110,11 @@ static int stmpe_read_temp(struct stmpe_adc *info,stmpe_reg_write (info->stmpe,STMPE_REG_TEMP_CTRL ,STMPE_START_ONE_TEMP_CONV ); - ret =wait_for_completion_interruptible_timeout - (&info->completion,STMPE_ADC_TIMEOUT ); + ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) {mutex_unlock (&info->lock); -if (ret ==0 ) -return -ETIMEDOUT ; -else -return ret; +return -ETIMEDOUT ; }/*
Re: [PATCH 4/5] iio: stmpe-adc: Use wait_for_completion_timeout
Quoted 20 lines · Jonathan Cameron
Quoted 5 lines · On Tue, 7 May 2019 16:36:14 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
Use
wait_for_completion_timeoutinstead ofwait_for_completion_interuptible_timeout.Quoted 7 lines
The interruptible variant gets constantly interrupted if a user program is compiled with the -pg option.
The killable variant was not used due to the fact that a second program, reading on this device, that gets killed is then also killing that wait.Signed-off-by Philippe Schenker <[email protected]>Hi Phillippe
This one clashed a little bit with our earlier patch to remove the unnecessary assignment. I've applied it by hand but please check it.
Quoted 6 lines
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Hmm, yeah I see it sorry for that! Somehow that line went in again in this patch. Don't know why... Anyway I checked it and it looks good. Thank you!
Philippe
Quoted 46 lines
Quoted 46 lines
---
drivers/iio/adc/stmpe-adc.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)drivers/iio/adc/stmpe-adc.c +4
-14@@ -77,17 +77,11 @@ static int stmpe_read_voltage(struct stmpe_adc *info,stmpe_reg_write (info->stmpe,STMPE_REG_ADC_CAPT ,STMPE_ADC_CH (info->channel)); - *val = info->value; - - ret =wait_for_completion_interruptible_timeout - (&info->completion,STMPE_ADC_TIMEOUT ); + ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) {mutex_unlock (&info->lock); -if (ret ==0 ) -return -ETIMEDOUT ; -else -return ret; +return -ETIMEDOUT ; } *val = info->value;@@ -116,15 +110,11 @@ static int stmpe_read_temp(struct stmpe_adc *info,stmpe_reg_write (info->stmpe,STMPE_REG_TEMP_CTRL ,STMPE_START_ONE_TEMP_CONV ); - ret =wait_for_completion_interruptible_timeout - (&info->completion,STMPE_ADC_TIMEOUT ); + ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) {mutex_unlock (&info->lock); -if (ret ==0 ) -return -ETIMEDOUT ; -else -return ret; +return -ETIMEDOUT ; }
Quoted 1 line
drivers/iio/adc/stmpe-adc.c static int stmpe_read_temp(struct stmpe_adc *info, · line 120
Quoted 1 line
drivers/iio/adc/stmpe-adc.c +0
-0/*
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 5/5 iio: stmpe-adc: Reset possible interrupts
In reply to Philippe SchenkerFrom: Philippe Schenker <[email protected]>
Clear any interrupt that still is on the device on every channel this driver is activated for in probe and specific channels in the timeout handler.
---
drivers/iio/adc/stmpe-adc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/iio/adc/stmpe-adc.c +5 -0
@@ -80,6 +80,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) { +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_STA , +STMPE_ADC_CH (info->channel));mutex_unlock (&info->lock);return -ETIMEDOUT ; }
@@ -326,6 +328,9 @@ static int stmpe_adc_probe(struct platform_device *pdev)stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_EN , ~(norequest_mask &0xFF )); +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_STA , + ~(norequest_mask &0xFF )); +return devm_iio_device_register (&pdev->dev, indio_dev); }
Signature · 1 line
2.21.0
Jonathan Cameron
maintainerRe: [PATCH 5/5] iio: stmpe-adc: Reset possible interrupts
Quoted 7 lines · On Tue, 7 May 2019 16:36:15 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
Clear any interrupt that still is on the device on every channel this driver is activated for in probe and specific channels in the timeout handler.
Signed-off-by Philippe Schenker <[email protected]>
I'm never particularly clean on blanket resets as they do tend to hide bugs. However, the probe one is something that would happen anyway if there was a 'reset' function.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 29 lines
---
drivers/iio/adc/stmpe-adc.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/iio/adc/stmpe-adc.c +5
-0@@ -80,6 +80,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) { +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_STA , +STMPE_ADC_CH (info->channel));mutex_unlock (&info->lock);return -ETIMEDOUT ; }@@ -326,6 +328,9 @@ static int stmpe_adc_probe(struct platform_device *pdev)stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_EN , ~(norequest_mask &0xFF )); +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_STA , + ~(norequest_mask &0xFF )); +return devm_iio_device_register (&pdev->dev, indio_dev); }
Re: [PATCH 5/5] iio: stmpe-adc: Reset possible interrupts
Quoted 14 lines · Jonathan Cameron
Quoted 7 lines · On Tue, 7 May 2019 16:36:15 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
Clear any interrupt that still is on the device on every channel this driver is activated for in probe and specific channels in the timeout handler.
Signed-off-by Philippe Schenker <[email protected]>I'm never particularly clean on blanket resets as they do tend to hide bugs. However, the probe one is something that would happen anyway if there was a 'reset' function.
Quoted 6 lines
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
You're right about hiding bugs. But if the interrupt for whatever (hardware?) reason does not occur, it prevents further interrupts as it does not get reset.
So this reset takes care that after a timeout one is still able to read out the ADC.
Philippe
Quoted 29 lines
Quoted 29 lines
---
drivers/iio/adc/stmpe-adc.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/iio/adc/stmpe-adc.c +5
-0@@ -80,6 +80,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, ret =wait_for_completion_timeout (&info->completion,STMPE_ADC_TIMEOUT );if (ret <=0 ) { +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_STA , +STMPE_ADC_CH (info->channel));mutex_unlock (&info->lock);return -ETIMEDOUT ; }@@ -326,6 +328,9 @@ static int stmpe_adc_probe(struct platform_device *pdev)stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_EN , ~(norequest_mask &0xFF )); +stmpe_reg_write (info->stmpe,STMPE_REG_ADC_INT_STA , + ~(norequest_mask &0xFF )); +return devm_iio_device_register (&pdev->dev, indio_dev); }
Quoted 10 lines · Philippe Schenker
From: Philippe Schenker <[email protected]>
Add the compatible name to the driver so it gets loaded when the proper node in DT is detected.
Signed-off-by Philippe Schenker <[email protected]>---
drivers/iio/adc/stmpe-adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Why have you sent this set to me?
Signature · 4 lines
Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Quoted 7 lines · Lee Jones
Quoted 5 lines · Philippe Schenker
From: Philippe Schenker <[email protected]>
Add the compatible name to the driver so it gets loaded when the proper node in DT is detected.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Philippe Schenker <[email protected]>---
drivers/iio/adc/stmpe-adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)Why have you sent this set to me?
get_maintainer.pl returned you as a commit signer. You signed the initial commit of this driver and pulled it back then because it is part of a mfd.
Philippe
Jonathan Cameron
maintainerQuoted 6 lines · On Tue, 7 May 2019 16:36:11 +0200 Philippe Schenker <[email protected]> wrote:
From: Philippe Schenker <[email protected]>
Add the compatible name to the driver so it gets loaded when the proper node in DT is detected.
Signed-off-by Philippe Schenker <[email protected]>
Applied thanks,
Jonathan
Quoted 25 lines
---
drivers/iio/adc/stmpe-adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/iio/adc/stmpe-adc.c +6
-1@@ -354,9 +354,14 @@ static struct platform_driver stmpe_adc_driver = { .pm = &stmpe_adc_pm_ops, }, }; -module_platform_driver (stmpe_adc_driver); +static const struct of_device_id stmpe_adc_ids[] = { + { .compatible ="st,stmpe-adc" , }, + { }, +}; +MODULE_DEVICE_TABLE (of, stmpe_adc_ids); +MODULE_AUTHOR ("Stefan Agner <[email protected]>" );MODULE_DESCRIPTION ("STMPEXXX ADC driver" );MODULE_LICENSE ("GPL v2" );