Skip to contentSkip to conversation

iio: mxs-lradc: simplify TS handling

PATCH New Stefan Wahren 4 participants 12 messages Apr 23, 2016 – May 4, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover iio: mxs-lradc: simplify TS handling

This patch series simplifies TS handling of mxs-lradc.

These patches has been tested with i.MX23 and i.MX28 but without a touchscreen. I added only a bogus touchscreen in devicetree.

It would be nice if someone with a real touchscreen could test it.

Changes in V3:
- remove dev.parent assignment as suggested by Dimitry
- add new patch to remove mxs_lradc_ts_unregister
- remove PM implementation from series in order to wait until Ksenija has split the driver

Changes in V2:
- rebase on iio/testing since patch 2 and 3 from V1 has been applied
- also remove input_unregister_device in patch 1
- use mask of virtual channels for IRQ disabling in patch 2

Stefan Wahren (3):
iio: mxs-lradc: simplify TS registration
iio: mxs-lradc: remove mxs_lradc_ts_unregister
iio: mxs-lradc: disable only masked channels in
mxs_lradc_hw_stop

 drivers/iio/adc/mxs-lradc.c |   34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/3 iio: mxs-lradc: simplify TS registration

This patch simplifies the TS registration of mxs-lradc by using devm_input_allocate_device.

---
 drivers/iio/adc/mxs-lradc.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/mxs-lradc.c +2 -8
index ad26da1..3d1d370 100644
@@ -1120,18 +1120,16 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 {
 	struct input_dev *input;
 	struct device *dev = lradc->dev;
-	int ret;
 
 	if (!lradc->use_touchscreen)
 		return 0;
 
-	input = input_allocate_device();
+	input = devm_input_allocate_device(dev);
 	if (!input)
 		return -ENOMEM;
 
 	input->name = DRIVER_NAME;
 	input->id.bustype = BUS_HOST;
-	input->dev.parent = dev;
 	input->open = mxs_lradc_ts_open;
 	input->close = mxs_lradc_ts_close;
 
@@ -1146,11 +1144,8 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 
 	lradc->ts_input = input;
 	input_set_drvdata(input, lradc);
-	ret = input_register_device(input);
-	if (ret)
-		input_free_device(lradc->ts_input);
 
-	return ret;
+	return input_register_device(input);
 }
 
 static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
@@ -1159,7 +1154,6 @@ static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
 		return;
 
 	mxs_lradc_disable_ts(lradc);
