* [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
@ 2020-07-28 11:22 Hans de Goede
2020-07-28 11:22 ` [PATCH v2 2/2] media: uvcvideo: Cleanup uvc_ctrl_add_info() error handling Hans de Goede
2020-07-28 19:58 ` [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Laurent Pinchart
0 siblings, 2 replies; 6+ messages in thread
From: Hans de Goede @ 2020-07-28 11:22 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab
Cc: Hans de Goede, linux-media, stable
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 <hdegoede@redhat.com>
---
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;
}
}
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] media: uvcvideo: Cleanup uvc_ctrl_add_info() error handling
2020-07-28 11:22 [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Hans de Goede
@ 2020-07-28 11:22 ` Hans de Goede
2020-07-28 20:01 ` Laurent Pinchart
2020-07-28 19:58 ` [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Laurent Pinchart
1 sibling, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-07-28 11:22 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab; +Cc: Hans de Goede, linux-media
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 <hdegoede@redhat.com>
---
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;
}
/*
--
2.26.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
2020-07-28 11:22 [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Hans de Goede
2020-07-28 11:22 ` [PATCH v2 2/2] media: uvcvideo: Cleanup uvc_ctrl_add_info() error handling Hans de Goede
@ 2020-07-28 19:58 ` Laurent Pinchart
2020-09-08 9:32 ` Hans de Goede
1 sibling, 1 reply; 6+ messages in thread
From: Laurent Pinchart @ 2020-07-28 19:58 UTC (permalink / raw)
To: Hans de Goede; +Cc: Mauro Carvalho Chehab, linux-media, stable
Hi Hans,
Thank you for the patch.
On Tue, Jul 28, 2020 at 01:22:08PM +0200, Hans de Goede wrote:
> 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 <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> 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;
> }
> }
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] media: uvcvideo: Cleanup uvc_ctrl_add_info() error handling
2020-07-28 11:22 ` [PATCH v2 2/2] media: uvcvideo: Cleanup uvc_ctrl_add_info() error handling Hans de Goede
@ 2020-07-28 20:01 ` Laurent Pinchart
0 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2020-07-28 20:01 UTC (permalink / raw)
To: Hans de Goede; +Cc: Mauro Carvalho Chehab, linux-media
Hi Hans,
Thank you for the patch.
On Tue, Jul 28, 2020 at 01:22:09PM +0200, Hans de Goede wrote:
> 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 <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> 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;
> }
>
> /*
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
2020-07-28 19:58 ` [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Laurent Pinchart
@ 2020-09-08 9:32 ` Hans de Goede
2020-09-08 19:36 ` Laurent Pinchart
0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-09-08 9:32 UTC (permalink / raw)
To: Laurent Pinchart, Mauro Carvalho Chehab; +Cc: linux-media, stable
Hi,
On 7/28/20 9:58 PM, Laurent Pinchart wrote:
> Hi Hans,
>
> Thank you for the patch.
>
> On Tue, Jul 28, 2020 at 01:22:08PM +0200, Hans de Goede wrote:
>> 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 <hdegoede@redhat.com>
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
The first patch in this series is a bug-fix for a real-world issue,
and I'm still not seeing this in -next, let alone in a fixed branch for Linus.
Can we get these 2 patches merged please?
Regards,
Hans
>
>> ---
>> 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;
>> }
>> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
2020-09-08 9:32 ` Hans de Goede
@ 2020-09-08 19:36 ` Laurent Pinchart
0 siblings, 0 replies; 6+ messages in thread
From: Laurent Pinchart @ 2020-09-08 19:36 UTC (permalink / raw)
To: Hans de Goede; +Cc: Mauro Carvalho Chehab, linux-media, stable
Hi Hans,
On Tue, Sep 08, 2020 at 11:32:58AM +0200, Hans de Goede wrote:
> On 7/28/20 9:58 PM, Laurent Pinchart wrote:
> > On Tue, Jul 28, 2020 at 01:22:08PM +0200, Hans de Goede wrote:
> >> 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 <hdegoede@redhat.com>
> >
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
> The first patch in this series is a bug-fix for a real-world issue,
> and I'm still not seeing this in -next, let alone in a fixed branch for Linus.
>
> Can we get these 2 patches merged please?
I've just sent the pull request for uvcvideo, it should get merged this
week or the next one and will make it for v5.10. I apologize for the
delay.
>
> >> ---
> >> 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;
> >> }
> >> }
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-09-08 19:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 11:22 [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Hans de Goede
2020-07-28 11:22 ` [PATCH v2 2/2] media: uvcvideo: Cleanup uvc_ctrl_add_info() error handling Hans de Goede
2020-07-28 20:01 ` Laurent Pinchart
2020-07-28 19:58 ` [PATCH v2 1/2] media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect Laurent Pinchart
2020-09-08 9:32 ` Hans de Goede
2020-09-08 19:36 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).