From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932580AbbLNN1r (ORCPT ); Mon, 14 Dec 2015 08:27:47 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:32979 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932419AbbLNN1p (ORCPT ); Mon, 14 Dec 2015 08:27:45 -0500 Subject: Re: [PATCH 11/19] clocksource: fix __ftm_clk_init result To: Andrzej Hajda , linux-kernel@vger.kernel.org References: <1443103227-25612-1-git-send-email-a.hajda@samsung.com> <1443103227-25612-12-git-send-email-a.hajda@samsung.com> <566E9B27.9010804@samsung.com> Cc: Bartlomiej Zolnierkiewicz , Marek Szyprowski , Thomas Gleixner From: Daniel Lezcano Message-ID: <566EC3D3.7030404@linaro.org> Date: Mon, 14 Dec 2015 14:27:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <566E9B27.9010804@samsung.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/14/2015 11:34 AM, Andrzej Hajda wrote: > Hi, > > Ping. [ ... ] Please as you fix this, also fix the caller. freq = __ftm_clk_init(np, "ftm-evt-counter-en", "ftm-evt"); -if (freq <= 0) +if (!freq) and, by the way, isn't there an issue if in the DT "ftm-src" is declared before "ftm-evt" ? > On 09/24/2015 04:00 PM, Andrzej Hajda wrote: >> The function tries to return clock frequency (unsigned long) or error >> (int < 0). Using int as a result could be dangerous. On the other side >> caller is not interested in error value, so the best solution is to >> return frequency or zero in case of error, for this unsigned long is OK. >> >> The problem has been detected using proposed semantic patch >> scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. >> >> [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 >> >> Signed-off-by: Andrzej Hajda >> --- >> Hi, >> >> To avoid problems with too many mail recipients I have sent whole >> patchset only to LKML. Anyway patches have no dependencies. >> >> Regards >> Andrzej >> --- >> drivers/clocksource/fsl_ftm_timer.c | 8 ++++---- >> 1 file changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/clocksource/fsl_ftm_timer.c b/drivers/clocksource/fsl_ftm_timer.c >> index ef43469..11a7ae7 100644 >> --- a/drivers/clocksource/fsl_ftm_timer.c >> +++ b/drivers/clocksource/fsl_ftm_timer.c >> @@ -248,7 +248,7 @@ static int __init ftm_clocksource_init(unsigned long freq) >> return 0; >> } >> >> -static int __init __ftm_clk_init(struct device_node *np, char *cnt_name, >> +static unsigned long __init __ftm_clk_init(struct device_node *np, char *cnt_name, >> char *ftm_name) >> { >> struct clk *clk; >> @@ -257,19 +257,19 @@ static int __init __ftm_clk_init(struct device_node *np, char *cnt_name, >> clk = of_clk_get_by_name(np, cnt_name); >> if (IS_ERR(clk)) { >> pr_err("ftm: Cannot get \"%s\": %ld\n", cnt_name, PTR_ERR(clk)); >> - return PTR_ERR(clk); >> + return 0; >> } >> err = clk_prepare_enable(clk); >> if (err) { >> pr_err("ftm: clock failed to prepare+enable \"%s\": %d\n", >> cnt_name, err); >> - return err; >> + return 0; >> } >> >> clk = of_clk_get_by_name(np, ftm_name); >> if (IS_ERR(clk)) { >> pr_err("ftm: Cannot get \"%s\": %ld\n", ftm_name, PTR_ERR(clk)); >> - return PTR_ERR(clk); >> + return 0; >> } >> err = clk_prepare_enable(clk); >> if (err) > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog