2016-10-24 20:58:40

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 0/3] [media] au0828-video: Fine-tuning for au0828_init_isoc()

From: Markus Elfring <[email protected]>
Date: Mon, 24 Oct 2016 22:52:10 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Use kcalloc()
Delete three error messages for a failed memory allocation
Move two assignments

drivers/media/usb/au0828/au0828-video.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)

--
2.10.1


2016-10-24 20:59:42

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()

From: Markus Elfring <[email protected]>
Date: Mon, 24 Oct 2016 22:08:47 +0200

* Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kcalloc".

This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
to make the corresponding size determination a bit safer according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/usb/au0828/au0828-video.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 85dd9a8..85b13c1 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,

dev->isoc_ctl.isoc_copy = isoc_copy;
dev->isoc_ctl.num_bufs = num_bufs;
-
- dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
+ dev->isoc_ctl.urb = kcalloc(num_bufs,
+ sizeof(*dev->isoc_ctl.urb),
+ GFP_KERNEL);
if (!dev->isoc_ctl.urb) {
au0828_isocdbg("cannot alloc memory for usb buffers\n");
return -ENOMEM;
}

- dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
- GFP_KERNEL);
+ dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs,
+ sizeof(*dev->isoc_ctl
+ .transfer_buffer),
+ GFP_KERNEL);
if (!dev->isoc_ctl.transfer_buffer) {
au0828_isocdbg("cannot allocate memory for usb transfer\n");
kfree(dev->isoc_ctl.urb);
--
2.10.1

2016-10-24 21:01:02

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 2/3] [media] au0828-video: Delete three error messages for a failed memory allocation

From: Markus Elfring <[email protected]>
Date: Mon, 24 Oct 2016 22:28:03 +0200

Omit extra messages for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/usb/au0828/au0828-video.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index 85b13c1..b5c88a7 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -224,17 +224,14 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
dev->isoc_ctl.urb = kcalloc(num_bufs,
sizeof(*dev->isoc_ctl.urb),
GFP_KERNEL);
- if (!dev->isoc_ctl.urb) {
- au0828_isocdbg("cannot alloc memory for usb buffers\n");
+ if (!dev->isoc_ctl.urb)
return -ENOMEM;
- }

dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs,
sizeof(*dev->isoc_ctl
.transfer_buffer),
GFP_KERNEL);
if (!dev->isoc_ctl.transfer_buffer) {
- au0828_isocdbg("cannot allocate memory for usb transfer\n");
kfree(dev->isoc_ctl.urb);
return -ENOMEM;
}
@@ -256,10 +253,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->usbdev,
sb_size, GFP_KERNEL, &urb->transfer_dma);
if (!dev->isoc_ctl.transfer_buffer[i]) {
- printk("unable to allocate %i bytes for transfer"
- " buffer %i%s\n",
- sb_size, i,
- in_interrupt() ? " while in int" : "");
au0828_uninit_isoc(dev);
return -ENOMEM;
}
--
2.10.1

2016-10-24 21:01:48

by SF Markus Elfring

[permalink] [raw]
Subject: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc()

From: Markus Elfring <[email protected]>
Date: Mon, 24 Oct 2016 22:44:02 +0200

Move the assignment for the data structure members "isoc_copy"
and "num_bufs" behind the source code for memory allocations
by this function.

Signed-off-by: Markus Elfring <[email protected]>
---
drivers/media/usb/au0828/au0828-video.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
index b5c88a7..5ebda64 100644
--- a/drivers/media/usb/au0828/au0828-video.c
+++ b/drivers/media/usb/au0828/au0828-video.c
@@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
int rc;

au0828_isocdbg("au0828: called au0828_prepare_isoc\n");
-
- dev->isoc_ctl.isoc_copy = isoc_copy;
- dev->isoc_ctl.num_bufs = num_bufs;
dev->isoc_ctl.urb = kcalloc(num_bufs,
sizeof(*dev->isoc_ctl.urb),
GFP_KERNEL);
@@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
dev->isoc_ctl.buf = NULL;

sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
+ dev->isoc_ctl.num_bufs = num_bufs;

/* allocate urbs and transfer buffers */
for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
@@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
k += dev->isoc_ctl.max_pkt_size;
}
}
+ dev->isoc_ctl.isoc_copy = isoc_copy;

/* submit urbs and enables IRQ */
for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
--
2.10.1

2016-10-24 22:29:15

by Andrey Utkin

[permalink] [raw]
Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()

