diff mbox series

[25/40] mfd: ti_am335x_tscadc: Add a boolean to clarify the presence of a touchscreen

Message ID 20210825152518.379386-26-miquel.raynal@bootlin.com
State New
Headers show
Series TI AM437X ADC1 | expand

Commit Message

Miquel Raynal Aug. 25, 2021, 3:25 p.m. UTC
Just checking the number of wires will soon not be enough, add a boolean
to indicated the actual use or not of the touchscreen.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mfd/ti_am335x_tscadc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Aug. 30, 2021, 1:59 p.m. UTC | #1
On Wed, 25 Aug 2021 17:25:03 +0200
Miquel Raynal <miquel.raynal@bootlin.com> wrote:

> Just checking the number of wires will soon not be enough, add a boolean
> to indicated the actual use or not of the touchscreen.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> ---
>  drivers/mfd/ti_am335x_tscadc.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
> index 2f934fd2154a..30f53cdb41f8 100644
> --- a/drivers/mfd/ti_am335x_tscadc.c
> +++ b/drivers/mfd/ti_am335x_tscadc.c
> @@ -121,6 +121,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	const __be32 *cur;
>  	struct clk *clk;
>  	u32 val;
> +	bool use_tsc = false;
>  	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
>  	int total_channels, err;
>  
> @@ -141,6 +142,8 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
>  	of_property_read_u32(node, "ti,wires", &tscmag_wires);
>  	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
> +	if (tscmag_wires)
> +		use_tsc = true;
>  
>  	node = of_get_child_by_name(pdev->dev.of_node, "adc");
>  	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
> @@ -163,7 +166,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>  
> -	if (readouts * 2 + 2 + adc_channels > 16) {
> +	if (use_tsc && (readouts * 2 + 2 + adc_channels > 16)) {

This one is adding a check that wasn't there before.  The description should
mention why it will now be necessary and isn't a bug...

>  		dev_err(&pdev->dev, "Too many step configurations requested\n");
>  		return -EINVAL;
>  	}
> @@ -218,7 +221,7 @@ static	int ti_tscadc_probe(struct platform_device *pdev)
>  	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
>  	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
>  
> -	if (tscmag_wires > 0) {
> +	if (use_tsc) {
>  		tscadc->ctrl |= CNTRLREG_TSC_ENB;
>  		if (tscmag_wires == 5)
>  			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;
diff mbox series

Patch

diff --git a/drivers/mfd/ti_am335x_tscadc.c b/drivers/mfd/ti_am335x_tscadc.c
index 2f934fd2154a..30f53cdb41f8 100644
--- a/drivers/mfd/ti_am335x_tscadc.c
+++ b/drivers/mfd/ti_am335x_tscadc.c
@@ -121,6 +121,7 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 	const __be32 *cur;
 	struct clk *clk;
 	u32 val;
+	bool use_tsc = false;
 	int tscmag_wires = 0, adc_channels = 0, readouts = 0, cell_idx = 0;
 	int total_channels, err;
 
@@ -141,6 +142,8 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 	node = of_get_child_by_name(pdev->dev.of_node, "tsc");
 	of_property_read_u32(node, "ti,wires", &tscmag_wires);
 	of_property_read_u32(node, "ti,coordiante-readouts", &readouts);
+	if (tscmag_wires)
+		use_tsc = true;
 
 	node = of_get_child_by_name(pdev->dev.of_node, "adc");
 	of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
@@ -163,7 +166,7 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (readouts * 2 + 2 + adc_channels > 16) {
+	if (use_tsc && (readouts * 2 + 2 + adc_channels > 16)) {
 		dev_err(&pdev->dev, "Too many step configurations requested\n");
 		return -EINVAL;
 	}
@@ -218,7 +221,7 @@  static	int ti_tscadc_probe(struct platform_device *pdev)
 	tscadc->ctrl = CNTRLREG_TSC_STEPCONFIGWRT | CNTRLREG_STEPID;
 	regmap_write(tscadc->regmap, REG_CTRL, tscadc->ctrl);
 
-	if (tscmag_wires > 0) {
+	if (use_tsc) {
 		tscadc->ctrl |= CNTRLREG_TSC_ENB;
 		if (tscmag_wires == 5)
 			tscadc->ctrl |= CNTRLREG_TSC_5WIRE;