-	input_unregister_device(lradc->ts_input);
 }
 
 /*
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 1/3 iio: mxs-lradc: simplify TS registration

Quoted 5 lines · Stefan Wahren

This patch simplifies the TS registration of mxs-lradc by using devm_input_allocate_device.

Quoted 52 lines
---
 drivers/iio/adc/mxs-lradc.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/mxs-lradc.c +2 -8
index ad26da1..3d1d370 100644
@@ -1120,18 +1120,16 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 {
 	struct input_dev *input;
 	struct device *dev = lradc->dev;
-	int ret;
 
 	if (!lradc->use_touchscreen)
 		return 0;
 
-	input = input_allocate_device();
+	input = devm_input_allocate_device(dev);
 	if (!input)
 		return -ENOMEM;
 
 	input->name = DRIVER_NAME;
 	input->id.bustype = BUS_HOST;
-	input->dev.parent = dev;
 	input->open = mxs_lradc_ts_open;
 	input->close = mxs_lradc_ts_close;
 
@@ -1146,11 +1144,8 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 
 	lradc->ts_input = input;
 	input_set_drvdata(input, lradc);
-	ret = input_register_device(input);
-	if (ret)
-		input_free_device(lradc->ts_input);
 
-	return ret;
+	return input_register_device(input);
 }
 
 static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
@@ -1159,7 +1154,6 @@ static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
 		return;
 
 	mxs_lradc_disable_ts(lradc);
-	input_unregister_device(lradc->ts_input);
 }
 
 /*
Signature · 1 line
1.7.9.5
Signature · 1 line
Dmitry
maintainer Applied
#3 lore raw

PATCH v3 1/3 iio: mxs-lradc: simplify TS registration

Quoted 8 lines · Dmitry Torokhov
Quoted 5 lines · Stefan Wahren

This patch simplifies the TS registration of mxs-lradc by using devm_input_allocate_device.

Applied to the togreg branch of iio.git - initially going to be pushed out as testing though may not be until the weekend.

Jonathan

Quoted 54 lines
Quoted 53 lines
---
 drivers/iio/adc/mxs-lradc.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/adc/mxs-lradc.c +2 -8
index ad26da1..3d1d370 100644
@@ -1120,18 +1120,16 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 {
 	struct input_dev *input;
 	struct device *dev = lradc->dev;
-	int ret;
 
 	if (!lradc->use_touchscreen)
 		return 0;
 
-	input = input_allocate_device();
+	input = devm_input_allocate_device(dev);
 	if (!input)
 		return -ENOMEM;
 
 	input->name = DRIVER_NAME;
 	input->id.bustype = BUS_HOST;
-	input->dev.parent = dev;
 	input->open = mxs_lradc_ts_open;
 	input->close = mxs_lradc_ts_close;
 
@@ -1146,11 +1144,8 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 
 	lradc->ts_input = input;
 	input_set_drvdata(input, lradc);
-	ret = input_register_device(input);
-	if (ret)
-		input_free_device(lradc->ts_input);
 
-	return ret;
+	return input_register_device(input);
 }
 
 static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
@@ -1159,7 +1154,6 @@ static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
 		return;
 
 	mxs_lradc_disable_ts(lradc);
-	input_unregister_device(lradc->ts_input);
 }
 
 /*
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v3 2/3 iio: mxs-lradc: remove mxs_lradc_ts_unregister

In reply to Stefan Wahren

After using devm_input_allocate_device for registration the function mxs_lradc_ts_unregister isn't necessary anymore since mxs_lradc_ts_close already does the job.

---
 drivers/iio/adc/mxs-lradc.c |   13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/iio/adc/mxs-lradc.c +1 -12
index 3d1d370..90242ba 100644
@@ -1148,14 +1148,6 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 	return input_register_device(input);
 }
 
-static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
-{
-	if (!lradc->use_touchscreen)
-		return;
-
-	mxs_lradc_disable_ts(lradc);
-}
-
 /*
  * IRQ Handling
  */
@@ -1715,13 +1707,11 @@ static int mxs_lradc_probe(struct platform_device *pdev)
 	ret = iio_device_register(iio);
 	if (ret) {
 		dev_err(dev, "Failed to register IIO device\n");
-		goto err_ts;
+		return ret;
 	}
 
 	return 0;
 
-err_ts:
-	mxs_lradc_ts_unregister(lradc);
 err_ts_register:
 	mxs_lradc_hw_stop(lradc);
 err_dev:
@@ -1739,7 +1729,6 @@ static int mxs_lradc_remove(struct platform_device *pdev)
 	struct mxs_lradc *lradc = iio_priv(iio);
 
 	iio_device_unregister(iio);
-	mxs_lradc_ts_unregister(lradc);
 	mxs_lradc_hw_stop(lradc);
 	mxs_lradc_trigger_remove(iio);
 	iio_triggered_buffer_cleanup(iio);
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v3 2/3 iio: mxs-lradc: remove mxs_lradc_ts_unregister

Quoted 6 lines · Stefan Wahren

After using devm_input_allocate_device for registration the function mxs_lradc_ts_unregister isn't necessary anymore since mxs_lradc_ts_close already does the job.

Quoted 49 lines
---
 drivers/iio/adc/mxs-lradc.c |   13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/iio/adc/mxs-lradc.c +1 -12
index 3d1d370..90242ba 100644
@@ -1148,14 +1148,6 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 	return input_register_device(input);
 }
 
-static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
-{
-	if (!lradc->use_touchscreen)
-		return;
-
-	mxs_lradc_disable_ts(lradc);
-}
-
 /*
  * IRQ Handling
  */
