From patchwork Fri Jun 4 07:51:43 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 104230 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o547pvEi021399 for ; Fri, 4 Jun 2010 07:51:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753330Ab0FDHvu (ORCPT ); Fri, 4 Jun 2010 03:51:50 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:47909 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752511Ab0FDHvt (ORCPT ); Fri, 4 Jun 2010 03:51:49 -0400 Received: by pvg16 with SMTP id 16so459815pvg.19 for ; Fri, 04 Jun 2010 00:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:subject:to:cc:date :message-id:user-agent:mime-version:content-type :content-transfer-encoding; bh=B1kT5WDBHHIYOGCkbKuE7o6yTbdmlVXUTeiJ825jZoY=; b=g2460ztDww/qqGUC599MJqeX6GgEYhE438h3LVz/Ov+B0CSzz5VgPhKxUkXGmKUOYr ohZXF0tV0pnNpDBtgicsqQQMcX3L/azKgJKKi3f3G4VIkbVuHKREy6pY5ctXMm2NlyAu WwmYaQwGLQBY/JgUG3T4xfBSc/ji5mMGQ4tSU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:subject:to:cc:date:message-id:user-agent:mime-version :content-type:content-transfer-encoding; b=Xrat5pc0Kche55WAsvn84TgyBt7mkxpIsBdpnG4ZvB+bF5JFCugBUEoQ5NZgzjWJqJ oIF/h29wtZs+R+dR6n30WYBRE0FdG2Rwxic87lM3ldn6V01PZ7M1FbX5u5d3t9unCACJ iGnhd23tDgI/1VJDh2aDOoKgsOCPOwkueFAZ0= Received: by 10.141.214.32 with SMTP id r32mr8692743rvq.27.1275637907914; Fri, 04 Jun 2010 00:51:47 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-24-6-153-206.hsd1.ca.comcast.net [24.6.153.206]) by mx.google.com with ESMTPS id i19sm2222314rvn.11.2010.06.04.00.51.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 04 Jun 2010 00:51:47 -0700 (PDT) From: Dmitry Torokhov Subject: [PATCH] Input: usbtouchscreen - reduce number fo be16_to_cpu conversions To: Ondrej Zary Cc: linux-input@vger.kernel.org Date: Fri, 04 Jun 2010 00:51:43 -0700 Message-ID: <20100604075057.15829.92443.stgit@localhost.localdomain> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 04 Jun 2010 07:51:57 +0000 (UTC) diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index 567d572..5d6bf2a 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) static int nexio_read_data(struct usbtouch_usb *usbtouch, unsigned char *pkt) { - int x, y, begin_x, begin_y, end_x, end_y, w, h, ret; struct nexio_touch_packet *packet = (void *) pkt; struct nexio_priv *priv = usbtouch->priv; + unsigned int data_len = be16_to_cpu(packet->data_len); + unsigned int x_len = be16_to_cpu(packet->x_len); + unsigned int y_len = be16_to_cpu(packet->y_len); + int x, y, begin_x, begin_y, end_x, end_y, w, h, ret; /* got touch data? */ if ((pkt[0] & 0xe0) != 0xe0) return 0; - if (be16_to_cpu(packet->data_len) > 0xff) - packet->data_len = cpu_to_be16(be16_to_cpu(packet->data_len) - 0x100); - if (be16_to_cpu(packet->x_len) > 0xff) - packet->x_len = cpu_to_be16(be16_to_cpu(packet->x_len) - 0x80); + if (data_len > 0xff) + data_len -= 0x100; + if (x_len > 0xff) + x_len -= 0x80; /* send ACK */ ret = usb_submit_urb(priv->ack, GFP_ATOMIC); if (!usbtouch->type->max_xc) { - usbtouch->type->max_xc = 2 * be16_to_cpu(packet->x_len); - input_set_abs_params(usbtouch->input, ABS_X, 0, - 2 * be16_to_cpu(packet->x_len), 0, 0); - usbtouch->type->max_yc = 2 * be16_to_cpu(packet->y_len); - input_set_abs_params(usbtouch->input, ABS_Y, 0, - 2 * be16_to_cpu(packet->y_len), 0, 0); + usbtouch->type->max_xc = 2 * x_len; + input_set_abs_params(usbtouch->input, ABS_X, + 0, usbtouch->type->max_xc, 0, 0); + usbtouch->type->max_yc = 2 * y_len; + input_set_abs_params(usbtouch->input, ABS_Y, + 0, usbtouch->type->max_yc, 0, 0); } /* * 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) * it's disabled (and untested) here as there's no X driver for that. */ begin_x = end_x = begin_y = end_y = -1; - for (x = 0; x < be16_to_cpu(packet->x_len); x++) { + for (x = 0; x < x_len; x++) { if (begin_x == -1 && packet->data[x] > NEXIO_THRESHOLD) { begin_x = x; continue; } if (end_x == -1 && begin_x != -1 && packet->data[x] < NEXIO_THRESHOLD) { end_x = x - 1; - for (y = be16_to_cpu(packet->x_len); - y < be16_to_cpu(packet->data_len); y++) { + for (y = x_len; y < data_len; y++) { if (begin_y == -1 && packet->data[y] > NEXIO_THRESHOLD) { - begin_y = y - be16_to_cpu(packet->x_len); + begin_y = y - x_len; continue; } if (end_y == -1 && begin_y != -1 && packet->data[y] < NEXIO_THRESHOLD) { - end_y = y - 1 - be16_to_cpu(packet->x_len); + end_y = y - 1 - x_len; w = end_x - begin_x; h = end_y - begin_y; #if 0