On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Mon, 24 Oct 2016 22:08:47 +0200
>
> * Multiplications for the size determination of memory allocations
> indicated that array data structures should be processed.
> Thus use the corresponding function "kcalloc".
>
> This issue was detected by using the Coccinelle software.
>
> * Replace the specification of data types by pointer dereferences
> to make the corresponding size determination a bit safer according to
> the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> drivers/media/usb/au0828/au0828-video.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index 85dd9a8..85b13c1 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
>
> dev->isoc_ctl.isoc_copy = isoc_copy;
> dev->isoc_ctl.num_bufs = num_bufs;
> -

> - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
> + dev->isoc_ctl.urb = kcalloc(num_bufs,
> + sizeof(*dev->isoc_ctl.urb),
> + GFP_KERNEL);

What about this (for both hunks)?

- dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
+ dev->isoc_ctl.urb =
+ kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL);

2016-10-25 00:11:27

by Mauro Carvalho Chehab

[permalink] [raw]
Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()

Em Mon, 24 Oct 2016 23:28:44 +0100
Andrey Utkin <[email protected]> escreveu:

> On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote:
> > From: Markus Elfring <[email protected]>
> > Date: Mon, 24 Oct 2016 22:08:47 +0200
> >
> > * Multiplications for the size determination of memory allocations
> > indicated that array data structures should be processed.
> > Thus use the corresponding function "kcalloc".
> >
> > This issue was detected by using the Coccinelle software.
> >
> > * Replace the specification of data types by pointer dereferences
> > to make the corresponding size determination a bit safer according to
> > the Linux coding style convention.
> >
> > Signed-off-by: Markus Elfring <[email protected]>
> > ---
> > drivers/media/usb/au0828/au0828-video.c | 11 +++++++----
> > 1 file changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> > index 85dd9a8..85b13c1 100644
> > --- a/drivers/media/usb/au0828/au0828-video.c
> > +++ b/drivers/media/usb/au0828/au0828-video.c
> > @@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> >
> > dev->isoc_ctl.isoc_copy = isoc_copy;
> > dev->isoc_ctl.num_bufs = num_bufs;
> > -
>
> > - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
> > + dev->isoc_ctl.urb = kcalloc(num_bufs,
> > + sizeof(*dev->isoc_ctl.urb),
> > + GFP_KERNEL);
>
> What about this (for both hunks)?
>
> - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
> + dev->isoc_ctl.urb =
> + kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL);


That's worse :)

The usual Kernel style is:

var = foo(bar1,
bar2,
bar3);

instead of something like:

var =
foo(bar1,
bar2,
bar3);

The places where it is different than that is because people ran
./scripts/Lindent to try to follow the Kernel coding style.

On my experiences, at the end, using it caused more harm than
good, IMHO, and cause very weird indentation on lines with
more than 80 columns like the above.

Thanks,
Mauro

2016-10-25 05:51:59

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()



On Mon, 24 Oct 2016, Mauro Carvalho Chehab wrote:

> Em Mon, 24 Oct 2016 23:28:44 +0100
> Andrey Utkin <[email protected]> escreveu:
>
> > On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote:
> > > From: Markus Elfring <[email protected]>
> > > Date: Mon, 24 Oct 2016 22:08:47 +0200
> > >
> > > * Multiplications for the size determination of memory allocations
> > > indicated that array data structures should be processed.
> > > Thus use the corresponding function "kcalloc".
> > >
> > > This issue was detected by using the Coccinelle software.
> > >
> > > * Replace the specification of data types by pointer dereferences
> > > to make the corresponding size determination a bit safer according to
> > > the Linux coding style convention.
> > >
> > > Signed-off-by: Markus Elfring <[email protected]>
> > > ---
> > > drivers/media/usb/au0828/au0828-video.c | 11 +++++++----
> > > 1 file changed, 7 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> > > index 85dd9a8..85b13c1 100644
> > > --- a/drivers/media/usb/au0828/au0828-video.c
> > > +++ b/drivers/media/usb/au0828/au0828-video.c
> > > @@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> > >
> > > dev->isoc_ctl.isoc_copy = isoc_copy;
> > > dev->isoc_ctl.num_bufs = num_bufs;
> > > -
> >
> > > - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
> > > + dev->isoc_ctl.urb = kcalloc(num_bufs,
> > > + sizeof(*dev->isoc_ctl.urb),
> > > + GFP_KERNEL);
> >
> > What about this (for both hunks)?
> >
> > - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
> > + dev->isoc_ctl.urb =
> > + kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL);
>
>
> That's worse :)
>
> The usual Kernel style is:
>
> var = foo(bar1,
> bar2,
> bar3);

