From patchwork Sun Jan 26 14:38:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Badarkhe X-Patchwork-Id: 3539821 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8BD09C02DC for ; Sun, 26 Jan 2014 14:38:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E35862012E for ; Sun, 26 Jan 2014 14:38:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1ED4020127 for ; Sun, 26 Jan 2014 14:38:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752653AbaAZOiV (ORCPT ); Sun, 26 Jan 2014 09:38:21 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:46662 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752225AbaAZOiU (ORCPT ); Sun, 26 Jan 2014 09:38:20 -0500 Received: by mail-pa0-f44.google.com with SMTP id kq14so5007610pab.3 for ; Sun, 26 Jan 2014 06:38:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=nnJU4zpoovttEVaOeqX1PPfqDsZnmdf39BiYo2TDfy4=; b=GoTH+Z5qBZZ+9Yw8r9YLS44ngqssArJlAgQ3DCCVeDltVT7oP1/y+/BrdojQGBBR4l QtoLd4m1EEg9B5qrTMGqkZngcDOQepgdt5JrK0aomlk3LZfJo6pnffV6pU8eyFYHkNck ngEs8yJPoTS+3GR4RXr030OGz38TsZ5uClW46NEcsRnhUZnv8EBRiWXdFTggBYBWOO5O 7BAZfALNzcoAlXe0mQO1mZw6SISL3XQABhUuH9wFs1DBhXHhnLQ1zcSm8j+DQ5EZmEfy KvGIkO2EXVsczllxs9ZEWXN9mRgAT9S6agOYTw4vKrYqsVdbGiexmRT+5bVF+i2G6PxU uJZw== X-Received: by 10.66.142.132 with SMTP id rw4mr25651455pab.6.1390747099630; Sun, 26 Jan 2014 06:38:19 -0800 (PST) Received: from manish-HP-Pavilion-dv4-Notebook-PC.connectify ([113.193.151.74]) by mx.google.com with ESMTPSA id zc6sm60653377pab.18.2014.01.26.06.38.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 26 Jan 2014 06:38:19 -0800 (PST) From: Manish Badarkhe To: linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: broonie@kernel.org, lgirdwood@gmail.com, badarkhe.manish@gmail.com Subject: [PATCH V2] max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code. Date: Sun, 26 Jan 2014 20:08:07 +0530 Message-Id: <1390747087-5394-1-git-send-email-badarkhe.manish@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Instead of "#ifdef CONFIG_OF" use "IS_ENABLED(CONFIG_OF)" option for DT code to avoid if-deffery in code. Signed-off-by: Manish Badarkhe --- Changes since V1: 1. update code to retrieve platform/dt data in same function :100644 100644 b4513f2... 20a7100... M drivers/power/max8925_power.c drivers/power/max8925_power.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c index b4513f2..20a7100 100644 --- a/drivers/power/max8925_power.c +++ b/drivers/power/max8925_power.c @@ -427,9 +427,8 @@ static int max8925_deinit_charger(struct max8925_power_info *info) return 0; } -#ifdef CONFIG_OF static struct max8925_power_pdata * -max8925_power_dt_init(struct platform_device *pdev) +max8925_get_data(struct platform_device *pdev) { struct device_node *nproot = pdev->dev.parent->of_node; struct device_node *np; @@ -440,7 +439,7 @@ max8925_power_dt_init(struct platform_device *pdev) int no_insert_detect; struct max8925_power_pdata *pdata; - if (!nproot) + if (!IS_ENABLED(CONFIG_OF) || !nproot) return pdev->dev.platform_data; np = of_find_node_by_name(nproot, "charger"); @@ -468,13 +467,6 @@ max8925_power_dt_init(struct platform_device *pdev) return pdata; } -#else -static struct max8925_power_pdata * -max8925_power_dt_init(struct platform_device *pdev) -{ - return pdev->dev.platform_data; -} -#endif static int max8925_power_probe(struct platform_device *pdev) { @@ -483,7 +475,8 @@ static int max8925_power_probe(struct platform_device *pdev) struct max8925_power_info *info; int ret; - pdata = max8925_power_dt_init(pdev); + pdata = max8925_get_data(pdev); + if (!pdata) { dev_err(&pdev->dev, "platform data isn't assigned to " "power supply\n");