Skip to contentSkip to conversation

Input: stmpe-ts - remove input_free_device() in stmpe_ts_remove()

PATCH In review Axel Lin 4 participants 6 messages Sep 3, 2010 – Sep 4, 2010

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/2 Input: stmpe-ts - remove input_free_device() in stmpe_ts_remove()

No need to call input_free_device() after input_unregister_device().

---
 drivers/input/touchscreen/stmpe-ts.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/input/touchscreen/stmpe-ts.c +0 -1
index 656148e..0339d1d 100644
@@ -361,7 +361,6 @@ static int __devexit stmpe_ts_remove(struct platform_device *pdev)
 	platform_set_drvdata(pdev, NULL);
 
 	input_unregister_device(ts->idev);
-	input_free_device(ts->idev);
 
 	kfree(ts);
 
Signature · 1 line
1.7.2
author
#1 lore raw

PATCH 2/2 Input: stmpe-ts - return -ENOMEM if memory allocation fail

---
 drivers/input/touchscreen/stmpe-ts.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/input/touchscreen/stmpe-ts.c +6 -2
index 0339d1d..e715b27 100644
@@ -276,12 +276,16 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
 		return ts_irq;
 
 	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
-	if (!ts)
+	if (!ts) {
+		ret = -ENOMEM;
 		goto err_out;
+	}
 
 	idev = input_allocate_device();
-	if (!idev)
+	if (!idev) {
+		ret = -ENOMEM;
 		goto err_free_ts;
+	}
 
 	platform_set_drvdata(pdev, ts);
 	ts->stmpe = stmpe;
Signature · 1 line
1.7.2
#2 lore raw

Re: [PATCH 2/2] Input: stmpe-ts - return -ENOMEM if memory allocation fail

Quoted 1 line · Axel Lin

Basically correct. Should be simpler to just use

	int ret = -ENOMEM;

though.

Quoted 33 lines
---
 drivers/input/touchscreen/stmpe-ts.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/input/touchscreen/stmpe-ts.c +6 -2
index 0339d1d..e715b27 100644
@@ -276,12 +276,16 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
 		return ts_irq;
 
 	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
-	if (!ts)
+	if (!ts) {
+		ret = -ENOMEM;
 		goto err_out;
+	}
 
 	idev = input_allocate_device();
-	if (!idev)
+	if (!idev) {
+		ret = -ENOMEM;
 		goto err_free_ts;
+	}
 
 	platform_set_drvdata(pdev, ts);
 	ts->stmpe = stmpe;
Signature · 1 line
1.7.2
Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
maintainer
#3 lore raw

Re: [PATCH 2/2] Input: stmpe-ts - return -ENOMEM if memory allocation fail

Quoted 9 lines · Wolfram Sang
Quoted 1 line · Axel Lin

Basically correct. Should be simpler to just use

	int ret = -ENOMEM;

though.

No! I hate when people initialize error values like that, because it is so easy to miss the case and end up with wrong value. If the original version of the driver did not initialize it to 0 compiler would warn the author and the error would not make it into the mainline to begin with.

Please explicitly assign error codes in error handling path.

Thanks.

Signature · 1 line
Dmitry
#4 lore raw

Re: [PATCH 2/2] Input: stmpe-ts - return -ENOMEM if memory allocation fail

Quoted 4 lines · Dmitry Torokhov
Quoted 3 lines · Wolfram Sang
Quoted 1 line · Axel Lin
Quoted 8 lines
Quoted 6 lines

Basically correct. Should be simpler to just use

	int ret = -ENOMEM;

though.

No! I hate when people initialize error values like that, because it is

Might be a mileage; I don't insist, though :)

Quoted 4 lines

so easy to miss the case and end up with wrong value. If the original version of the driver did not initialize it to 0 compiler would warn the author and the error would not make it into the mainline to begin with.

So, the initialization to 0 could be removed, at least.

Quoted 1 line

Please explicitly assign error codes in error handling path.

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Acked-by on v1 1/2
#5 lore raw
In reply to Axel Lin

Hi,

Quoted 2 lines · Axel Lin

No need to call input_free_device() after input_unregister_device().

yeah right. The device is input_unregister_device unregisters the device already. Thx for fixing this.

Quoted 18 lines

---
 drivers/input/touchscreen/stmpe-ts.c |    1 -

 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/input/touchscreen/stmpe-ts.c +0 -2
index 656148e..0339d1d 100644
@@ -361,7 +361,6 @@ static int __devexit stmpe_ts_remove(struct platform_device *pdev)
        platform_set_drvdata(pdev, NULL);
 
        input_unregister_device(ts->idev);
-       input_free_device(ts->idev);
 
        kfree(ts);
 
--
Quoted 5 lines

1.7.2

cheers
Luotao Fu
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html