@@ -1715,13 +1707,11 @@ static int mxs_lradc_probe(struct platform_device *pdev)
 	ret = iio_device_register(iio);
 	if (ret) {
 		dev_err(dev, "Failed to register IIO device\n");
-		goto err_ts;
+		return ret;
 	}
 
 	return 0;
 
-err_ts:
-	mxs_lradc_ts_unregister(lradc);
 err_ts_register:
 	mxs_lradc_hw_stop(lradc);
 err_dev:
@@ -1739,7 +1729,6 @@ static int mxs_lradc_remove(struct platform_device *pdev)
 	struct mxs_lradc *lradc = iio_priv(iio);
 
 	iio_device_unregister(iio);
-	mxs_lradc_ts_unregister(lradc);
 	mxs_lradc_hw_stop(lradc);
 	mxs_lradc_trigger_remove(iio);
 	iio_triggered_buffer_cleanup(iio);
Signature · 1 line
1.7.9.5
Signature · 1 line
Dmitry
maintainer Applied
#6 lore raw

PATCH v3 2/3 iio: mxs-lradc: remove mxs_lradc_ts_unregister

Quoted 9 lines · Dmitry Torokhov
Quoted 6 lines · Stefan Wahren

After using devm_input_allocate_device for registration the function mxs_lradc_ts_unregister isn't necessary anymore since mxs_lradc_ts_close already does the job.

Applied.

Quoted 51 lines
Quoted 50 lines
---
 drivers/iio/adc/mxs-lradc.c |   13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/iio/adc/mxs-lradc.c +1 -12
index 3d1d370..90242ba 100644
@@ -1148,14 +1148,6 @@ static int mxs_lradc_ts_register(struct mxs_lradc *lradc)
 	return input_register_device(input);
 }
 
-static void mxs_lradc_ts_unregister(struct mxs_lradc *lradc)
-{
-	if (!lradc->use_touchscreen)
-		return;
-
-	mxs_lradc_disable_ts(lradc);
-}
-
 /*
  * IRQ Handling
  */
@@ -1715,13 +1707,11 @@ static int mxs_lradc_probe(struct platform_device *pdev)
 	ret = iio_device_register(iio);
 	if (ret) {
 		dev_err(dev, "Failed to register IIO device\n");
-		goto err_ts;
+		return ret;
 	}
 
 	return 0;
 
-err_ts:
-	mxs_lradc_ts_unregister(lradc);
 err_ts_register:
 	mxs_lradc_hw_stop(lradc);
 err_dev:
@@ -1739,7 +1729,6 @@ static int mxs_lradc_remove(struct platform_device *pdev)
 	struct mxs_lradc *lradc = iio_priv(iio);
 
 	iio_device_unregister(iio);
-	mxs_lradc_ts_unregister(lradc);
 	mxs_lradc_hw_stop(lradc);
 	mxs_lradc_trigger_remove(iio);
 	iio_triggered_buffer_cleanup(iio);
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v3 3/3 iio: mxs-lradc: disable only masked channels in mxs_lradc_hw_stop

In reply to Stefan Wahren

Disabling of the touchscreen IRQs should be done in mxs_lradc_disable_ts. So disable only the masked virtual channels in mxs_lradc_hw_stop and finally remove the unused function mxs_lradc_irq_en_mask.

---
 drivers/iio/adc/mxs-lradc.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/iio/adc/mxs-lradc.c +3 -8
index 90242ba..b84d37c 100644
@@ -373,13 +373,6 @@ static u32 mxs_lradc_plate_mask(struct mxs_lradc *lradc)
 	return LRADC_CTRL0_MX28_PLATE_MASK;
 }
 
