[PATCH 2/2] Cleanup - Add internal functions for clearing filters

Nelson Castillo nelsoneci at gmail.com
Wed Dec 3 10:54:47 CET 2008


This patch adds the following functions:

* ts_filter_mean_clear_internal
* ts_filter_median_clear_internal

The idea: avoid calling the clean function of other filters
          when we initialize one.

Also:

* modify messages for consistency.
* remove an unneeded else.

Signed-off-by: Nelson Castillo <nelsoneci at gmail.com>
---

 drivers/input/touchscreen/ts_filter_mean.c   |   18 ++++++++++++------
 drivers/input/touchscreen/ts_filter_median.c |   21 +++++++++++++--------
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/drivers/input/touchscreen/ts_filter_mean.c b/drivers/input/touchscreen/ts_filter_mean.c
index 2322432..a2f1748 100644
--- a/drivers/input/touchscreen/ts_filter_mean.c
+++ b/drivers/input/touchscreen/ts_filter_mean.c
@@ -36,7 +36,7 @@
 #include <linux/slab.h>
 #include <linux/ts_filter_mean.h>
 
-static void ts_filter_mean_clear(struct ts_filter *tsf)
+static void ts_filter_mean_clear_internal(struct ts_filter *tsf)
 {
 	struct ts_filter_mean *tsfs = (struct ts_filter_mean *)tsf;
 	int n;
@@ -46,6 +46,11 @@ static void ts_filter_mean_clear(struct ts_filter *tsf)
 		tsfs->ftail[n] = 0;
 		tsfs->lowpass[n] = 0;
 	}
+}
+
+static void ts_filter_mean_clear(struct ts_filter *tsf)
+{
+	ts_filter_mean_clear_internal(tsf);
 
 	if (tsf->next) /* chain */
 		(tsf->next->api->clear)(tsf->next);
@@ -82,10 +87,11 @@ static struct ts_filter *ts_filter_mean_create(void *config, int count_coords)
 	if (!tsfs->config->averaging_threshold)
 		tsfs->config->averaging_threshold = 0xffff; /* always active */
 
-	ts_filter_mean_clear(&tsfs->tsf);
+	ts_filter_mean_clear_internal(&tsfs->tsf);
 
-	printk(KERN_INFO "  Created Mean ts filter len %d thresh %d\n",
-		       tsfs->config->extent, tsfs->config->averaging_threshold);
+	printk(KERN_INFO"  Created Mean ts filter len %d depth %d thresh %d\n",
+	       tsfs->config->extent, count_coords,
+	       tsfs->config->averaging_threshold);
 
 	return &tsfs->tsf;
 }
@@ -151,8 +157,8 @@ static int ts_filter_mean_process(struct ts_filter *tsf, int *coords)
 
 	if (tsf->next) /* chain */
 		return (tsf->next->api->process)(tsf->next, coords);
-// 	else
-		return 1;
+
+	return 1;
 }
 
 struct ts_filter_api ts_filter_mean_api = {
diff --git a/drivers/input/touchscreen/ts_filter_median.c b/drivers/input/touchscreen/ts_filter_median.c
index d60c431..67dd3fe 100644
--- a/drivers/input/touchscreen/ts_filter_median.c
+++ b/drivers/input/touchscreen/ts_filter_median.c
@@ -65,13 +65,18 @@ static void ts_filter_median_del(int *p, int value, int count)
 }
 
 
-static void ts_filter_median_clear(struct ts_filter *tsf)
+static void ts_filter_median_clear_internal(struct ts_filter *tsf)
 {
 	struct ts_filter_median *tsfm = (struct ts_filter_median *)tsf;
 
 	tsfm->pos = 0;
 	tsfm->valid = 0;
 
+}
+static void ts_filter_median_clear(struct ts_filter *tsf)
+{
+	ts_filter_median_clear_internal(tsf);
+
 	if (tsf->next) /* chain */
 		(tsf->next->api->clear)(tsf->next);
 }
@@ -92,10 +97,6 @@ static struct ts_filter *ts_filter_median_create(void * conf, int count_coords)
 
 	tsfm->config->midpoint = (tsfm->config->extent >> 1) + 1;
 
-	printk(KERN_INFO"  Creating Median ts filter len %d depth %d dec %d\n",
-		tsfm->config->extent, count_coords,
-					    tsfm->config->decimation_threshold);
-
 	p = kmalloc(2 * count_coords * sizeof(int) * (tsfm->config->extent + 1),
 								    GFP_KERNEL);
 	if (!p) {
@@ -110,7 +111,11 @@ static struct ts_filter *ts_filter_median_create(void * conf, int count_coords)
 		p += tsfm->config->extent + 1;
 	}
 
-	ts_filter_median_clear(&tsfm->tsf);
+	ts_filter_median_clear_internal(&tsfm->tsf);
+
+	printk(KERN_INFO"  Created Median ts filter len %d depth %d dec %d\n",
+	       tsfm->config->extent, count_coords,
+	       tsfm->config->decimation_threshold);
 
 	return &tsfm->tsf;
 }
@@ -195,8 +200,8 @@ static int ts_filter_median_process(struct ts_filter *tsf, int *coords)
 
 	if (tsf->next) /* chain */
 		return (tsf->next->api->process)(tsf->next, coords);
-	else
-		return 1;
+
+	return 1;
 }
 
 struct ts_filter_api ts_filter_median_api = {




More information about the openmoko-kernel mailing list