From patchwork Mon Sep 1 09:47:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 384734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-qa0-x239.google.com (mail-qa0-x239.google.com [IPv6:2607:f8b0:400d:c00::239]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 719A81401DB for ; Mon, 1 Sep 2014 19:47:39 +1000 (EST) Received: by mail-qa0-f57.google.com with SMTP id f12sf1328138qad.2 for ; Mon, 01 Sep 2014 02:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:list-post:list-help :list-archive:sender:list-subscribe:list-unsubscribe:content-type; bh=nyvYs7L6GkFwy+V3hpgXmRqYgW0P/+yYFLApreTTaZs=; b=kE2VeJYj/tUlXKt/BFHJ5FFoNmcSbGz2NOQmG0Qyc6H0Npq5wsbbS1gGF3C/D8CFVm 0vKt2Im1H4lSBFp3wUhNspo5uzvGqZh+U8hQb7hmLDyaSRvCwKdmwVN+HCQpmZLBpUJc E7ILPexUO0umccn8uv0h91DVjUslj1/9ooFHTAqg7tmmva3Gu7+FJ0Fi5/i3cxQ7aN7J duW5Z6p0MalamyfTNrMR1DjOI79rS4i7QjsRqylR2SF95dtRXh25RvpE4jCfbhgIeVeF N/9Wv5QcS+XY7x6skV54JkoQo6h8vfqk10Knpfec3H+HIJt3mib+IgtdLWqWOtKAfJEE d94A== X-Received: by 10.182.56.228 with SMTP id d4mr169073obq.5.1409564857410; Mon, 01 Sep 2014 02:47:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.182.214.98 with SMTP id nz2ls741101obc.94.gmail; Mon, 01 Sep 2014 02:47:36 -0700 (PDT) X-Received: by 10.182.130.168 with SMTP id of8mr15844480obb.27.1409564856927; Mon, 01 Sep 2014 02:47:36 -0700 (PDT) Received: from vasmtpcom.263.net (va-smtp01.263.net. [54.88.144.211]) by gmr-mx.google.com with ESMTP id i4si89335qcm.0.2014.09.01.02.47.36 for ; Mon, 01 Sep 2014 02:47:36 -0700 (PDT) Received-SPF: pass (google.com: domain of zyw@rock-chips.com designates 54.88.144.211 as permitted sender) client-ip=54.88.144.211; Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by vasmtpcom.263.net (Postfix) with ESMTP id 83AE07F95C; Mon, 1 Sep 2014 17:47:27 +0800 (CST) X-RL-SENDER: zyw@rock-chips.com X-FST-TO: robh+dt@kernel.org X-SENDER-IP: 127.0.0.1 X-LOGIN-NAME: zyw@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: zyw@rock-chips.com X-DNS-TYPE: 1 Received: from localhost.localdomain (localhost [127.0.0.1]) by vasmtpcom.263.net (Postfix) whith ESMTP id 32540VC1V4X; Mon, 01 Sep 2014 17:47:27 +0800 (CST) From: Chris Zhong To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, sameo@linux.intel.com, lee.jones@linaro.org, lgirdwood@gmail.com, a.zummo@towertech.it, mturquette@linaro.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com, grant.likely@linaro.org, hl@rock-chips.com, huangtao@rock-chips.com, cf@rock-chips.com, zhangqing@rock-chips.com, xxx@rock-chips.com, dianders@chromium.org, heiko@sntech.de, olof@lixom.net, sonnyrao@chromium.org, dtor@chromium.org, javier.martinez@collabora.co.uk, kever.yang@rock-chips.com, Chris Zhong Subject: [rtc-linux] [PATCH v7 5/5] regulator: RK808: Remove pdata from the regulator Date: Mon, 1 Sep 2014 17:47:15 +0800 Message-Id: <1409564835-18522-1-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1409562468-16586-1-git-send-email-zyw@rock-chips.com> References: <1409562468-16586-1-git-send-email-zyw@rock-chips.com> X-Original-Sender: zyw@rock-chips.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of zyw@rock-chips.com designates 54.88.144.211 as permitted sender) smtp.mail=zyw@rock-chips.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Chris Zhong --- Changes in v7: - remove pdata struct from header file, add rk808_regulator struct Changes in v6: - remove the redundant code Changes in v5: - re-edit base on Mark's branch Changes in v4: - use &client->dev replace rk808->dev Changes in v3: None Changes in v2: Adviced by Mark Browm: - change of_find_node_by_name to find_child_by_name - use RK808_NUM_REGULATORS as the name of the constant - create a pdata when missing platform data - use the rk808_reg name to supply_regulator name - replace regulator_register with devm_regulator_register - some other problem with coding style drivers/regulator/rk808-regulator.c | 52 ++++++++++++++--------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/drivers/regulator/rk808-regulator.c b/drivers/regulator/rk808-regulator.c index 0d11df1..4d543a9 100644 --- a/drivers/regulator/rk808-regulator.c +++ b/drivers/regulator/rk808-regulator.c @@ -3,9 +3,6 @@ * * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd * - * Author: Chris Zhong - * Author: Zhang Qing - * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. @@ -14,28 +11,25 @@ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. - * */ #include -#include #include -#include -#include #include -#include #include #include #include -#include -#include -/* - * Field Definitions. - */ + +/* Field Definitions */ #define RK808_BUCK_VSEL_MASK 0x3f #define RK808_BUCK4_VSEL_MASK 0xf #define RK808_LDO_VSEL_MASK 0x1f +struct rk808_regulator { + struct regulator_init_data *rk808_init_data[RK808_NUM_REGULATORS]; + struct device_node *of_node[RK808_NUM_REGULATORS]; +}; + static const int buck_set_vol_base_addr[] = { RK808_BUCK1_ON_VSEL_REG, RK808_BUCK2_ON_VSEL_REG, @@ -50,10 +44,6 @@ static const int buck_contr_base_addr[] = { RK808_BUCK4_CONFIG_REG, }; -#define rk808_BUCK_SET_VOL_REG(x) (buck_set_vol_base_addr[x]) -#define rk808_BUCK_CONTR_REG(x) (buck_contr_base_addr[x]) -#define rk808_LDO_SET_VOL_REG(x) (ldo_set_vol_base_addr[x]) - static const int ldo_set_vol_base_addr[] = { RK808_LDO1_ON_VSEL_REG, RK808_LDO2_ON_VSEL_REG, @@ -65,9 +55,7 @@ static const int ldo_set_vol_base_addr[] = { RK808_LDO8_ON_VSEL_REG, }; -/* - * rk808 voltage number - */ +/* rk808 voltage number */ static const struct regulator_linear_range rk808_buck_voltage_ranges[] = { REGULATOR_LINEAR_RANGE(700000, 0, 63, 12500), }; @@ -295,7 +283,7 @@ static struct of_regulator_match rk808_reg_matches[] = { }; static int rk808_regulator_dts(struct i2c_client *client, - struct rk808_board *pdata) + struct rk808_regulator *rk808_regulator) { struct device_node *np, *reg_np; int i, ret; @@ -323,8 +311,9 @@ static int rk808_regulator_dts(struct i2c_client *client, !rk808_reg_matches[i].of_node) continue; - pdata->rk808_init_data[i] = rk808_reg_matches[i].init_data; - pdata->of_node[i] = rk808_reg_matches[i].of_node; + rk808_regulator->rk808_init_data[i] = + rk808_reg_matches[i].init_data; + rk808_regulator->of_node[i] = rk808_reg_matches[i].of_node; } return 0; @@ -334,26 +323,25 @@ static int rk808_regulator_probe(struct platform_device *pdev) { struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent); struct i2c_client *client = rk808->i2c; - struct rk808_board *pdata = dev_get_platdata(&client->dev); + struct rk808_regulator *rk808_regulator; struct regulator_config config = {}; struct regulator_dev *rk808_rdev; struct regulator_init_data *reg_data; int i = 0; int ret = 0; - if (!pdata) { - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - } + rk808_regulator = devm_kzalloc(&pdev->dev, sizeof(*rk808_regulator), + GFP_KERNEL); + if (!rk808_regulator) + return -ENOMEM; - ret = rk808_regulator_dts(client, pdata); + ret = rk808_regulator_dts(client, rk808_regulator); if (ret) return ret; /* Instantiate the regulators */ for (i = 0; i < RK808_NUM_REGULATORS; i++) { - reg_data = pdata->rk808_init_data[i]; + reg_data = rk808_regulator->rk808_init_data[i]; if (!reg_data) continue; @@ -362,7 +350,7 @@ static int rk808_regulator_probe(struct platform_device *pdev) config.regmap = rk808->regmap; if (client->dev.of_node) - config.of_node = pdata->of_node[i]; + config.of_node = rk808_regulator->of_node[i]; reg_data->supply_regulator = rk808_reg[i].name; config.init_data = reg_data;