-static u32 mxs_lradc_irq_en_mask(struct mxs_lradc *lradc)
-{
-	if (lradc->soc == IMX23_LRADC)
-		return LRADC_CTRL1_MX23_LRADC_IRQ_EN_MASK;
-	return LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK;
-}
-
 static u32 mxs_lradc_irq_mask(struct mxs_lradc *lradc)
 {
 	if (lradc->soc == IMX23_LRADC)
@@ -1496,7 +1489,9 @@ static void mxs_lradc_hw_stop(struct mxs_lradc *lradc)
 {
 	int i;
 
-	mxs_lradc_reg_clear(lradc, mxs_lradc_irq_en_mask(lradc), LRADC_CTRL1);
+	mxs_lradc_reg_clear(lradc,
+		lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET,
+		LRADC_CTRL1);
 
 	for (i = 0; i < LRADC_MAX_DELAY_CHANS; i++)
 		mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(i));
Signature · 1 line
1.7.9.5
maintainer Applied
#8 lore raw

PATCH v3 3/3 iio: mxs-lradc: disable only masked channels in mxs_lradc_hw_stop

Quoted 8 lines · Stefan Wahren

Disabling of the touchscreen IRQs should be done in mxs_lradc_disable_ts. So disable only the masked virtual channels in mxs_lradc_hw_stop and finally remove the unused function mxs_lradc_irq_en_mask.

Applied to the togreg branch of iio.git

Thanks,

Jonathan

Quoted 34 lines
---
 drivers/iio/adc/mxs-lradc.c |   11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/iio/adc/mxs-lradc.c +3 -8
index 90242ba..b84d37c 100644
@@ -373,13 +373,6 @@ static u32 mxs_lradc_plate_mask(struct mxs_lradc *lradc)
 	return LRADC_CTRL0_MX28_PLATE_MASK;
 }
 
-static u32 mxs_lradc_irq_en_mask(struct mxs_lradc *lradc)
-{
-	if (lradc->soc == IMX23_LRADC)
-		return LRADC_CTRL1_MX23_LRADC_IRQ_EN_MASK;
-	return LRADC_CTRL1_MX28_LRADC_IRQ_EN_MASK;
-}
-
 static u32 mxs_lradc_irq_mask(struct mxs_lradc *lradc)
 {
 	if (lradc->soc == IMX23_LRADC)
@@ -1496,7 +1489,9 @@ static void mxs_lradc_hw_stop(struct mxs_lradc *lradc)
 {
 	int i;
 
-	mxs_lradc_reg_clear(lradc, mxs_lradc_irq_en_mask(lradc), LRADC_CTRL1);
+	mxs_lradc_reg_clear(lradc,
+		lradc->buffer_vchans << LRADC_CTRL1_LRADC_IRQ_EN_OFFSET,
+		LRADC_CTRL1);
 
 	for (i = 0; i < LRADC_MAX_DELAY_CHANS; i++)
 		mxs_lradc_reg_wrt(lradc, 0, LRADC_DELAY(i));
maintainer
#9 lore raw

v3 cover iio: mxs-lradc: simplify TS handling

In reply to Stefan Wahren

Ksenija,

How would you prefer we handle this interaction of this set and your series. Options are:

1. I apply these now and you rebase on top of the result.
2. You pull these into your series, probably after the driver split making sure these improvements end up in the new drivers.
3. We ask Stephan to re roll them at a later date (least preferred option as that adds another person we need to chase down to get to the end of this process!)

No immediate rush on any of the above as we've probably missed this cycle now anyway. I've been cut off today so not sure what Linus has said today.

Jonathan

Quoted 27 lines · Stefan Wahren

This patch series simplifies TS handling of mxs-lradc.

These patches has been tested with i.MX23 and i.MX28 but without a touchscreen. I added only a bogus touchscreen in devicetree.

It would be nice if someone with a real touchscreen could test it.

Changes in V3:
- remove dev.parent assignment as suggested by Dimitry
- add new patch to remove mxs_lradc_ts_unregister
- remove PM implementation from series in order to wait until Ksenija has split the driver

Changes in V2:
- rebase on iio/testing since patch 2 and 3 from V1 has been applied
- also remove input_unregister_device in patch 1
- use mask of virtual channels for IRQ disabling in patch 2

Stefan Wahren (3):
iio: mxs-lradc: simplify TS registration
iio: mxs-lradc: remove mxs_lradc_ts_unregister
iio: mxs-lradc: disable only masked channels in
mxs_lradc_hw_stop

 drivers/iio/adc/mxs-lradc.c |   34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)
#10 lore raw

v3 cover iio: mxs-lradc: simplify TS handling

Hi Jonathan,

Quoted 5 lines · Jonathan Cameron

Ksenija,

How would you prefer we handle this interaction of this set and your series. Options are:

Quoted 8 lines

1. I apply these now and you rebase on top of the result.
2. You pull these into your series, probably after the driver split making sure these improvements end up in the new drivers.
3. We ask Stephan to re roll them at a later date (least preferred option as that adds another person we need to chase down to get to the end of this process!)

No immediate rush on any of the above as we've probably missed this cycle now anyway. I've been cut off today so not sure what Linus has said today.

My understanding was that you will take this patch series so I already included changes made by this patch set in touchscreen part, I will check if I missed something.
I think the best is to apply these now.

Thanks,
Ksenija

Quoted 30 lines

Jonathan

Quoted 27 lines · Stefan Wahren

This patch series simplifies TS handling of mxs-lradc.

These patches has been tested with i.MX23 and i.MX28 but without a touchscreen. I added only a bogus touchscreen in devicetree.

It would be nice if someone with a real touchscreen could test it.

Changes in V3:
- remove dev.parent assignment as suggested by Dimitry
- add new patch to remove mxs_lradc_ts_unregister
- remove PM implementation from series in order to wait until Ksenija has split the driver

Changes in V2:
- rebase on iio/testing since patch 2 and 3 from V1 has been applied
- also remove input_unregister_device in patch 1
- use mask of virtual channels for IRQ disabling in patch 2

Stefan Wahren (3):
iio: mxs-lradc: simplify TS registration
iio: mxs-lradc: remove mxs_lradc_ts_unregister
iio: mxs-lradc: disable only masked channels in
mxs_lradc_hw_stop

 drivers/iio/adc/mxs-lradc.c |   34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)
