linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Andrzej Hajda <a.hajda@samsung.com>, linux-kernel@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 11/19] clocksource: fix __ftm_clk_init result
Date: Mon, 14 Dec 2015 14:27:47 +0100	[thread overview]
Message-ID: <566EC3D3.7030404@linaro.org> (raw)
In-Reply-To: <566E9B27.9010804@samsung.com>

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 <a.hajda@samsung.com>
>> ---
>> 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)
>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2015-12-14 13:27 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24 14:00 [PATCH 00/19] Fixes related to incorrect assignment of signed results function Andrzej Hajda
2015-09-24 14:00 ` [PATCH 01/19] SUNRPC: fix variable type Andrzej Hajda
2015-09-25 20:25   ` J. Bruce Fields
2015-09-24 14:00 ` [PATCH 02/19] spi: davinci: fix handling platform_get_irq result Andrzej Hajda
2015-09-24 14:00 ` [PATCH 03/19] libata: samsung_cf: " Andrzej Hajda
2015-09-24 14:53   ` Tejun Heo
2015-09-25  6:43     ` [PATCH v2 " Andrzej Hajda
2015-09-25 15:50       ` Tejun Heo
2015-09-24 14:00 ` [PATCH 04/19] v4l: omap3isp: " Andrzej Hajda
2015-11-09 20:16   ` Laurent Pinchart
2015-11-10  6:48     ` Andrzej Hajda
2015-11-10  8:53       ` Laurent Pinchart
2015-11-10  9:59         ` Andrzej Hajda
2015-09-24 14:00 ` [PATCH 05/19] media: am437x-vpfe: " Andrzej Hajda
2015-09-24 14:00 ` [PATCH 06/19] staging: media: omap4iss: " Andrzej Hajda
2015-09-24 15:07   ` Dan Carpenter
2015-09-24 14:00 ` [PATCH 07/19] net: hisilicon: " Andrzej Hajda
2015-09-27  5:47   ` David Miller
2015-09-24 14:00 ` [PATCH 08/19] clk: st: fix handling result of of_property_count_strings Andrzej Hajda
2015-10-01 22:23   ` Stephen Boyd
2015-09-24 14:00 ` [PATCH 09/19] dmaengine: xgene-dma: fix handling xgene_dma_get_ring_size result Andrzej Hajda
2015-09-25  2:09   ` Vinod Koul
2015-09-24 14:00 ` [PATCH 10/19] cx231xx: fix handling cx231xx_read_i2c_data result Andrzej Hajda
2015-09-24 14:00 ` [PATCH 11/19] clocksource: fix __ftm_clk_init result Andrzej Hajda
2015-12-14 10:34   ` Andrzej Hajda
2015-12-14 13:27     ` Daniel Lezcano [this message]
2015-09-24 14:00 ` [PATCH 12/19] extcon: rt8973a: fix handling regmap_irq_get_virq result Andrzej Hajda
2015-09-24 23:40   ` Chanwoo Choi
2015-09-24 14:00 ` [PATCH 13/19] extcon: sm5502: " Andrzej Hajda
2015-09-24 23:40   ` Chanwoo Choi
2015-09-24 14:00 ` [PATCH 14/19] sony-laptop: fix handling sony_nc_hotkeys_decode result Andrzej Hajda
2015-10-03 16:39   ` Darren Hart
2015-10-05  7:42     ` Andrzej Hajda
2015-09-24 14:00 ` [PATCH 15/19] KVM: PPC: e500: fix handling local_sid_lookup result Andrzej Hajda
2015-09-24 22:58   ` Scott Wood
2015-10-15  5:30   ` Paul Mackerras
2015-09-24 14:00 ` [PATCH 16/19] r8169: fix handling rtl_readphy result Andrzej Hajda
2015-09-27  5:48   ` David Miller
2015-09-24 14:00 ` [PATCH 17/19] tools: bpf_jit_disasm: make get_last_jit_image return unsigned Andrzej Hajda
2015-09-24 18:53   ` Daniel Borkmann
2015-09-25  6:45     ` [PATCH v2 " Andrzej Hajda
2015-09-29  5:18       ` David Miller
2015-09-24 14:00 ` [PATCH 18/19] mac80211: make ieee80211_new_mesh_header " Andrzej Hajda
2015-09-24 14:09   ` Johannes Berg
2015-09-25  6:42     ` [PATCH v2 " Andrzej Hajda
2015-09-24 14:00 ` [PATCH 19/19] block: nvme-scsi: make nvme_trans_get_blk_desc_len " Andrzej Hajda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=566EC3D3.7030404@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=a.hajda@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).