Isn't it more like

var = foo(bar1, bar2,
bar3)

Otherwise, Markus is going to send millions of patches to put every
function argument on its own line...

julia

>
> instead of something like:
>
> var =
> foo(bar1,
> bar2,
> bar3);
>
> The places where it is different than that is because people ran
> ./scripts/Lindent to try to follow the Kernel coding style.
>
> On my experiences, at the end, using it caused more harm than
> good, IMHO, and cause very weird indentation on lines with
> more than 80 columns like the above.
>
> Thanks,
> Mauro
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2016-10-25 08:41:06

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()

On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote:
> + dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs,
> + sizeof(*dev->isoc_ctl
> + .transfer_buffer),

This is ugly.

regards,
dan carpenter

2016-10-25 09:06:54

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc()

This patch introduces bugs. It's my policy to not explain the Markus's
bugs because otherwise he will just resend the patchset and I have asked
him many times to stop.

I will happily review bug fix patches but I really think he should stop
sending these cleanup patches.

regards,
dan carpenter

2016-10-25 12:46:15

by Andrey Utkin

[permalink] [raw]
Subject: Re: [PATCH 1/3] [media] au0828-video: Use kcalloc() in au0828_init_isoc()

On Mon, Oct 24, 2016 at 10:11:15PM -0200, Mauro Carvalho Chehab wrote:
> Em Mon, 24 Oct 2016 23:28:44 +0100
> Andrey Utkin <[email protected]> escreveu:
>
> > On Mon, Oct 24, 2016 at 10:59:24PM +0200, SF Markus Elfring wrote:
> > > From: Markus Elfring <[email protected]>
> > > Date: Mon, 24 Oct 2016 22:08:47 +0200
> > >
> > > * Multiplications for the size determination of memory allocations
> > > indicated that array data structures should be processed.
> > > Thus use the corresponding function "kcalloc".
> > >
> > > This issue was detected by using the Coccinelle software.
> > >
> > > * Replace the specification of data types by pointer dereferences
> > > to make the corresponding size determination a bit safer according to
> > > the Linux coding style convention.
> > >
> > > Signed-off-by: Markus Elfring <[email protected]>
> > > ---
> > > drivers/media/usb/au0828/au0828-video.c | 11 +++++++----
> > > 1 file changed, 7 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> > > index 85dd9a8..85b13c1 100644
> > > --- a/drivers/media/usb/au0828/au0828-video.c
> > > +++ b/drivers/media/usb/au0828/au0828-video.c
> > > @@ -221,15 +221,18 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> > >
> > > dev->isoc_ctl.isoc_copy = isoc_copy;
> > > dev->isoc_ctl.num_bufs = num_bufs;
> > > -
> >
> > > - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
> > > + dev->isoc_ctl.urb = kcalloc(num_bufs,
> > > + sizeof(*dev->isoc_ctl.urb),
> > > + GFP_KERNEL);
> >
> > What about this (for both hunks)?
> >
> > - dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
> > + dev->isoc_ctl.urb =
> > + kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb), GFP_KERNEL);

Now i see that also this should suit style better than original variant:

dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(*dev->isoc_ctl.urb),
GFP_KERNEL);

That's what vim with github.com/vivien/vim-linux-coding-style plugin
proposes.

> That's worse :)

I was about to send long emotional noobish bikeshedding rant arguing
with this point, but restrained from that keeping in mind that I want to
proceed contributing to the codebase successfully :) I'll keep my coding
style preferences for myself for a while.

2016-11-03 12:41:08

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc()

On 24/10/16 23:01, SF Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Mon, 24 Oct 2016 22:44:02 +0200
>
> Move the assignment for the data structure members "isoc_copy"
> and "num_bufs" behind the source code for memory allocations
> by this function.

I don't see the point, dropping this patch.

Hans

>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> drivers/media/usb/au0828/au0828-video.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
> index b5c88a7..5ebda64 100644
> --- a/drivers/media/usb/au0828/au0828-video.c
> +++ b/drivers/media/usb/au0828/au0828-video.c
> @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> int rc;
>
> au0828_isocdbg("au0828: called au0828_prepare_isoc\n");
> -
> - dev->isoc_ctl.isoc_copy = isoc_copy;
> - dev->isoc_ctl.num_bufs = num_bufs;
> dev->isoc_ctl.urb = kcalloc(num_bufs,
> sizeof(*dev->isoc_ctl.urb),
> GFP_KERNEL);
> @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> dev->isoc_ctl.buf = NULL;
>
> sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
> + dev->isoc_ctl.num_bufs = num_bufs;
>
> /* allocate urbs and transfer buffers */
> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
> @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
> k += dev->isoc_ctl.max_pkt_size;
> }
> }
> + dev->isoc_ctl.isoc_copy = isoc_copy;
>
> /* submit urbs and enables IRQ */
> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
>

