From patchwork Fri Jan 11 13:14:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1965691 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id E664E40D16 for ; Fri, 11 Jan 2013 13:12:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754711Ab3AKNM1 (ORCPT ); Fri, 11 Jan 2013 08:12:27 -0500 Received: from perceval.ideasonboard.com ([95.142.166.194]:37232 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754133Ab3AKNMY (ORCPT ); Fri, 11 Jan 2013 08:12:24 -0500 Received: from avalon.ideasonboard.com (unknown [91.178.45.2]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DCCE935A84; Fri, 11 Jan 2013 14:12:22 +0100 (CET) From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Hans Verkuil Subject: [PATCH 3/3] uvcvideo: Set error_idx properly for S_EXT_CTRLS failures Date: Fri, 11 Jan 2013 14:14:00 +0100 Message-Id: <1357910040-27463-4-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1357910040-27463-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1357910040-27463-1-git-send-email-laurent.pinchart@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The uvc_set_ctrl() calls don't write to the hardware. A failure at that point thus leaves the device in a clean state, with no control modified. Set the error_idx field to the count value to reflect that, as per the V4L2 specification. TRY_EXT_CTRLS is unchanged and the error_idx field must always be set to the failed control index in that case. Signed-off-by: Laurent Pinchart Acked-by: Hans Verkuil --- drivers/media/usb/uvc/uvc_v4l2.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 5eb8989..68d59b5 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -685,7 +685,8 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg) ret = uvc_ctrl_set(chain, ctrl); if (ret < 0) { uvc_ctrl_rollback(handle); - ctrls->error_idx = i; + ctrls->error_idx = cmd == VIDIOC_S_EXT_CTRLS + ? ctrls->count : i; return ret; } }