Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp768908ybz; Sat, 25 Apr 2020 03:59:31 -0700 (PDT) X-Google-Smtp-Source: APiQypLlzdCIbnhePbeflVyMDfH+TnmzVJvcj5SHpjm2z/FPTrQ1Uam2LOmZ5zGAQuwLvNTGdtU3 X-Received: by 2002:a17:906:1641:: with SMTP id n1mr11482103ejd.365.1587812370902; Sat, 25 Apr 2020 03:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812370; cv=none; d=google.com; s=arc-20160816; b=OTtLw/MtOFMdmYlQ+PYmqtOuoKwMABwCfVFjHms1oekGTwRArHie5AeONiwj1q+bdN xo/MSYeW3q0XeCzJEhvZjC00CVPhALt7TkbsTc3hv4wCXW6v0bjBRSETym84/y+MPbsh XlJ5H5gqe1/vEqHkte5kMnlWXNcOhG4AcQBYzArUnrjdEUlLgTSk4SO3qLC2rHUYZtW+ /2jzxwJ5IZp2hCxBTjPKrlsp1Ysi1AKu2uPW84o3ygSk9/lfYDwqPysBMbzc+mTPGVAO r0bu8RWrx209dQhYOd1Ueekwr8utOtWOAb2wIywjBztOiKz3uxOK5bAsGthxLj9/gLPV ug9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=zlMBO9Hd74P/IG5jsbxyL18JFrWqwzZaid229A2r+ro=; b=JVcO4fXKrSaBH29Hn09SJaC87cjbXY9fH1CgLcPPNqGi+p5307TDEkmGYiU8q+3IhP nD6Ica86hyE+U3u7epHs7/V3ncm+ikI9YYKL3JulMdbgLG2CGYMwN931FmBZoLukyjgJ SuPsYnAOWEelvymTHsdhPLzh+7FmQxM891kb9S11uQCjyP1NXw4TTz1sb6IJAQh6kyKI 9f6FYd3md/jJ2cLzKj63Qpl/pnY23bCPyvE5ce0ZFrp9kjkRrdreOM9EjINA4MSdxEnW lpiIXe0nmQZlCnCFMIJ8HI8ENi7nPbdiCLHz5Ceg+yFWLVxPvLwxJNq/LmK4lM2OH6lR a3tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RJLWAhjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si5038867ejw.241.2020.04.25.03.59.08; Sat, 25 Apr 2020 03:59:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RJLWAhjp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726088AbgDYK5S (ORCPT + 99 others); Sat, 25 Apr 2020 06:57:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:35924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgDYK5S (ORCPT ); Sat, 25 Apr 2020 06:57:18 -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 26F5620714; Sat, 25 Apr 2020 10:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587812237; bh=ahHvZa0kV6fBVPT9PiZNAdoAVU0at8XiPcIB1IJsIuA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RJLWAhjpyWqkesSXczSZP4wjmmg7mjfrlnfwilcjybZ/lUZunCc3mjSw+FUXRsy2/ zDqLD76OEKs7T1iWq9h+MHzGtb38wNq8OGnmw41NvvdhpocxnagXdWBlSR2z9tbELa s5jL9vxlpvjs6J4u5m41j9GHndKTtY1lkTGroQ/A= Date: Sat, 25 Apr 2020 12:57:14 +0200 From: Greg Kroah-Hartman To: Oscar Carter Cc: Forest Bond , devel@driverdev.osuosl.org, Malcolm Priestley , linux-kernel@vger.kernel.org, Dan Carpenter Subject: Re: [PATCH v2] staging: vt6656: Add formula to the vnt_rf_addpower function Message-ID: <20200425105714.GA2071664@kroah.com> References: <20200423170557.10401-1-oscar.carter@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200423170557.10401-1-oscar.carter@gmx.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 23, 2020 at 07:05:57PM +0200, Oscar Carter wrote: > Use a formula to calculate the return value of the vnt_rf_addpower > function instead of the "if" statement with literal values for every > case. > > Signed-off-by: Oscar Carter > --- > Changelog v1 -> v2 > - Change the type of "base" variable from s32 to int as Dan Carpenter > suggested. > - Remove the "--" postoperator and replace with (base - 1) as Dan > Carpenter suggested. Also, as this expression has a minus before the > parenthesis, remove it an apply the minus operator changing the sign of > "base" and literal "1". > > drivers/staging/vt6656/rf.c | 20 +++----------------- > 1 file changed, 3 insertions(+), 17 deletions(-) > > diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c > index 06fa8867cfa3..612fd4a59f8a 100644 > --- a/drivers/staging/vt6656/rf.c > +++ b/drivers/staging/vt6656/rf.c > @@ -538,28 +538,14 @@ int vnt_rf_write_embedded(struct vnt_private *priv, u32 data) > > static u8 vnt_rf_addpower(struct vnt_private *priv) > { > + int base; > s32 rssi = -priv->current_rssi; > > if (!rssi) > return 7; > > - if (priv->rf_type == RF_VT3226D0) { > - if (rssi < -70) > - return 9; > - else if (rssi < -65) > - return 7; > - else if (rssi < -60) > - return 5; > - } else { > - if (rssi < -80) > - return 9; > - else if (rssi < -75) > - return 7; > - else if (rssi < -70) > - return 5; > - } > - > - return 0; > + base = (priv->rf_type == RF_VT3226D0) ? -60 : -70; > + return (rssi < base) ? ((rssi - base + 1) / -5) * 2 + 5 : 0; I _hate_ ? : functions, just spell this out please as a real if() statement. thanks, greg k-h