From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755094AbbI3Vlf (ORCPT ); Wed, 30 Sep 2015 17:41:35 -0400 Received: from lists.s-osg.org ([54.187.51.154]:41083 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754928AbbI3Vlb (ORCPT ); Wed, 30 Sep 2015 17:41:31 -0400 Subject: Re: [PATCH 8/8] mfd: lm3533: Simplify function return logic To: Johan Hovold References: <1443525968-30899-1-git-send-email-javier@osg.samsung.com> <1443525968-30899-9-git-send-email-javier@osg.samsung.com> <20150930210437.GF4284@localhost> From: Javier Martinez Canillas X-Enigmail-Draft-Status: N1110 Cc: linux-kernel@vger.kernel.org, Lee Jones , Samuel Ortiz Message-ID: <560C5706.2030705@osg.samsung.com> Date: Wed, 30 Sep 2015 23:41:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <20150930210437.GF4284@localhost> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Johan, On 09/30/2015 11:04 PM, Johan Hovold wrote: > On Tue, Sep 29, 2015 at 01:26:08PM +0200, Javier Martinez Canillas wrote: >> The invoked functions already return zero on success or a negative >> errno code so there is no need to open code the logic in the caller. >> >> Signed-off-by: Javier Martinez Canillas > > I do not consider this an improvement in any way and suggest this patch > is dropped. > Since I posted the patch I obviously disagree but I don't really mind if the patch is dropped. >> --- >> >> drivers/mfd/lm3533-core.c | 12 ++---------- >> 1 file changed, 2 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/mfd/lm3533-core.c b/drivers/mfd/lm3533-core.c >> index 643f3750e830..193ecee1fa7e 100644 >> --- a/drivers/mfd/lm3533-core.c >> +++ b/drivers/mfd/lm3533-core.c >> @@ -472,11 +472,7 @@ static int lm3533_device_setup(struct lm3533 *lm3533, >> if (ret) >> return ret; >> >> - ret = lm3533_set_boost_ovp(lm3533, pdata->boost_ovp); >> - if (ret) >> - return ret; >> - >> - return 0; >> + return lm3533_set_boost_ovp(lm3533, pdata->boost_ovp); > > You're saving a few lines of code but instead introduce asymmetries and > obscure the fact that the function returns zero on success. > I don't think the change makes the code more obscure tbh, the return foo() construct is very common in the kernel and most functions return 0 on success and a negative errno code on failure. Also, we have a coccinelle semantic patch to find this pattern [0] so if you think that is not worth it, please add a comment to the code. Otherwise another developer could attempt to post the same patch since make coccicheck will always complain about this file. > Johan > [0]: http://lxr.free-electrons.com/source/scripts/coccinelle/misc/simple_return.cocci Best regards, -- Javier Martinez Canillas Open Source Group Samsung Research America