From patchwork Tue Dec 18 07:54:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 1890781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id CCBD0DF23A for ; Tue, 18 Dec 2012 07:58:24 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tks11-0002PT-1t; Tue, 18 Dec 2012 07:55:03 +0000 Received: from mail-pa0-f47.google.com ([209.85.220.47]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tks0x-0002Oo-Ft for linux-arm-kernel@lists.infradead.org; Tue, 18 Dec 2012 07:55:00 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa10so335153pad.34 for ; Mon, 17 Dec 2012 23:54:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:subject:from:to:cc:date:content-type:x-mailer :content-transfer-encoding:mime-version:x-gm-message-state; bh=0PrTbtLLS/THi6O265qVEgBDgvkOu4NkXaefZVzaLJs=; b=gEwc8Y6KbRZ8YEV8zrVi5SIEgA/Ce5e7OQ5SfEcbikyfnlo9efqy4D2dt1teMMXeMw kTh8gqLVikDv1jekmYr+6+CsWA20MAIw5mw28gPk+Cb6dHvzFkuhlXTzIP+73PSqlSGP xuqrVQ6LlV3styj84ceUdcBXb09VaqdkqV4dFxzb0HvQDtVIhPcP8c0yZ2P5aPBEB7RF I1ZCO94HlFXTcpBj0W8rIt3QcaVKCJz5rQwsoGdk3aBYkZuWlm73kUAPRLPeBrC5UQD8 FWdcZOsCfa6rKMWF0/pUv/baeIkdKKyLF1tEA26IAl5ZjLGvpsrQO9P1xPFwljA06Znf Qd3g== X-Received: by 10.68.190.227 with SMTP id gt3mr4315025pbc.5.1355817297871; Mon, 17 Dec 2012 23:54:57 -0800 (PST) Received: from [192.168.0.101] (218-173-175-100.dynamic.hinet.net. [218.173.175.100]) by mx.google.com with ESMTPS id ni8sm712408pbc.70.2012.12.17.23.54.55 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Dec 2012 23:54:57 -0800 (PST) Message-ID: <1355817292.32595.2.camel@phoenix> Subject: [PATCH] clk: max77686: Remove unnecessary NULL checking for container_of() From: Axel Lin To: Mike Turquette Date: Tue, 18 Dec 2012 15:54:52 +0800 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQkVgDYp++T7u4YfxheCYkTCOOjL/TB+vlFoHSgLOWdSl80Ir4xjPvDg9WURU2AeuRMRVftN X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121218_025459_714823_21051421 X-CRM114-Status: GOOD ( 12.00 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.47 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Jonghwa Lee , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org container_of() never returns NULL, thus remove the NULL checking for it. Also rename get_max77686_clk() to to_max77686_clk() for better readability. Signed-off-by: Axel Lin --- drivers/clk/clk-max77686.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 8944214..3680f66 100644 --- a/drivers/clk/clk-max77686.c +++ b/drivers/clk/clk-max77686.c @@ -44,48 +44,34 @@ struct max77686_clk { struct clk_lookup *lookup; }; -static struct max77686_clk *get_max77686_clk(struct clk_hw *hw) +static struct max77686_clk *to_max77686_clk(struct clk_hw *hw) { return container_of(hw, struct max77686_clk, hw); } static int max77686_clk_prepare(struct clk_hw *hw) { - struct max77686_clk *max77686; - int ret; - - max77686 = get_max77686_clk(hw); - if (!max77686) - return -ENOMEM; - - ret = regmap_update_bits(max77686->iodev->regmap, - MAX77686_REG_32KHZ, max77686->mask, max77686->mask); + struct max77686_clk *max77686 = to_max77686_clk(hw); - return ret; + return regmap_update_bits(max77686->iodev->regmap, + MAX77686_REG_32KHZ, max77686->mask, + max77686->mask); } static void max77686_clk_unprepare(struct clk_hw *hw) { - struct max77686_clk *max77686; - - max77686 = get_max77686_clk(hw); - if (!max77686) - return; + struct max77686_clk *max77686 = to_max77686_clk(hw); regmap_update_bits(max77686->iodev->regmap, - MAX77686_REG_32KHZ, max77686->mask, ~max77686->mask); + MAX77686_REG_32KHZ, max77686->mask, 0); } static int max77686_clk_is_enabled(struct clk_hw *hw) { - struct max77686_clk *max77686; + struct max77686_clk *max77686 = to_max77686_clk(hw); int ret; u32 val; - max77686 = get_max77686_clk(hw); - if (!max77686) - return -ENOMEM; - ret = regmap_read(max77686->iodev->regmap, MAX77686_REG_32KHZ, &val);