Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5787980pxu; Wed, 23 Dec 2020 05:38:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyfkkgLpC/MQWrZbzbq3x2/Z1MMrJBCONLRW69EgsP37vGxNYyIidOsZT0LytL+G2WYNa9 X-Received: by 2002:a17:906:58f:: with SMTP id 15mr12534434ejn.67.1608730708195; Wed, 23 Dec 2020 05:38:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608730708; cv=none; d=google.com; s=arc-20160816; b=qmYYI9j5s8gOZs/IXjC9UmuFxOneRJSgHKMRubREQKKbqe0RPSu+2eWMfVeHdwFafF KaXCbT2giHgNJyy98DVOTvHo8Y8d22bWHnLl9V3vUN8IvaiEqsTtNLxhdAW3P8ywDLXJ fnJXYJjvczO4e+KIGQZ/2YwboIL4oSh8+/K8eTPsS/O5GJiYxGGT9+6u4eHsvRMDwM1D hE0LG/V0miSFge4kB1mGLqVh/x9DfUveL2Re3ArsB7adTvOdCGE7b26YrQrTcw+H1YRS u5NLSutQ4B8jvIZI+yVF6+QjjQuLzAZbp3rK7EVLn9eFZKFx64W+oiqUcgmYWrF1Jw5l UlVQ== 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=vMMhND9dbUUEj2ww7vseY1DEK0ffrGAQ/eCkOIT9i/k=; b=aGk72FaC4VxmnskMMc8NHhgPB/BcRdppodKRvCKARuR+C8OhhSa8cDkHmWzpJib3Fb DYfyYaA3rYEyOA8gzuDqH5KplQLgUMc34WviSpn4ppC3suTsStx5ocEda5Mm9cV8r2nl SNAHCJSgr2uTnLfhuXdsbsNsOigAWT4qqr26N4RLWB8CUXugnjPJUBOMQXPeRdcCiSKO 812kKku7FrXbz3XgOJFNjtpQ7Yz7F9jKXx5MhG5bUZIV2LjnkbExmi/4Em7jwVafNLBn MTs3KRD8odmZ3GCFM4aqqRsDMN+FI7To0GiFBje8R8VUSSAQtxEi3+NjtXEK/h0tKff5 6xOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FAXL7dxc; 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 a12si14275410edk.285.2020.12.23.05.38.05; Wed, 23 Dec 2020 05:38:28 -0800 (PST) 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=FAXL7dxc; 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 S1728737AbgLWNgz (ORCPT + 99 others); Wed, 23 Dec 2020 08:36:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728691AbgLWNgx (ORCPT ); Wed, 23 Dec 2020 08:36:53 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DF1C061248 for ; Wed, 23 Dec 2020 05:35:35 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id t16so18663148wra.3 for ; Wed, 23 Dec 2020 05:35:35 -0800 (PST) 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=vMMhND9dbUUEj2ww7vseY1DEK0ffrGAQ/eCkOIT9i/k=; b=FAXL7dxcCL6+kQVm4vQPfQYwf4m1b9e17z1aW83BL0qeHhqNR/BPwmZjV9xP/F9IiB 2xYrAlbxaGz0xK2XyuZC+0asToc5ri1h2WlafJFXbdcqpMQNzFsmQr3Q1LXpQh/a2mok 3t1Hh73aDh8ilR03DRLxmxqKaZY4ZGQeQZ85g= 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=vMMhND9dbUUEj2ww7vseY1DEK0ffrGAQ/eCkOIT9i/k=; b=GbStoiKA/6BgV1qWDhXbLhjFUo0WFgDL6HuPCqUmgNpyRKJyMLZqOjIg47/V4b2aUb JNr3b0mSisiuVF9TbsWh5cOA10iJbrbmSHWh6usmWeA+bCD3bpcpfWsk2wFBEsHZIEb3 EI94OU7TM8yvuuSFNWMOCgJmMxgd7xbVWaeCDob6+mvMTer7zpBhtG8Itq06lE/D0uIa LK+QOAr2oyskWn4gc6kx+LdURl0fLjPmmN/UGIE+5gwzq4to1dkeH3npmf6AmgRR/umw NjJDv9VJlpQOMBAPJhkZ/z6iPM0to85A+7xIdHp186UErR6Vq8sheaktuMQFGweXkG7V aNcw== X-Gm-Message-State: AOAM533OLM93SrUuwdckinwuLqjHpydhlxnxiSWmbKLBX6U8q+g/bCXT XZctoNH/Mvex/owmnfmEsDDl28ZuusmFPKIur20= X-Received: by 2002:a5d:6cc9:: with SMTP id c9mr28856322wrc.411.1608730534140; Wed, 23 Dec 2020 05:35:34 -0800 (PST) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id q143sm31572247wme.28.2020.12.23.05.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 05:35:33 -0800 (PST) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ricardo Ribalda Subject: [PATCH v7 04/12] media: uvcvideo: Provide sync and async uvc_ctrl_status_event Date: Wed, 23 Dec 2020 14:35:20 +0100 Message-Id: <20201223133528.55014-5-ribalda@chromium.org> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20201223133528.55014-1-ribalda@chromium.org> References: <20201223133528.55014-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split the functionality of void uvc_ctrl_status_event_work in two, so it can be called by functions outside interrupt context and not part of an URB. Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 25 +++++++++++++++---------- drivers/media/usb/uvc/uvc_status.c | 3 ++- drivers/media/usb/uvc/uvcvideo.h | 4 +++- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 9f6174a10e73..4d43f4c3e349 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1254,17 +1254,12 @@ static void uvc_ctrl_send_slave_event(struct uvc_video_chain *chain, uvc_ctrl_send_event(chain, handle, ctrl, mapping, val, changes); } -static void uvc_ctrl_status_event_work(struct work_struct *work) +void uvc_ctrl_status_event(struct uvc_video_chain *chain, + struct uvc_control *ctrl, const u8 *data) { - struct uvc_device *dev = container_of(work, struct uvc_device, - async_ctrl.work); - struct uvc_ctrl_work *w = &dev->async_ctrl; - struct uvc_video_chain *chain = w->chain; struct uvc_control_mapping *mapping; - struct uvc_control *ctrl = w->ctrl; struct uvc_fh *handle; unsigned int i; - int ret; mutex_lock(&chain->ctrl_mutex); @@ -1272,7 +1267,7 @@ static void uvc_ctrl_status_event_work(struct work_struct *work) ctrl->handle = NULL; list_for_each_entry(mapping, &ctrl->info.mappings, list) { - s32 value = __uvc_ctrl_get_value(mapping, w->data); + s32 value = __uvc_ctrl_get_value(mapping, data); /* * handle may be NULL here if the device sends auto-update @@ -1291,6 +1286,16 @@ static void uvc_ctrl_status_event_work(struct work_struct *work) } mutex_unlock(&chain->ctrl_mutex); +} + +static void uvc_ctrl_status_event_work(struct work_struct *work) +{ + struct uvc_device *dev = container_of(work, struct uvc_device, + async_ctrl.work); + struct uvc_ctrl_work *w = &dev->async_ctrl; + int ret; + + uvc_ctrl_status_event(w->chain, w->ctrl, w->data); /* Resubmit the URB. */ w->urb->interval = dev->int_ep->desc.bInterval; @@ -1300,8 +1305,8 @@ static void uvc_ctrl_status_event_work(struct work_struct *work) ret); } -bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain, - struct uvc_control *ctrl, const u8 *data) +bool uvc_ctrl_status_event_async(struct urb *urb, struct uvc_video_chain *chain, + struct uvc_control *ctrl, const u8 *data) { struct uvc_device *dev = chain->dev; struct uvc_ctrl_work *w = &dev->async_ctrl; diff --git a/drivers/media/usb/uvc/uvc_status.c b/drivers/media/usb/uvc/uvc_status.c index 2bdb0ff203f8..3e26d82a906d 100644 --- a/drivers/media/usb/uvc/uvc_status.c +++ b/drivers/media/usb/uvc/uvc_status.c @@ -179,7 +179,8 @@ static bool uvc_event_control(struct urb *urb, switch (status->bAttribute) { case UVC_CTRL_VALUE_CHANGE: - return uvc_ctrl_status_event(urb, chain, ctrl, status->bValue); + return uvc_ctrl_status_event_async(urb, chain, ctrl, + status->bValue); case UVC_CTRL_INFO_CHANGE: case UVC_CTRL_FAILURE_CHANGE: diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index c50b0546901f..be784ed8354d 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -843,7 +843,9 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, int uvc_ctrl_init_device(struct uvc_device *dev); void uvc_ctrl_cleanup_device(struct uvc_device *dev); int uvc_ctrl_restore_values(struct uvc_device *dev); -bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain, +bool uvc_ctrl_status_event_async(struct urb *urb, struct uvc_video_chain *chain, + struct uvc_control *ctrl, const u8 *data); +void uvc_ctrl_status_event(struct uvc_video_chain *chain, struct uvc_control *ctrl, const u8 *data); int uvc_ctrl_begin(struct uvc_video_chain *chain); -- 2.29.2.729.g45daf8777d-goog