Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1092567imm; Wed, 20 Jun 2018 11:26:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIxfNKpQZEvcvMr+EKSO+9l0i6TuuLZOMPJ1iNTKsnSUn69/22U+jYvnKQfHOU49KPWMtE6 X-Received: by 2002:aa7:8004:: with SMTP id j4-v6mr23846430pfi.174.1529519165520; Wed, 20 Jun 2018 11:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529519165; cv=none; d=google.com; s=arc-20160816; b=wI7nU8TBFtjChuax/utoCE6zJv2VOsmy8CztCVSxSyR+/d2chXLwM+ZWjN1Ftw4wf1 S/dUMFKbYsRdVhfy2feNo/p9F4HlvnDElry6EgJJZl5dvD3dFYaHGFGpqA0qiyN9B6+p E0+Gq7OUExuQD/G+eVKgKX9kwHDvEzE0h1B/Wdqy+WOplLKz582Tu4G9zbCDboW0wS5Z Zoqr1jzW1YACZ+bpLaUv08X/LlZPitX5lRzk8Qe3+XEZGa1ZC1f84z6yr7knTCsVPgBm CGRKYxi69ArUsCN/RQ8Vx6PFp0hxRB16pp6D9nNPbLt+/GkHv83lKEdSbj4K88RLcuqQ Eqqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=XLij7QsA+xEq64G3IGFj+w6IywwBh/dToc+b/y91tdc=; b=IMCkzXyp00sVT559rYjvWSmvXAgI7olq8DmuQUHwuaa5um5mlNX6TU7p57KOIgnv5a MvGSOCju1vJmYO1qKU9W5HOJDr6M9tTFxNW0Z20fzOnYxJcWohKCQnMNuF+pYkL0W0r2 Lf5g5GPzlnmkbllUW3QfY5+3dOAshweXtMLy+SSlwZxfdmm3oBMq16yLWyQTdBPWmMjj zbYYhEVJ73ZNS4rbjvhg5TuO06pv87mqkRvhbTHdX0Ackd9HDqSwZvKlkViDZ1hsDlHj A3f6PjaU7rtnERHKie6UsrvWkjb0d2wV07g9TFCMkgStqDgjuePTDiVexZiIQLJ/0uAE /wSQ== ARC-Authentication-Results: i=1; mx.google.com; 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 f67-v6si2890286plb.460.2018.06.20.11.25.51; Wed, 20 Jun 2018 11:26:05 -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; 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 S1754455AbeFTSZQ (ORCPT + 99 others); Wed, 20 Jun 2018 14:25:16 -0400 Received: from smtprelay0008.hostedemail.com ([216.40.44.8]:60020 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751767AbeFTSZN (ORCPT ); Wed, 20 Jun 2018 14:25:13 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id DDAAD182CED34; Wed, 20 Jun 2018 18:25:12 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:973:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2693:2828:2904:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3874:4250:4321:5007:6117:6119:6120:6742:7901:8957:9010:10004:10400:10848:11026:11232:11473:11657:11658:11914:12043:12048:12295:12296:12438:12679:12740:12760:12895:13161:13229:13439:14096:14097:14659:14721:21080:21324:21451:21627:30046:30051:30054:30055:30060:30070:30083:30091,0,RBL:47.151.150.235:@perches.com:.lbl8.mailshell.net-62.8.0.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:28,LUA_SUMMARY:none X-HE-Tag: wrist12_1008fc6f71b63 X-Filterd-Recvd-Size: 3674 Received: from XPS-9350.home (unknown [47.151.150.235]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Wed, 20 Jun 2018 18:25:10 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 2/2] hwmon: npcm750: add NPCM7xx PWM and Fan driver From: Joe Perches To: Guenter Roeck , Tomer Maimon , Julia Lawall , cocci Cc: robh+dt@kernel.org, mark.rutland@arm.com, jdelvare@suse.com, avifishman70@gmail.com, yuenn@google.com, brendanhiggins@google.com, venture@google.com, joel@jms.id.au, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, openbmc@lists.ozlabs.org Date: Wed, 20 Jun 2018 11:25:08 -0700 In-Reply-To: <20180620164853.GA3459@roeck-us.net> References: <20180619105352.97181-1-tmaimon77@gmail.com> <20180619105352.97181-3-tmaimon77@gmail.com> <20180620164853.GA3459@roeck-us.net> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (adding Julia Lawall and cocci mailing list) On Wed, 2018-06-20 at 09:48 -0700, Guenter Roeck wrote: [] > > +static inline void npcm7xx_fan_start_capture(struct npcm7xx_pwm_fan_data *data, > > + u8 fan, u8 cmp) > > +{ > > + u8 fan_id = 0; > > + u8 reg_mode = 0; > > + u8 reg_int = 0; > > + unsigned long flags; > > + > > + fan_id = NPCM7XX_FAN_INPUT(fan, cmp); > > + > > + /* to check whether any fan tach is enable */ > > + if (data->npcm7xx_fan[fan_id].FanStFlag != FAN_DISABLE) { > > + /* reset status */ > > + spin_lock_irqsave(&data->npcm7xx_fan_lock[fan], flags); > > + > > + data->npcm7xx_fan[fan_id].FanStFlag = FAN_INIT; > > + reg_int = ioread8(NPCM7XX_FAN_REG_TIEN(data->fan_base, fan)); > > + > > + if (cmp == NPCM7XX_FAN_CMPA) { > > + /* enable interrupt */ > > + iowrite8((u8) (reg_int | (NPCM7XX_FAN_TIEN_TAIEN | > > + NPCM7XX_FAN_TIEN_TEIEN)), > > Is the (u8) typecast really necessary ? Seems unlikely. The cast is not really necessary here as there would be an implicit cast already. Some might complain about loss of type safety and "make W=123" would probably emit something here. But casts to the same type are not necessary. A possible coccinelle script to find casts to the same type is below, but there are some false positives for things like __force and __user casts Also, spatch (1.0.4) seems to have a defect for this when the type is used in operations that change a smaller type to int or unsigned int. i.e.: (offset is u16, but offset * 2 is int) While running the cocci script below: HANDLING: drivers/net/ethernet/intel/igb/e1000_nvm.c diff = diff -u -p a/drivers/net/drivers/net/ethernet/intel/igb/e1000_nvm.c b/drivers/net/ethernet/intel/igb/e1000_nvm.c --- a/drivers/net/ethernet/intel/igb/e1000_nvm.c +++ b/drivers/net/ethernet/intel/igb/e1000_nvm.c @@ -335,7 +335,7 @@ s32 igb_read_nvm_spi(struct e1000_hw *hw /* Send the READ command (opcode + addr) */ igb_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits); - igb_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits); + igb_shift_out_eec_bits(hw, (offset * 2), nvm->address_bits); /* Read the data. SPI NVMs increment the address with each byte * read and will roll over if reading beyond the end. This allows --- Anyway, here's the cocci script: $ cat same_typecast.cocci @@ type T; T foo; @@ - (T *)&foo + &foo @@ type T; T foo; @@ - (T)foo + foo