aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-06-08 04:01:46 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-06-08 04:26:01 -0400
commit4aa5bbeca0fe561181e8fba089cd96e449ee5fca (patch)
treea7765508f69637ba69b6d946e816b99ab980f292 /drivers
parent8bf2269fc08b883c728fce2171e9c6747a6a91b4 (diff)
Input: usbtouchscreen - reduce number fo be16_to_cpu conversions
Let's perform be16_to_cpu() conversions once for each received packet, and then use cached values. Makes code a little bit easier to follow. Tested-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 567d57215c28..5d6bf2a4bbad 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -849,29 +849,32 @@ static void nexio_exit(struct usbtouch_usb *usbtouch)
849 849
850static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt) 850static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
851{ 851{
852 int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
853 struct nexio_touch_packet *packet = (void *) pkt; 852 struct nexio_touch_packet *packet = (void *) pkt;
854 struct nexio_priv *priv = usbtouch->priv; 853 struct nexio_priv *priv = usbtouch->priv;
854 unsigned int data_len = be16_to_cpu(packet->data_len);
855 unsigned int x_len = be16_to_cpu(packet->x_len);
856 unsigned int y_len = be16_to_cpu(packet->y_len);
857 int x, y, begin_x, begin_y, end_x, end_y, w, h, ret;
855 858
856 /* got touch data? */ 859 /* got touch data? */
857 if ((pkt[0] & 0xe0) != 0xe0) 860 if ((pkt[0] & 0xe0) != 0xe0)
858 return 0; 861 return 0;
859 862
860 if (be16_to_cpu(packet->data_len) > 0xff) 863 if (data_len > 0xff)
861 packet->data_len = cpu_to_be16(be16_to_cpu(packet->data_len) - 0x100); 864 data_len -= 0x100;
862 if (be16_to_cpu(packet->x_len) > 0xff) 865 if (x_len > 0xff)
863 packet->x_len = cpu_to_be16(be16_to_cpu(packet->x_len) - 0x80); 866 x_len -= 0x80;
864 867
865 /* send ACK */ 868 /* send ACK */
866 ret = usb_submit_urb(priv->ack, GFP_ATOMIC); 869 ret = usb_submit_urb(priv->ack, GFP_ATOMIC);
867 870
868 if (!usbtouch->type->max_xc) { 871 if (!usbtouch->type->max_xc) {
869 usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len); 872 usbtouch->type->max_xc = 2 * x_len;
870 input_set_abs_params(usbtouch->input, ABS_X, 0, 873 input_set_abs_params(usbtouch->input, ABS_X,
871 2 * be16_to_cpu(packet->x_len), 0, 0); 874 0, usbtouch->type->max_xc, 0, 0);
872 usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len); 875 usbtouch->type->max_yc = 2 * y_len;
873 input_set_abs_params(usbtouch->input, ABS_Y, 0, 876 input_set_abs_params(usbtouch->input, ABS_Y,
874 2 * be16_to_cpu(packet->y_len), 0, 0); 877 0, usbtouch->type->max_yc, 0, 0);
875 } 878 }
876 /* 879 /*
877 * The device reports state of IR sensors on X and Y axes. 880 * The device reports state of IR sensors on X and Y axes.
@@ -881,22 +884,21 @@ static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt)
881 * it's disabled (and untested) here as there's no X driver for that. 884 * it's disabled (and untested) here as there's no X driver for that.
882 */ 885 */
883 begin_x = end_x = begin_y = end_y = -1; 886 begin_x = end_x = begin_y = end_y = -1;
884 for (x = 0; x < be16_to_cpu(packet->x_len); x++) { 887 for (x = 0; x < x_len; x++) {
885 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) { 888 if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) {
886 begin_x = x; 889 begin_x = x;
887 continue; 890 continue;
888 } 891 }
889 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) { 892 if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) {
890 end_x = x - 1; 893 end_x = x - 1;
891 for (y = be16_to_cpu(packet->x_len); 894 for (y = x_len; y < data_len; y++) {
892 y < be16_to_cpu(packet->data_len); y++) {
893 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) { 895 if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) {
894 begin_y = y - be16_to_cpu(packet->x_len); 896 begin_y = y - x_len;
895 continue; 897 continue;
896 } 898 }
897 if (end_y == -1 && 899 if (end_y == -1 &&
898 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) { 900 begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) {
899 end_y = y - 1 - be16_to_cpu(packet->x_len); 901 end_y = y - 1 - x_len;
900 w = end_x - begin_x; 902 w = end_x - begin_x;
901 h = end_y - begin_y; 903 h = end_y - begin_y;
902#if 0 904#if 0