From patchwork Sat Jan 12 10:01:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 1968861 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 53972DF230 for ; Sat, 12 Jan 2013 10:06:10 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Ttxua-0002mf-Cz; Sat, 12 Jan 2013 10:02:00 +0000 Received: from mail-da0-f52.google.com ([209.85.210.52]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TtxuW-0002m4-Mb for linux-arm-kernel@lists.infradead.org; Sat, 12 Jan 2013 10:01:57 +0000 Received: by mail-da0-f52.google.com with SMTP id f10so1133081dak.39 for ; Sat, 12 Jan 2013 02:01:54 -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=/cQogPaQrAc0BrTxnOhf0cNVbbarmS2rN4hsrTm5Npg=; b=BzXhuWoyhroKQFWsHnsElDVl8x+A/LotcHi0ibxUJ8QtwyNBnW9UcITSr8TAaps+qa HVLVtUx4mTJ9JDUyd+bVOy3K+6Kx3tBgtWeSNBJNpBQl0fHKhp0wdZarGbl67/+PDDAH A2OX9l9k8Qr+7sih3r0UIdTQE1PQzXfyrQpk2MSh+9gyn5JRKMqePf78JIR0MA49Fsrf d7Ke/Fp+PcQtfxZC9rU+pQXcT74AAJ2zrcwtFl9aC0CU36+nBnT1OTm1gVc7RZucrF7v WSU729Vp5XZbXR7TNdlKEXHP79d+wxf0LPNQhpSTVsBPH5/Q7h17qB+cSBkfZMsUhv8b /3Dg== X-Received: by 10.68.197.197 with SMTP id iw5mr234076250pbc.22.1357984914474; Sat, 12 Jan 2013 02:01:54 -0800 (PST) Received: from [192.168.0.102] (122-121-50-214.dynamic.hinet.net. [122.121.50.214]) by mx.google.com with ESMTPS id wr4sm4372454pbc.72.2013.01.12.02.01.51 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 12 Jan 2013 02:01:53 -0800 (PST) Message-ID: <1357984906.6460.2.camel@phoenix> Subject: [PATCH v2] clk: max77686: Remove unnecessary NULL checking for container_of() From: Axel Lin To: Mike Turquette Date: Sat, 12 Jan 2013 18:01:46 +0800 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQkdWyi9Blc6x5V77XgsStEbZFYH8ZPH+Yxt3CpCz/FUNrvFO3ZyplmMABZrEHAj5ZJgNWPE X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130112_050156_915235_3D78BE8B X-CRM114-Status: GOOD ( 11.01 ) 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.210.52 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 --- v2: remove unrelated change for ~max77686->mask drivers/clk/clk-max77686.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/clk/clk-max77686.c b/drivers/clk/clk-max77686.c index 8944214..90bf59c 100644 --- a/drivers/clk/clk-max77686.c +++ b/drivers/clk/clk-max77686.c @@ -44,33 +44,23 @@ 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); @@ -78,14 +68,10 @@ static void max77686_clk_unprepare(struct clk_hw *hw) 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);