From patchwork Tue Jul 28 11:22:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11688959 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E4C26C1 for ; Tue, 28 Jul 2020 11:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB5442075D for ; Tue, 28 Jul 2020 11:22:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZVuADUQ9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729020AbgG1LWW (ORCPT ); Tue, 28 Jul 2020 07:22:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42039 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728985AbgG1LWV (ORCPT ); Tue, 28 Jul 2020 07:22:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595935340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=OM8kQeBlgXTVmT6/iyptsReY/9gmQ0oUbCzvizJ2goY=; b=ZVuADUQ9rQFUk1zaJ1onDIDNU/wXkhWX8xOS5MAV4dqx98uEdbTP8oaJZ0AVxJ5EginjHm LcLZrw2nh3vysrJUOzkVboJS9VRKkJ0V8OInNAsuwzj8rLaqhzGSyZE68fV3HOOWxiopJ6 6Rdi4RT7Er5k28kX+3SKFeuAo+jeYo8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-331-e2hbXsfsMSaatcGi02Zpjg-1; Tue, 28 Jul 2020 07:22:16 -0400 X-MC-Unique: e2hbXsfsMSaatcGi02Zpjg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3702D801A03; Tue, 28 Jul 2020 11:22:15 +0000 (UTC) Received: from x1.localdomain.com (ovpn-114-116.ams2.redhat.com [10.36.114.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 24F2E7BD60; Tue, 28 Jul 2020 11:22:10 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Hans de Goede , linux-media@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Date: Tue, 28 Jul 2020 13:22:08 +0200 Message-Id: <20200728112209.26207-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org uvc_ctrl_add_info() calls uvc_ctrl_get_flags() which will override the fixed-up flags set by uvc_ctrl_fixup_xu_info(). uvc_ctrl_init_xu_ctrl() already calls uvc_ctrl_get_flags() before calling uvc_ctrl_add_info(), so the uvc_ctrl_get_flags() call in uvc_ctrl_add_info() is not necessary for xu ctrls. This commit moves the uvc_ctrl_get_flags() call for normal controls from uvc_ctrl_add_info() to uvc_ctrl_init_ctrl(), so that we no longer call uvc_ctrl_get_flags() twice for xu controls and so that we no longer override the fixed-up flags set by uvc_ctrl_fixup_xu_info(). This fixes the xu motor controls not working properly on a Logitech 046d:08cc, and presumably also on the other Logitech models which have a quirk for this in the uvc_ctrl_fixup_xu_info() function. Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede Reviewed-by: Laurent Pinchart --- Changes in v2: - Move the uvc_ctrl_get_flags() call for normal controls to uvc_ctrl_init_ctrl() --- drivers/media/usb/uvc/uvc_ctrl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index e399b9fad757..b78aba991212 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2024,13 +2024,6 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, goto done; } - /* - * Retrieve control flags from the device. Ignore errors and work with - * default flag values from the uvc_ctrl array when the device doesn't - * properly implement GET_INFO on standard controls. - */ - uvc_ctrl_get_flags(dev, ctrl, &ctrl->info); - ctrl->initialized = 1; uvc_trace(UVC_TRACE_CONTROL, "Added control %pUl/%u to device %s " @@ -2253,6 +2246,13 @@ static void uvc_ctrl_init_ctrl(struct uvc_device *dev, struct uvc_control *ctrl) if (uvc_entity_match_guid(ctrl->entity, info->entity) && ctrl->index == info->index) { uvc_ctrl_add_info(dev, ctrl, info); + /* + * Retrieve control flags from the device. Ignore errors + * and work with default flag values from the uvc_ctrl + * array when the device doesn't properly implement + * GET_INFO on standard controls. + */ + uvc_ctrl_get_flags(dev, ctrl, &ctrl->info); break; } } From patchwork Tue Jul 28 11:22:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 11688957 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCEB9138C for ; Tue, 28 Jul 2020 11:22:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B44A62064B for ; Tue, 28 Jul 2020 11:22:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OvPeO7ld" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729016AbgG1LWV (ORCPT ); Tue, 28 Jul 2020 07:22:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:48706 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728988AbgG1LWV (ORCPT ); Tue, 28 Jul 2020 07:22:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595935339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QcKwcnIHe1V5eFZ1SVGNcadWZV+wUuaqXZ3S8T0mtXs=; b=OvPeO7ldZOuSTpAPAl01Vpps49XMwg5k0wvPWAieT6+GfTJbb8P/aI6wX3jRAyKy1m17Uf KImXWDYfGH2LV5fiMg9xE1f4D0I2MlMHJVzFD7klSWhim84kGmvGYv1bg8FkQ9JKpfqMtd jVMli14s7NnxdYHyw/AURX7H4iloZKE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-390-tT4Kzh5uP8ixZ6FSmKxsdw-1; Tue, 28 Jul 2020 07:22:17 -0400 X-MC-Unique: tT4Kzh5uP8ixZ6FSmKxsdw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DEFDE8015F7; Tue, 28 Jul 2020 11:22:16 +0000 (UTC) Received: from x1.localdomain.com (ovpn-114-116.ams2.redhat.com [10.36.114.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80E8D7BD60; Tue, 28 Jul 2020 11:22:15 +0000 (UTC) From: Hans de Goede To: Laurent Pinchart , Mauro Carvalho Chehab Cc: Hans de Goede , linux-media@vger.kernel.org Subject: [PATCH v2 2/2] media: uvcvideo: Cleanup uvc_ctrl_add_info() error handling Date: Tue, 28 Jul 2020 13:22:09 +0200 Message-Id: <20200728112209.26207-2-hdegoede@redhat.com> In-Reply-To: <20200728112209.26207-1-hdegoede@redhat.com> References: <20200728112209.26207-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is only 1 error exit in uvc_ctrl_add_info(), so using goto style error handling is not necessary. Also the kfree(ctrl->uvc_data) on error is not necessary, because the only error exit is for the kzalloc() of ctrl->uvc_data failing. Remove all the error handling cruft and simply do "return -ENOMEM" on kzalloc() failure. Signed-off-by: Hans de Goede Reviewed-by: Laurent Pinchart --- Changes in v2: - new patch in v2 of this series --- drivers/media/usb/uvc/uvc_ctrl.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index b78aba991212..dbebc6083e85 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -2011,18 +2011,14 @@ int uvc_ctrl_restore_values(struct uvc_device *dev) static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, const struct uvc_control_info *info) { - int ret = 0; - ctrl->info = *info; INIT_LIST_HEAD(&ctrl->info.mappings); /* Allocate an array to save control values (cur, def, max, etc.) */ ctrl->uvc_data = kzalloc(ctrl->info.size * UVC_CTRL_DATA_LAST + 1, GFP_KERNEL); - if (ctrl->uvc_data == NULL) { - ret = -ENOMEM; - goto done; - } + if (!ctrl->uvc_data) + return -ENOMEM; ctrl->initialized = 1; @@ -2030,10 +2026,7 @@ static int uvc_ctrl_add_info(struct uvc_device *dev, struct uvc_control *ctrl, "entity %u\n", ctrl->info.entity, ctrl->info.selector, dev->udev->devpath, ctrl->entity->id); -done: - if (ret < 0) - kfree(ctrl->uvc_data); - return ret; + return 0; } /*