Re: [PATCH] staging: most: usb: Remove variable frame_size
From: Christian.Gromm
Date: Fri May 24 2019 - 04:28:08 EST
On Do, 2019-05-23 at 18:51 +0200, Greg KH wrote:
> External E-Mail
>
>
> On Thu, May 23, 2019 at 06:53:34PM +0530, Nishka Dasgupta wrote:
> >
> > Remove variable frame_size as its multiple usages are all
> > independent of
> > each other and so can be returned separately.
> > Issue found with Coccinelle.
> >
> > Signed-off-by: Nishka Dasgupta <nishkadg.linux@xxxxxxxxx>
> > ---
> > Âdrivers/staging/most/usb/usb.c | 16 ++++++----------
> > Â1 file changed, 6 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/staging/most/usb/usb.c
> > b/drivers/staging/most/usb/usb.c
> > index 360cb5b7a10b..751e82cf66c5 100644
> > --- a/drivers/staging/most/usb/usb.c
> > +++ b/drivers/staging/most/usb/usb.c
> > @@ -186,32 +186,28 @@ static inline int start_sync_ep(struct
> > usb_device *usb_dev, u16 ep)
> > Â */
> > Âstatic unsigned int get_stream_frame_size(struct
> > most_channel_config *cfg)
> > Â{
> > - unsigned int frame_size = 0;
> > Â unsigned int sub_size = cfg->subbuffer_size;
> > Â
> > Â if (!sub_size) {
> > Â pr_warn("Misconfig: Subbuffer size zero.\n");
> > - return frame_size;
> > + return 0;
> > Â }
> > Â switch (cfg->data_type) {
> > Â case MOST_CH_ISOC:
> > - frame_size = AV_PACKETS_PER_XACT * sub_size;
> > - break;
> > + return AV_PACKETS_PER_XACT * sub_size;
> > Â case MOST_CH_SYNC:
> > Â if (cfg->packets_per_xact == 0) {
> > Â pr_warn("Misconfig: Packets per XACT
> > zero\n");
> > - frame_size = 0;
> > + return 0;
> > Â } else if (cfg->packets_per_xact == 0xFF) {
> > - frame_size = (USB_MTU / sub_size) *
> > sub_size;
> > + return (USB_MTU / sub_size) * sub_size;
> > Â } else {
> > - frame_size = cfg->packets_per_xact *
> > sub_size;
> > + return cfg->packets_per_xact * sub_size;
> > Â }
> > - break;
> > Â default:
> > Â pr_warn("Query frame size of non-streaming
> > channel\n");
> > - break;
> > + return 0;
> > Â }
> > - return frame_size;
> > Â}
> Now it just feels like you are doing "busy work" :(
>
> frame_size makes sense here, right?ÂÂWhy change this code?
>
> Remember, code is written for developers first, the compiler second.
> Reading this with frame_size makes it much more obvious what this
> code
> does when you read it again in 5-10 years.ÂÂWhy change this, you have
> not made it faster, or smaller at all.
>
> So no, I would not accept this, sorry.
I haven't seen this on time. So please ignore my acknowledge I've sent.
Good to know that you favor readability over compactness.
Sorry for the noise,
Chris
>
> We have so many _real_ things to do in the drivers/staging/ directory
> if
> you are looking for stuff to clean up.ÂÂDon't try to micro-optimize
> things that do not matter at the expense of understanding.
>
> thanks,
>
> greg k-h
>