From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761993AbdAINf7 (ORCPT ); Mon, 9 Jan 2017 08:35:59 -0500 Received: from smtprelay0108.hostedemail.com ([216.40.44.108]:56095 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755220AbdAINeW (ORCPT ); Mon, 9 Jan 2017 08:34:22 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2691:2692:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3872:3873:4250:4321:5007:6120:7576:7903:10004:10400:10848:11232:11658:11914:12438:12555:12740:12760:12895:12986:13069:13161:13229:13311:13357:13439:14096:14097:14659:14721:14819:21080:21324:21326:21433:21434:21451:30012:30054:30055:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: owl20_7320a11d1b44e X-Filterd-Recvd-Size: 2350 Message-ID: <1483968790.2106.10.camel@perches.com> Subject: Re: [RFC PATCH] intel: Use upper_32_bits and lower_32_bits From: Joe Perches To: David Laight , Jeff Kirsher Cc: Julia Lawall , "intel-wired-lan@lists.osuosl.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Date: Mon, 09 Jan 2017 05:33:10 -0800 In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DB025AC14@AcuExch.aculab.com> References: <7a5cfe63cad3ef4badc30cbc2185a5bfb9250fd8.1483813334.git.joe@perches.com> <063D6719AE5E284EB5DD2968C1650D6DB025AC14@AcuExch.aculab.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.3-0ubuntu0.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2017-01-09 at 12:55 +0000, David Laight wrote: > From: Joe Perches > > Sent: 07 January 2017 18:33 > > Shifting and masking various types can be made a bit > > simpler to read by using the available kernel macros. > > ... > > - ew32(TDBAH, (tdba >> 32)); > > - ew32(TDBAL, (tdba & 0x00000000ffffffffULL)); > > + ew32(TDBAH, upper_32_bits(tdba)); > > + ew32(TDBAL, lower_32_bits(tdba)); > > Personally I find the original code easier to understand > since I don't have to look up another silly macro. It's already a pretty common usage and I believe the naming is fairly obvious. Also you don't have to count the "f" characters to see how many bits are being used. After about 6 consecutive chars, it can be error prone. The leading zeros? ugh. The ULL too. $ git grep -w -E "upper_32_bits|lower_32_bits" | wc -l 1569 > I'd normally not even explicitly mask the low bits > relying on the implicit truncation of the assignment. Relying on implicit behaviors can be noisy when compilers complain about implicit conversions and truncations. > At least modern compilers aren't stupid enough to add two > 'mask with 0xff' instructions for: > *uchar_ptr = (unsigned char)(foo & 0xff); I agree it's visual noise.