Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4511203ybb; Tue, 14 Apr 2020 08:41:14 -0700 (PDT) X-Google-Smtp-Source: APiQypKUB3x6ylj/D9j5qhlegS/0FjIcgogUSU7qtTV81664pJ9OlmQSr/3489r4k8a90DNMy4JD X-Received: by 2002:a50:d942:: with SMTP id u2mr21207150edj.116.1586878874082; Tue, 14 Apr 2020 08:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586878874; cv=none; d=google.com; s=arc-20160816; b=Emlkhh+k8nTXPJZNgpYSOV77sVDslqfMN5YtNB6YO9WHezFBUV67ZLP4wcJfCMCB+m OKEuuNJOPnzFHbuxaXil/UuR5zI0VTNklOS2bRRFdNp43XeHUWOkhFkyJzCZBy1Dxj0A OiFML0XdLwwTuf6jimqIyP0o4dgf/iQTzh0gigIfcNLYDqbzL1YYCnOnTanQu7pnZM2P 2Sscy5qc4wyx09ALeGRYjkNWzz29DUew78Jy3PFrPYIkhkOltVIUTfqBkBtqWiAWPqYz VPamPrtTzDbDsEq7dPcRRpG9AaeLjIIG9qvKahuoQroNsOFAgOJvwV22nnFhesE4VCOd CsLA== 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=e7ZC9eF80V3HjAabjgEI+dUq9TU4s7TJqhKZXh3sEoM=; b=1DHS3mbGplF05KGHQlnMArk9gsxlElHAwkujCg/CG0ta1bHzlPHfBCeyu/X5tBnDuB CFIZFUG8eduHSuQ59wt0hQlLaEQUQfOBXyAhCFybe3qNGp4Tw+BZ6/Je1AqbrEJqa2w4 3vB1Kkz6uDIywXaFBVQ31ho1O6B1vp2pfghwvMnmRUqd000QxG0A4v2Zm5EhdjcyZgFL egiAZ23+F0MEsO1YOf9YZZzau6Y4KVrnYVMGf8s/Y/w6ZppP3JDhdZkghSPt7bX1rikk 7y5yoPGuwkOswaDkMfcjDwhDHUI8BCMYIs+Qh4kOkG//AgR7Gm0quy/vh6RGW10X6aRs N/vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b="MIWAs/yQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si2002846ejx.280.2020.04.14.08.40.51; Tue, 14 Apr 2020 08:41:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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=@oracle.com header.s=corp-2020-01-29 header.b="MIWAs/yQ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502610AbgDNNMg (ORCPT + 99 others); Tue, 14 Apr 2020 09:12:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45110 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728853AbgDNNMb (ORCPT ); Tue, 14 Apr 2020 09:12:31 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03ED9Xal011159; Tue, 14 Apr 2020 13:12:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=e7ZC9eF80V3HjAabjgEI+dUq9TU4s7TJqhKZXh3sEoM=; b=MIWAs/yQSRGjq+QFCOzkTAoi+OY1McNWJPC2BkXuO9D+U4aFugujrFVVm+1qHpsHfgrB ZS6ekk3X06ZYjCpeIpaFCPYfiJkcP47RJSoO/shrFFBHbnC2ek9F2ZxK1S0k5eDnXYfx MTE97611O8W9Ie79lO9cXZxskvrBEyCz0qlpMeNsQoDbRONeeSSrx/LSNDU0I0v1mVGg ptWTwjjIPOxjcuZCsVSKf5VlQOnndGexYFpWn/9EA4SDWBk6aQcUejTrvr1c4Dm2ptLB hf1o4GTq/QOLUN1EDEHrAszhyhBZnDoLGOrL8hdyB+nuF0LxZa0lhcFCn6RoHsSGSBtS CA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 30b6hpmgu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 13:12:23 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03ED7FlX017508; Tue, 14 Apr 2020 13:12:22 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 30ctaa58tx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 13:12:22 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03EDCLUl011000; Tue, 14 Apr 2020 13:12:21 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 14 Apr 2020 06:12:20 -0700 Date: Tue, 14 Apr 2020 16:12:14 +0300 From: Dan Carpenter To: Oscar Carter Cc: Forest Bond , Greg Kroah-Hartman , Malcolm Priestley , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] staging: vt6656: Add formula to the vnt_rf_addpower function Message-ID: <20200414131214.GI1163@kadam> References: <20200413140209.4520-1-oscar.carter@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200413140209.4520-1-oscar.carter@gmx.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 phishscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140108 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9590 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 mlxlogscore=999 clxscore=1015 mlxscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140108 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 13, 2020 at 04:02:09PM +0200, Oscar Carter wrote: > diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c > index 4f9aba0f21b0..3b200d7290a5 100644 > --- a/drivers/staging/vt6656/rf.c > +++ b/drivers/staging/vt6656/rf.c > @@ -575,28 +575,14 @@ int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel) > > static u8 vnt_rf_addpower(struct vnt_private *priv) > { > + s32 base; Just use "int". s32 is for when signed 32 bit is specified in the hardware. I realize that it's done in this file, but if all your friends jumped off a bridge doesn't mean you should drink their kool-aid. > 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) / -5) * 2 + 5 : 0; ^^^^^^ I quite hate this postop. It would have been cleaner to write it like: return (rssi < base) ? ((rssi - (base - 1)) / -5) * 2 + 5 : 0 I'm sorry, I'm not clever enough to figure out the potential values of "rssi". How did you work out this formula? It feels like it came from a standard or something? Do we not have a function already which implements the standard? regards, dan carpenter