Re: [PATCH] HID: New hid-cp2112 driver.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2013-08-21 at 15:11 -0500, David Barksdale wrote:
> From: David Barksdale <dbarksdale@xxxxxxxxxxx>

> +static int cp2112_wait(struct cp2112_device *dev, atomic_t *avail)
> +{
> +	int ret = 0;
> +
> +	ret = wait_event_interruptible_timeout(dev->wait,
> +		atomic_read(avail), msecs_to_jiffies(50));

A symbolic constant for the timeout please.

> +	if (-ERESTARTSYS == ret)
> +		return ret;
> +	if (!ret)
> +		return -ETIMEDOUT;
> +	atomic_set(avail, 0);
> +	return 0;
> +}
> +
> +static int cp2112_xfer_status(struct cp2112_device *dev)
> +{
> +	struct hid_device *hdev = dev->hdev;
> +	uint8_t buf[2];
> +	int ret;
> +
> +	buf[0] = TRANSFER_STATUS_REQUEST;
> +	buf[1] = 0x01;
> +	atomic_set(&dev->xfer_avail, 0);

Why an atomic here? Flags would also do the job.

> +	ret = hdev->hid_output_raw_report(hdev, buf, 2, HID_OUTPUT_REPORT);
> +	if (ret < 0) {
> +		hid_warn(hdev, "Error requesting status: %d\n", ret);
> +		return ret;
> +	}
> +	ret = cp2112_wait(dev, &dev->xfer_avail);
> +	if (ret)
> +		return ret;
> +	return dev->xfer_status;
> +}
> +
> +static int cp2112_read(struct cp2112_device *dev, uint8_t *data, size_t size)
> +{
> +	struct hid_device *hdev = dev->hdev;
> +	uint8_t buf[3];

This is DMA from the stack and iolates the DMA coherency rules.

	Regards
		Oliver


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux