From patchwork Thu Aug 22 07:17:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 2848080 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 35B539F271 for ; Thu, 22 Aug 2013 07:18:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53C2A204D5 for ; Thu, 22 Aug 2013 07:18:26 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3254C204D2 for ; Thu, 22 Aug 2013 07:18:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VCP9y-0002SI-Le; Thu, 22 Aug 2013 07:18:22 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VCP9w-0007FJ-CU; Thu, 22 Aug 2013 07:18:20 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VCP9t-0007ES-Oe for linux-arm-kernel@lists.infradead.org; Thu, 22 Aug 2013 07:18:18 +0000 Received: by mail-pa0-f41.google.com with SMTP id bj1so1829691pad.0 for ; Thu, 22 Aug 2013 00:17:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RTm5MApzqrjovC+4fG/E0c8PFOZibA7R/E3011TGMTw=; b=CeFPU12LYAjjo5botJaP+X0vqhNEXF4oWWqdYP4mIabx5Bx1Vewl08cZoVqrmHdmyj myH0ygw1LZ17N5BL/1MD08kD/EfbxGmeMch251SJJdg5VGyDvvthnoWmUXWJsAE5S7HO Ai+mjUqUlDPzIHqJf3y+sR1qXLexwrV0/Fu9/3l2R8LgCdIYONx+Yvt332QHlnmRPqXR Kc+GylZkshA+0vTUSDhlOUK1MNQStvuqVedKzj6kC3fNZT6Zh/ztetzXCEbrpL1+bGlH +zmskk2IQrRML3h8ynjSFrIXMPsIBsDWy2dHnDfy/lIj8w4nGUY7yDO7WGm3Lt0ONApL rQ1g== X-Gm-Message-State: ALoCoQmlMAfOfT5ei+nNzFFSRP05XBfYW2n4KH3hB/uL+IxrjBKxKmrMxkJ2MOuDyBCfPpBf8f73 X-Received: by 10.66.161.138 with SMTP id xs10mr13786210pab.56.1377155874647; Thu, 22 Aug 2013 00:17:54 -0700 (PDT) Received: from localhost.localdomain (c-174-62-77-112.hsd1.ca.comcast.net. [174.62.77.112]) by mx.google.com with ESMTPSA id ht5sm12971147pbb.29.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 22 Aug 2013 00:17:53 -0700 (PDT) From: Mike Turquette To: linux-kernel@vger.kernel.org Subject: [PATCH] clk: handle NULL struct clk gracefully Date: Thu, 22 Aug 2013 00:17:47 -0700 Message-Id: <1377155867-15552-1-git-send-email-mturquette@linaro.org> X-Mailer: git-send-email 1.8.1.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130822_031817_865585_ED0DEECF X-CRM114-Status: GOOD ( 11.25 ) X-Spam-Score: -2.6 (--) Cc: Mike Turquette , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At some point changes to clk_set_rate and clk_set_parent introduced a bug whereby NULL struct clk pointers were treated as an error. This is in violation of the API in include/linux/clk.h. Reintroduce graceful handling of NULL clk's by bailing from clk_set_rate and clk_set_parent with return codes of zero. Signed-off-by: Mike Turquette --- drivers/clk/clk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index bc02037..7c43762 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1428,6 +1428,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate) struct clk *top, *fail_clk; int ret = 0; + if (!clk) + return 0; + /* prevent racing with updates to the clock topology */ clk_prepare_lock(); @@ -1567,7 +1570,10 @@ int clk_set_parent(struct clk *clk, struct clk *parent) u8 p_index = 0; unsigned long p_rate = 0; - if (!clk || !clk->ops) + if (!clk) + return 0; + + if (!clk->ops) return -EINVAL; /* verify ops for for multi-parent clks */