From patchwork Sat Sep 24 21:57:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 9349315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 15F63601C2 for ; Sat, 24 Sep 2016 21:57:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F39D829007 for ; Sat, 24 Sep 2016 21:57:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E66DC29015; Sat, 24 Sep 2016 21:57:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E79529007 for ; Sat, 24 Sep 2016 21:57:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965111AbcIXV5j (ORCPT ); Sat, 24 Sep 2016 17:57:39 -0400 Received: from smtp01.smtpout.orange.fr ([80.12.242.123]:37570 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965022AbcIXV5i (ORCPT ); Sat, 24 Sep 2016 17:57:38 -0400 Received: from localhost.localdomain ([92.140.231.207]) by mwinf5d01 with ME id nZxY1t0084V8R7g03ZxY16; Sat, 24 Sep 2016 23:57:36 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 24 Sep 2016 23:57:36 +0200 X-ME-IP: 92.140.231.207 From: Christophe JAILLET To: boris.brezillon@free-electrons.com, mturquette@baylibre.com, sboyd@codeaurora.org Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] clk: at91: Fix a return value in case of error Date: Sat, 24 Sep 2016 23:57:26 +0200 Message-Id: <1474754246-27226-1-git-send-email-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.7.4 X-Antivirus: avast! (VPS 160924-1, 24/09/2016), Outbound message X-Antivirus-Status: Clean Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If 'clk_hw_register()' fails, it is likely that we expect to return an error instead of a valid pointer (which would mean success). 'clk_hw_register()' returns a bool, so we don't have the detail of the error. Return -ENOMEM instead, as it seems to be the most common error returned by clk_register(). Fix commit f5644f10dcfb ("clk: at91: Migrate to clk_hw based registration and OF APIs") Signed-off-by: Christophe JAILLET --- It is likely that a bigger change is needed. For example using clk_register instead of clk_hw_register would return the error instead of a bool. We could then propagate this error to the caller without the need to choose an arbitrary error value. This proposal is un-compiled and un-tested. I get an error when I run 'make drivers/clk/at91/' which is likely due to my building environment. --- drivers/clk/at91/clk-programmable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c index 190122e64a3a..2cf200e22d48 100644 --- a/drivers/clk/at91/clk-programmable.c +++ b/drivers/clk/at91/clk-programmable.c @@ -203,7 +203,7 @@ at91_clk_register_programmable(struct regmap *regmap, ret = clk_hw_register(NULL, &prog->hw); if (ret) { kfree(prog); - hw = &prog->hw; + hw = ERR_PTR(-ENOMEM); } return hw;