maintainer
#11 lore raw

v3 cover iio: mxs-lradc: simplify TS handling

Quoted 14 lines · Ksenija Stanojevi?

Hi Jonathan,

Quoted 11 lines · Jonathan Cameron

Ksenija,

How would you prefer we handle this interaction of this set and your series. Options are:

1. I apply these now and you rebase on top of the result.
2. You pull these into your series, probably after the driver split making sure these improvements end up in the new drivers.
3. We ask Stephan to re roll them at a later date (least preferred option as that adds another person we need to chase down to get to the end of this process!)

Quoted 7 lines
Quoted 2 lines

No immediate rush on any of the above as we've probably missed this cycle now anyway. I've been cut off today so not sure what Linus has said today.

My understanding was that you will take this patch series so I already included changes made by this patch set in touchscreen part, I will check if I missed something.
I think the best is to apply these now.

Cool - that's even easier ;)

Jonathan

Quoted 39 lines

Thanks,
Ksenija

Quoted 30 lines

Jonathan

Quoted 27 lines · Stefan Wahren

This patch series simplifies TS handling of mxs-lradc.

These patches has been tested with i.MX23 and i.MX28 but without a touchscreen. I added only a bogus touchscreen in devicetree.

It would be nice if someone with a real touchscreen could test it.

Changes in V3:
- remove dev.parent assignment as suggested by Dimitry
- add new patch to remove mxs_lradc_ts_unregister
- remove PM implementation from series in order to wait until Ksenija has split the driver

Changes in V2:
- rebase on iio/testing since patch 2 and 3 from V1 has been applied
- also remove input_unregister_device in patch 1
- use mask of virtual channels for IRQ disabling in patch 2

Stefan Wahren (3):
iio: mxs-lradc: simplify TS registration
iio: mxs-lradc: remove mxs_lradc_ts_unregister
iio: mxs-lradc: disable only masked channels in
mxs_lradc_hw_stop

 drivers/iio/adc/mxs-lradc.c |   34 ++++++----------------------------
 1 file changed, 6 insertions(+), 28 deletions(-)

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