From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753767AbdDRQ2t (ORCPT ); Tue, 18 Apr 2017 12:28:49 -0400 Received: from smtprelay0060.hostedemail.com ([216.40.44.60]:40982 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752531AbdDRQ2q (ORCPT ); Tue, 18 Apr 2017 12:28:46 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:541:599:960:966:968:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2196:2199:2200:2393:2553:2559:2562:2828:2898:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3870:3871:3872:4250:4321:4385:5007:6119:9010:10004:10400:10848:11026:11232:11658:11914:12050:12438:12740:12760:12895:13069:13161:13229:13311:13357:13439:14040:14096:14097:14659:14721:21080:21451:30012:30054:30070:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: store87_864ccde904947 X-Filterd-Recvd-Size: 2027 Message-ID: <1492532921.8661.42.camel@perches.com> Subject: Re: [PATCH] regulator/core.c: remove the else statement From: Joe Perches To: Mark Brown , hubiaoyong Cc: lgirdwood@gmail.com, linux-kernel@vger.kernel.org, hby2003@163.com Date: Tue, 18 Apr 2017 09:28:41 -0700 In-Reply-To: <20170418154947.tuom2jg5hwcpzje2@sirena.org.uk> References: <1492529974-4332-1-git-send-email-hubiaoyong@gmail.com> <20170418154947.tuom2jg5hwcpzje2@sirena.org.uk> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 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 Tue, 2017-04-18 at 16:49 +0100, Mark Brown wrote: > On Tue, Apr 18, 2017 at 11:39:34PM +0800, hubiaoyong wrote: > > in the function regulator_ena_gpio_free, the if branch contains > > the return statement, so remove the else statement. > > Why is it a benefit to make this change? In general, reducing source code indentation is a good thing. The logic today is: /* Free the GPIO only in case of no use */ list_for_each_entry_safe(pin, n, ®ulator_ena_gpio_list, list) { if (pin->gpiod == rdev->ena_pin->gpiod) { if (pin->request_count <= 1) { pin->request_count = 0; gpiod_put(pin->gpiod); list_del(&pin->list); kfree(pin); rdev->ena_pin = NULL; return; } else { pin->request_count--; } } } Perhaps it's better written as: /* Free the GPIO only in case of no use */ list_for_each_entry_safe(pin, n, ®ulator_ena_gpio_list, list) { if (pin->gpiod != rdev->ena_pin->gpiod) continue; if (pin->request_count <= 1) { pin->request_count = 0; gpiod_put(pin->gpiod); list_del(&pin->list); kfree(pin); rdev->ena_pin = NULL; return; } pin->request_count--; }