2016-11-03 19:57:11

by SF Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc()

>> From: Markus Elfring <[email protected]>
>> Date: Mon, 24 Oct 2016 22:44:02 +0200
>>
>> Move the assignment for the data structure members "isoc_copy"
>> and "num_bufs" behind the source code for memory allocations
>> by this function.
>
> I don't see the point,

Another explanation try …


> dropping this patch.

I proposed that these assignments should only be performed after the required
memory allocations succeeded. Is this detail worth for further considerations?


>> Signed-off-by: Markus Elfring <[email protected]>
>> ---
>> drivers/media/usb/au0828/au0828-video.c | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
>> index b5c88a7..5ebda64 100644
>> --- a/drivers/media/usb/au0828/au0828-video.c
>> +++ b/drivers/media/usb/au0828/au0828-video.c
>> @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
>> int rc;
>>
>> au0828_isocdbg("au0828: called au0828_prepare_isoc\n");
>> -
>> - dev->isoc_ctl.isoc_copy = isoc_copy;
>> - dev->isoc_ctl.num_bufs = num_bufs;
>> dev->isoc_ctl.urb = kcalloc(num_bufs,
>> sizeof(*dev->isoc_ctl.urb),
>> GFP_KERNEL);
>> @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
>> dev->isoc_ctl.buf = NULL;
>>
>> sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
>> + dev->isoc_ctl.num_bufs = num_bufs;
>>
>> /* allocate urbs and transfer buffers */
>> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
>> @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
>> k += dev->isoc_ctl.max_pkt_size;
>> }
>> }
>> + dev->isoc_ctl.isoc_copy = isoc_copy;
>>
>> /* submit urbs and enables IRQ */
>> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
>>

2016-11-04 08:09:20

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH 3/3] [media] au0828-video: Move two assignments in au0828_init_isoc()

On 03/11/16 20:56, SF Markus Elfring wrote:
>>> From: Markus Elfring <[email protected]>
>>> Date: Mon, 24 Oct 2016 22:44:02 +0200
>>>
>>> Move the assignment for the data structure members "isoc_copy"
>>> and "num_bufs" behind the source code for memory allocations
>>> by this function.
>>
>> I don't see the point,
>
> Another explanation try …
>
>
>> dropping this patch.
>
> I proposed that these assignments should only be performed after the required
> memory allocations succeeded. Is this detail worth for further considerations?

I understand why you think it is better, but I disagree :-) I prefer the
current
approach, that way I know as a reviewer that these fields are correctly
set and
I can forget about them. Not worth spending more time on this.

Regards,

Hans

>
>
>>> Signed-off-by: Markus Elfring <[email protected]>
>>> ---
>>> drivers/media/usb/au0828/au0828-video.c | 5 ++---
>>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c
>>> index b5c88a7..5ebda64 100644
>>> --- a/drivers/media/usb/au0828/au0828-video.c
>>> +++ b/drivers/media/usb/au0828/au0828-video.c
>>> @@ -218,9 +218,6 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
>>> int rc;
>>>
>>> au0828_isocdbg("au0828: called au0828_prepare_isoc\n");
>>> -
>>> - dev->isoc_ctl.isoc_copy = isoc_copy;
>>> - dev->isoc_ctl.num_bufs = num_bufs;
>>> dev->isoc_ctl.urb = kcalloc(num_bufs,
>>> sizeof(*dev->isoc_ctl.urb),
>>> GFP_KERNEL);
>>> @@ -240,6 +237,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
>>> dev->isoc_ctl.buf = NULL;
>>>
>>> sb_size = max_packets * dev->isoc_ctl.max_pkt_size;
>>> + dev->isoc_ctl.num_bufs = num_bufs;
>>>
>>> /* allocate urbs and transfer buffers */
>>> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
>>> @@ -276,6 +274,7 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
>>> k += dev->isoc_ctl.max_pkt_size;
>>> }
>>> }
>>> + dev->isoc_ctl.isoc_copy = isoc_copy;
>>>
>>> /* submit urbs and enables IRQ */
>>> for (i = 0; i < dev->isoc_ctl.num_bufs; i++) {
>>>
>