Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3488895pxf; Mon, 15 Mar 2021 10:38:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3+RMY7NB2Qcd4MKNqMeEvwlz4F4D7rb726xXjS6KjBN6sljVdzfnahkEpAR6qyDOUP2Zo X-Received: by 2002:a17:906:cecc:: with SMTP id si12mr24957902ejb.461.1615829911829; Mon, 15 Mar 2021 10:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615829911; cv=none; d=google.com; s=arc-20160816; b=bYz7Cvxx+W27dF7EGxfoO970pBTqCwsk745qu14ZwmGY2/vXUPHQ5D37lmopOC27wF zUCskNAsAviQ0/PcwZ7h4X96Vubm/3OL7j8YQ4DP3vxbcgWEetv6J8rVXyrIRKjf3TsR lUYTvWIL0sz/w/81D2CJWzUVqQJyWJ9GFtfk0HtugxLYXYmma/fPnyEZTbsjxzXDkQHd dHA3kOpYmJnyKtLhc49gWTu+l9ELcgARMFbWinunUlrd4AdIjrzmZVwvJKIxTZk4oy4k ep100sup/uJ/9ZKWP+ztqt/czoR7ya0pJAH7RyuodJET8mwIUlYAFAh23/GpuWMhiyLC Mv+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Gu1wcX48JlWZ2XlvoaI7f2bN46PWKUfPqpf8jSMDkdo=; b=jEaTEnjlvcAiDqNZWAQ1nbcqMUmlvLn/BzELkqaWHnZaSj/P/im7G7fh35wU3UZHfV R7npck1BKX1KLh7tjTni9AGA+1OwGv/DUGukTULHqyXgHTVsp01nNh0ebdUhSkP5z5SG YMvI4R8ZBvxmtrKOeiXIc56ofPO23ZFkDCkhiQxNtFyUuSCvgRU6L7jk9LQiWj4bQge7 LfJ1pQUgnz0VqVn/exeDGfe+d2KNHvphCQFyPnL7tJJNuSgTLwaloUqAoRTFSBoVNLz9 yfbHheIIf+tXLeDZsK+i7W8nBpv+WJbIqRRNshu6rzuBmREkT1SKi9SO+gFLR34wOmqc lvYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nHNLDKWR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si11177746edr.381.2021.03.15.10.38.08; Mon, 15 Mar 2021 10:38:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nHNLDKWR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236663AbhCORgw (ORCPT + 99 others); Mon, 15 Mar 2021 13:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236321AbhCORgS (ORCPT ); Mon, 15 Mar 2021 13:36:18 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64596C06175F for ; Mon, 15 Mar 2021 10:36:18 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id mm21so67602301ejb.12 for ; Mon, 15 Mar 2021 10:36:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Gu1wcX48JlWZ2XlvoaI7f2bN46PWKUfPqpf8jSMDkdo=; b=nHNLDKWRORkq3k0tierRfwmLevAt3HWL/9TfLhhjs3xnMTspkMjFmqODWROATtVFp9 fkopzFEy/SO9q270XgObukLBPiL6I6p8PBEx0XErIAk4u05k7vpyL0DARhU4M+wmYXgo IzK3VDOMamTu3DMvOdR5cb0cYfim1V9lYVHRs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Gu1wcX48JlWZ2XlvoaI7f2bN46PWKUfPqpf8jSMDkdo=; b=HjfV4cKOBidvKOdlYSap+R8mTTHXp+Y+MIrGRFRcZ7H+fuaYZTKBUi5BJMC7je1aeY +jenP/L1nYFp/fofJVwNYqw6Kor+T9vdjS4ERwdOqsQODEf+cAjWM+MVK01QiyqjoVX8 kDUeqqlHAeh85jh80fu/t4x1CwE20KVv3hgdSv6aqIBsEyI4QB+ciAEUeEGHbhCBAPP6 yLT4GEnXMv1TXdNyc662iSigztJzfdSUNjYwQD1k4nGyLYDaE9cN/DbDn0UAOz2/teI6 JhfXK3ZqoQo2+xG4L1bBc1zhI62X283LB6WAIcFKA1R4QzS9KvNWkQl4UvY587AFW7GB jdsw== X-Gm-Message-State: AOAM530qdOfgM5WyzPsj5SpN0mV/qYfN8b0TlzV3Q+6KI6RJGdBKI2e2 DtNXnHuIRlxhy3JX9TqS4YnWPvFoQzcMZzxudcA= X-Received: by 2002:a17:907:d09:: with SMTP id gn9mr24166311ejc.538.1615829777126; Mon, 15 Mar 2021 10:36:17 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id a3sm8109239ejv.40.2021.03.15.10.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 10:36:16 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda , Hans Verkuil Subject: [PATCH v4 10/11] media: uvcvideo: Return -EACCES to inactive controls Date: Mon, 15 Mar 2021 18:36:08 +0100 Message-Id: <20210315173609.1547857-11-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210315173609.1547857-1-ribalda@chromium.org> References: <20210315173609.1547857-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a control is inactive return -EACCES to let the userspace know that the value will not be applied automatically when the control is active again. Signed-off-by: Ricardo Ribalda Suggested-by: Hans Verkuil --- drivers/media/usb/uvc/uvc_ctrl.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index be0fadaf414c..f1593dc2f1ef 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1580,6 +1580,18 @@ int uvc_ctrl_begin(struct uvc_video_chain *chain) return mutex_lock_interruptible(&chain->ctrl_mutex) ? -ERESTARTSYS : 0; } +static bool uvc_ctrl_is_inactive(struct uvc_control *ctrl) +{ + struct uvc_control_mapping *map; + + list_for_each_entry(map, &ctrl->info.mappings, list) { + if (map->master_id) + return true; + } + + return false; +} + static int uvc_ctrl_commit_entity(struct uvc_device *dev, struct uvc_entity *entity, int rollback) { @@ -1623,8 +1635,11 @@ static int uvc_ctrl_commit_entity(struct uvc_device *dev, ctrl->dirty = 0; - if (ret < 0) + if (ret < 0) { + if (uvc_ctrl_is_inactive(ctrl)) + return -EACCES; return ret; + } } return 0; -- 2.31.0.rc2.261.g7f71774620-goog