[PATCH 1/3] Miscellaneous touchscreen filter cleanup
Nelson
arhuaco at freaks-unidos.net
Sat Jan 17 01:51:59 CET 2009
From: Nelson Castillo <arhuaco at freaks-unidos.net>
This is a cleanup patch fixing simple mistakes and coding conventions.
It also applies feedback we got from upstream.
Signed-off-by: Nelson Castillo <arhuaco at freaks-unidos.net>
---
0 files changed, 0 insertions(+), 0 deletions(-)
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 5db7a67..014a9e7 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -50,7 +50,7 @@ config TOUCHSCREEN_FILTER_LINEAR
depends on INPUT_TOUCHSCREEN && TOUCHSCREEN_FILTER
default Y
help
- Say Y here if you want to use the Mean touchscreen filter, it
+ Say Y here if you want to use the Linear touchscreen filter, it
enables the use of calibration data for the touchscreen.
endif
diff --git a/drivers/input/touchscreen/ts_filter.c b/drivers/input/touchscreen/ts_filter.c
index 1508388..d936e45 100644
--- a/drivers/input/touchscreen/ts_filter.c
+++ b/drivers/input/touchscreen/ts_filter.c
@@ -20,9 +20,11 @@
#include <linux/device.h>
#include <linux/ts_filter.h>
+static DEFINE_MUTEX(chain_mutex);
+
int ts_filter_create_chain(struct platform_device *pdev,
struct ts_filter_api **api, void **config,
- struct ts_filter **list, int count_coords)
+ struct ts_filter **arr, int count_coords)
{
int count = 0;
struct ts_filter *last = NULL;
@@ -30,35 +32,42 @@ int ts_filter_create_chain(struct platform_device *pdev,
if (!api)
return 0;
- while (*api && count < MAX_TS_FILTER_CHAIN) {
- *list = ((*api)->create)(pdev, *config++, count_coords);
- if (!*list) {
+ mutex_lock(&chain_mutex);
+
+ while (*api) {
+ *arr = ((*api)->create)(pdev, *config++, count_coords);
+ if (!*arr) {
printk(KERN_ERR "Filter %d failed init\n", count);
return count;
}
- (*list)->api = *api++;
+ (*arr)->api = *api++;
if (last)
- last->next = *list;
- last = *list;
- list++;
+ last->next = *arr;
+ last = *arr;
+ arr++;
count++;
}
+ mutex_unlock(&chain_mutex);
+
return count;
}
EXPORT_SYMBOL_GPL(ts_filter_create_chain);
void ts_filter_destroy_chain(struct platform_device *pdev,
- struct ts_filter **list)
+ struct ts_filter **arr)
{
- struct ts_filter **first;
- int count = 0;
+ struct ts_filter **first = arr;
- first = list;
- while (*list && count++ < MAX_TS_FILTER_CHAIN) {
- ((*list)->api->destroy)(pdev, *list);
- list++;
+ mutex_lock(&chain_mutex);
+
+ while (*arr) {
+ ((*arr)->api->destroy)(pdev, *arr);
+ arr++;
}
*first = NULL;
+
+ mutex_unlock(&chain_mutex);
}
EXPORT_SYMBOL_GPL(ts_filter_destroy_chain);
+
diff --git a/drivers/input/touchscreen/ts_filter_linear.c b/drivers/input/touchscreen/ts_filter_linear.c
index 4803e17..3322c69 100644
--- a/drivers/input/touchscreen/ts_filter_linear.c
+++ b/drivers/input/touchscreen/ts_filter_linear.c
@@ -30,9 +30,7 @@
#include <linux/string.h>
-/*
- * sysfs functions
- */
+/* sysfs functions */
static ssize_t const_attr_show(struct kobject *kobj,
@@ -82,9 +80,7 @@ static ssize_t const_store(struct const_obj *obj, struct const_attribute *attr,
return count;
}
-/*
- * filter functions
- */
+/* filter functions */
static struct ts_filter *ts_filter_linear_create(struct platform_device *pdev,
void *conf, int count_coords)
@@ -118,7 +114,6 @@ static struct ts_filter *ts_filter_linear_create(struct platform_device *pdev,
tsfl->const_ktype.default_attrs = tsfl->attrs;
tsfl->c_obj.tsfl = tsfl; /* kernel frees tsfl in const_release */
- /* TODO: /sys/ts-calibration is not OK */
ret = kobject_init_and_add(&tsfl->c_obj.kobj, &tsfl->const_ktype,
&pdev->dev.kobj, "calibration");
if (ret) {
diff --git a/drivers/input/touchscreen/ts_filter_mean.c b/drivers/input/touchscreen/ts_filter_mean.c
index a7b4a5a..409ccc7 100644
--- a/drivers/input/touchscreen/ts_filter_mean.c
+++ b/drivers/input/touchscreen/ts_filter_mean.c
@@ -63,7 +63,7 @@ static struct ts_filter *ts_filter_mean_create(struct platform_device *pdev,
int n;
struct ts_filter_mean *tsfs = kzalloc(
sizeof(struct ts_filter_mean), GFP_KERNEL);
-
+
if (!tsfs)
return NULL;
@@ -112,8 +112,9 @@ static void ts_filter_mean_scale(struct ts_filter *tsf, int *coords)
(tsf->next->api->scale)(tsf->next, coords);
}
-/* give us the raw sample data in x and y, and if we return 1 then you can
- * get a filtered coordinate from tsm->x and tsm->y: if we return 0 you didn't
+/*
+ * Give us the raw sample data in x and y, and if we return 1 then you can
+ * get a filtered coordinate from tsm->x and tsm->y. If we return 0 you didn't
* fill the filter with samples yet.
*/
@@ -125,7 +126,8 @@ static int ts_filter_mean_process(struct ts_filter *tsf, int *coords)
for (n = 0; n < tsf->count_coords; n++) {
- /* has he moved far enough away that we should abandon current
+ /*
+ * Has he moved far enough away that we should abandon current
* low pass filtering state?
*/
if ((coords[n] < (tsfs->reported[n] -
diff --git a/drivers/input/touchscreen/ts_filter_median.c b/drivers/input/touchscreen/ts_filter_median.c
index 883ab06..a033716 100644
--- a/drivers/input/touchscreen/ts_filter_median.c
+++ b/drivers/input/touchscreen/ts_filter_median.c
@@ -141,8 +141,9 @@ static void ts_filter_median_scale(struct ts_filter *tsf, int *coords)
(tsf->next->api->scale)(tsf->next, coords);
}
-/* give us the raw sample data coords, and if we return 1 then you can
- * get a filtered coordinate from coords: if we return 0 you didn't
+/*
+ * Give us the raw sample data coords, and if we return 1 then you can
+ * get a filtered coordinate from coords. If we return 0 you didn't
* fill all the filters with samples yet.
*/
@@ -169,9 +170,10 @@ static int ts_filter_median_process(struct ts_filter *tsf, int *coords)
/* discard the oldest sample in median sorted array */
tsfm->valid--;
- /* sum the middle 3 in the median sorted arrays. We don't divide back
+ /*
+ * Sum the middle 3 in the median sorted arrays. We don't divide back
* down which increases the sum resolution by a factor of 3 until the
- * scale API is called
+ * scale API is called.
*/
for (n = 0; n < tsfm->tsf.count_coords; n++)
/* perform the deletion of the oldest sample */
diff --git a/include/linux/ts_filter.h b/include/linux/ts_filter.h
index 1671044..5578e93 100644
--- a/include/linux/ts_filter.h
+++ b/include/linux/ts_filter.h
@@ -2,20 +2,20 @@
#define __TS_FILTER_H__
/*
- * touchscreen filter
+ * Touchscreen filter.
*
* (c) 2008 Andy Green <andy at openmoko.com>
*/
#include <linux/platform_device.h>
-#define MAX_TS_FILTER_CHAIN 4 /* max filters you can chain up */
-#define MAX_TS_FILTER_COORDS 3 /* X, Y and Z (pressure) */
+#define MAX_TS_FILTER_CHAIN 8 /* Max. filters we can chain up. */
+#define MAX_TS_FILTER_COORDS 3 /* X, Y and Z (pressure). */
struct ts_filter;
-/* operations that a filter can perform
- */
+/* Operations that a filter can perform. */
+
struct ts_filter_api {
struct ts_filter * (*create)(struct platform_device *pdev, void *config,
int count_coords);
@@ -25,32 +25,33 @@ struct ts_filter_api {
void (*scale)(struct ts_filter *filter, int *coords);
};
-/* this is the common part of all filters, the result
- * we use this type as an otherwise opaque handle on to
+/*
+ * This is the common part of all filters.
+ * We use this type as an otherwise opaque handle on to
* the actual filter. Therefore you need one of these
- * at the start of your actual filter struct
+ * at the start of your actual filter struct.
*/
struct ts_filter {
- struct ts_filter *next; /* next in chain */
- struct ts_filter_api *api; /* operations to use for this object */
+ struct ts_filter *next; /* Next in chain. */
+ struct ts_filter_api *api; /* Operations to use for this object. */
int count_coords;
int coords[MAX_TS_FILTER_COORDS];
};
/*
- * helper to create a filter chain from array of API pointers and
- * array of config ints... leaves pointers to created filters in list
- * array and fills in ->next pointers to create the chain
+ * Helper to create a filter chain from an array of API pointers and
+ * array of config ints. Leaves pointers to created filters in arr
+ * array and fills in ->next pointers to create the chain.
*/
extern int ts_filter_create_chain(struct platform_device *pdev,
struct ts_filter_api **api, void **config,
- struct ts_filter **list, int count_coords);
+ struct ts_filter **arr, int count_coords);
-/* helper to destroy a whole chain from the list of filter pointers */
+/* Helper to destroy a whole chain from the list of filter pointers. */
extern void ts_filter_destroy_chain(struct platform_device *pdev,
- struct ts_filter **list);
+ struct ts_filter **arr);
#endif
diff --git a/include/linux/ts_filter_linear.h b/include/linux/ts_filter_linear.h
index dab5390..b4dd8e4 100644
--- a/include/linux/ts_filter_linear.h
+++ b/include/linux/ts_filter_linear.h
@@ -5,7 +5,7 @@
#include <linux/kobject.h>
/*
- * touchscreen linear filter.
+ * Touchscreen linear filter.
*
* Copyright (C) 2008 by Openmoko, Inc.
* Author: Nelson Castillo <arhuaco at freaks-unidos.net>
diff --git a/include/linux/ts_filter_mean.h b/include/linux/ts_filter_mean.h
index 46ff01a..7bf7df6 100644
--- a/include/linux/ts_filter_mean.h
+++ b/include/linux/ts_filter_mean.h
@@ -4,7 +4,7 @@
#include <linux/ts_filter.h>
/*
- * touchscreen filter
+ * Touchscreen filter.
*
* mean
*
diff --git a/include/linux/ts_filter_median.h b/include/linux/ts_filter_median.h
index d816428..eb56eaa 100644
--- a/include/linux/ts_filter_median.h
+++ b/include/linux/ts_filter_median.h
@@ -4,7 +4,7 @@
#include <linux/ts_filter.h>
/*
- * touchscreen filter
+ * Touchscreen filter.
*
* median
*
More information about the openmoko-kernel
mailing list