diff options
Diffstat (limited to 'drivers/input/touchscreen')
| -rw-r--r-- | drivers/input/touchscreen/edt-ft5x06.c | 9 | ||||
| -rw-r--r-- | drivers/input/touchscreen/usbtouchscreen.c | 40 | 
2 files changed, 46 insertions, 3 deletions
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index b06a5e3a665..64957770b52 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -566,9 +566,12 @@ static ssize_t edt_ft5x06_debugfs_raw_data_read(struct file *file,  	}  	read = min_t(size_t, count, tsdata->raw_bufsize - *off); -	error = copy_to_user(buf, tsdata->raw_buffer + *off, read); -	if (!error) -		*off += read; +	if (copy_to_user(buf, tsdata->raw_buffer + *off, read)) { +		error = -EFAULT; +		goto out; +	} + +	*off += read;  out:  	mutex_unlock(&tsdata->mutex);  	return error ?: read; diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index e32709e0dd6..721fdb3597c 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c @@ -304,6 +304,45 @@ static int e2i_read_data(struct usbtouch_usb *dev, unsigned char *pkt)  #define EGALAX_PKT_TYPE_REPT		0x80  #define EGALAX_PKT_TYPE_DIAG		0x0A +static int egalax_init(struct usbtouch_usb *usbtouch) +{ +	int ret, i; +	unsigned char *buf; +	struct usb_device *udev = interface_to_usbdev(usbtouch->interface); + +	/* +	 * An eGalax diagnostic packet kicks the device into using the right +	 * protocol.  We send a "check active" packet.  The response will be +	 * read later and ignored. +	 */ + +	buf = kmalloc(3, GFP_KERNEL); +	if (!buf) +		return -ENOMEM; + +	buf[0] = EGALAX_PKT_TYPE_DIAG; +	buf[1] = 1;	/* length */ +	buf[2] = 'A';	/* command - check active */ + +	for (i = 0; i < 3; i++) { +		ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), +				      0, +				      USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, +				      0, 0, buf, 3, +				      USB_CTRL_SET_TIMEOUT); +		if (ret >= 0) { +			ret = 0; +			break; +		} +		if (ret != -EPIPE) +			break; +	} + +	kfree(buf); + +	return ret; +} +  static int egalax_read_data(struct usbtouch_usb *dev, unsigned char *pkt)  {  	if ((pkt[0] & EGALAX_PKT_TYPE_MASK) != EGALAX_PKT_TYPE_REPT) @@ -1056,6 +1095,7 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {  		.process_pkt	= usbtouch_process_multi,  		.get_pkt_len	= egalax_get_pkt_len,  		.read_data	= egalax_read_data, +		.init		= egalax_init,  	},  #endif  |