Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2013987ybm; Thu, 23 May 2019 10:00:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyS9J1efF+pKtPqkP1ZYGRO5kOG8adPHWoCyLGp26kRyHrYo5rQwwUGXCX8HHDnkaxw4QSN X-Received: by 2002:a63:fd4a:: with SMTP id m10mr96974606pgj.302.1558630816665; Thu, 23 May 2019 10:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558630816; cv=none; d=google.com; s=arc-20160816; b=c7BZuBITIP0K4HCOY9ZfOxma39UDM22/v8748liSWBREN//pK61ond22KMpt8FjWPl CZGLzjvH+M/aZk+ccgTgHINiSYlp93WqT1sC7gr4kkAr6NXnQTyni6myvutN06yTRwDZ klppGa0crJpgAP2fdrvXoUksEF89i5Nkz98rLd5/syg7TwfbUvX48xGUCONzTsFqcaWU NvkqXF8LXkuMyMMursebqfyqvGWahnaKO3CMkEOWz1ipwwcXkGFcdfTfBIyykEEzclv1 D1lGAv6fRAaBvEDMkE5wCCM5fSYeL8jXR1o0CtGinx2vHzxhUzCVysNepygO4Zzfi5wj Qsig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hBCLlSWd1c+9wmOUBm7ebL/KZfTU1HUwEh7zFlSozrQ=; b=RHTTD/48n76lz4lhtl4W+NSg94nxBe9atQzqXlbWxf+8z182D/FvR3fUDSZsjgbgfn JR+c+lvoOzFjz9cpUZG+4evX93Gqc5JR4z97xzXJiLloPaCBAd6mw46ufPzrh2HjUivN FbeiX95Dytpg96Dva4DzSNj5Bs95wCkYy2ir5Ybrsqn2uNuTLfmjM7ff6yUbPmhVceGq Ji1xr2tuRxKOaINRnsTGl5iLY5wty6Daou+c4V2BDFVs4ODeNTXgkA1SoxuZO8LrRuwU tRz5dt4CUeuRUScO7DBoJmDt/ZGCc59ZYSLN84xZYVCp92ELNvek1Hej18Y0/LO6qqaG hfvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yaCvTrdu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si6874pge.264.2019.05.23.10.00.01; Thu, 23 May 2019 10:00:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yaCvTrdu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731353AbfEWQ5X (ORCPT + 99 others); Thu, 23 May 2019 12:57:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37756 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731299AbfEWQ5W (ORCPT ); Thu, 23 May 2019 12:57:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF3E62070D; Thu, 23 May 2019 16:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558630320; bh=TCw7cKoRb0mNvs2XUEnU4+3yGCOFVTVy1RJc0z1Ogw0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yaCvTrdue+ruF5/+/4uQDCzrgFwtbSrks+PtpQpAJ8fQNoyl0AZFXYR41m8P0b6AZ RWHVm1Q2EQImnFPXFOU+0KUkHzWCf4dmAQNDWr/n6M1YR0tltL3ICmW0M02M3o0A6A GU5rSksqUXUmyhJn9xel9Ex9paNHOFXzYT6bmb2A= Date: Thu, 23 May 2019 18:51:57 +0200 From: Greg KH To: Nishka Dasgupta Cc: christian.gromm@microchip.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: most: usb: Remove variable frame_size Message-ID: <20190523165157.GA19908@kroah.com> References: <20190523132334.29611-1-nishkadg.linux@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190523132334.29611-1-nishkadg.linux@gmail.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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. 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