From patchwork Thu Mar 21 15:59:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 2315331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 2D678400E6 for ; Thu, 21 Mar 2013 16:40:44 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UIiTi-0005YP-1X; Thu, 21 Mar 2013 16:36:34 +0000 Received: from mail-wg0-f44.google.com ([74.125.82.44]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UIhvr-0001XS-8W for linux-arm-kernel@lists.infradead.org; Thu, 21 Mar 2013 16:01:37 +0000 Received: by mail-wg0-f44.google.com with SMTP id dr12so2328563wgb.11 for ; Thu, 21 Mar 2013 09:01:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=bgmrwS0b+B1pA9xSC2UDTY3tn+hbOUkxC64Q1Gtvnnk=; b=bma1Zk0OyH+/ndVSESvdcbeZbYPlwj0Bqf/VN3WmRZxS2glOa2nwH6UM4bp3ZQpsdO cJxfkKdnZQ+o7mWtmIgY4JMD6s+P/t9oGr2ZFU8cte7pYbHBbYFr2AbYkFc6jCoMAKeT WlxodMxfK6O0nqsqP7D52LqagPyPNyp0i/ipj0oGZ/OHsPchnl8SuJrcGeCntYsS593j cVEQeMQBjYVXSpOuE813y4uGAJyjT0b+wm3NSZoShfyHV4YdcUTQi0i4Gzz/Lnkx5iwQ BEjkTCB3uAp5hVNIDMRebNtr30kWA1lTeqLtbPDbnQqfr4lisETTgkKeDxVtTIkPFfWT vURg== X-Received: by 10.194.172.71 with SMTP id ba7mr18201931wjc.26.1363881691564; Thu, 21 Mar 2013 09:01:31 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id h10sm6110847wic.8.2013.03.21.09.01.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Mar 2013 09:01:30 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com Subject: [PATCH 45/46] regulator: ab8500: Shuffle init functions into a more logical order Date: Thu, 21 Mar 2013 15:59:42 +0000 Message-Id: <1363881583-15234-46-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363881583-15234-1-git-send-email-lee.jones@linaro.org> References: <1363881583-15234-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnRjUXwo29H+YV7XXaznB7+uhdvNOq31zeBFtFXraWe9Fu1PUgZafnkDHFDQoc6ljRDmFm5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130321_120135_552903_6556897C X-CRM114-Status: GOOD ( 19.19 ) 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 [74.125.82.44 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Lee Jones , linus.walleij@stericsson.com, arnd@arndb.de 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 The ab*_match[] arrays should be moved out of the way, instead of bunched in the middle of the initialisation functions. This patch moves all initialisation code which currently resides above these arrays down to be grouped with the others. This makes the whole thing slightly easier to read. Signed-off-by: Lee Jones --- drivers/regulator/ab8500.c | 170 ++++++++++++++++++++++---------------------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 72d1ed7..b1170d3 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -2905,91 +2905,6 @@ static struct ab8500_reg_init ab8540_reg_init[] = { REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07), }; -static struct { - struct ab8500_regulator_info *info; - int info_size; - struct ab8500_reg_init *init; - int init_size; - struct of_regulator_match *match; - int match_size; -} abx500_regulator; - -static int ab8500_regulator_init_registers(struct platform_device *pdev, - int id, int mask, int value) -{ - struct ab8500_reg_init *reg_init = abx500_regulator.init; - int err; - - BUG_ON(value & ~mask); - BUG_ON(mask & ~reg_init[id].mask); - - /* initialize register */ - err = abx500_mask_and_set_register_interruptible( - &pdev->dev, - reg_init[id].bank, - reg_init[id].addr, - mask, value); - if (err < 0) { - dev_err(&pdev->dev, - "Failed to initialize 0x%02x, 0x%02x.\n", - reg_init[id].bank, - reg_init[id].addr); - return err; - } - dev_vdbg(&pdev->dev, - " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", - reg_init[id].bank, - reg_init[id].addr, - mask, value); - - return 0; -} - -static int ab8500_regulator_register(struct platform_device *pdev, - struct regulator_init_data *init_data, - int id, struct device_node *np) -{ - struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); - struct ab8500_regulator_info *info = NULL; - struct regulator_config config = { }; - int err; - - /* assign per-regulator data */ - info = &abx500_regulator.info[id]; - info->dev = &pdev->dev; - - config.dev = &pdev->dev; - config.init_data = init_data; - config.driver_data = info; - config.of_node = np; - - /* fix for hardware before ab8500v2.0 */ - if (is_ab8500_1p1_or_earlier(ab8500)) { - if (info->desc.id == AB8500_LDO_AUX3) { - info->desc.n_voltages = - ARRAY_SIZE(ldo_vauxn_voltages); - info->desc.volt_table = ldo_vauxn_voltages; - info->voltage_mask = 0xf; - } - } - - /* register regulator with framework */ - info->regulator = regulator_register(&info->desc, &config); - if (IS_ERR(info->regulator)) { - err = PTR_ERR(info->regulator); - dev_err(&pdev->dev, "failed to register regulator %s\n", - info->desc.name); - /* when we fail, un-register all earlier regulators */ - while (--id >= 0) { - info = &abx500_regulator.info[id]; - regulator_unregister(info->regulator); - } - return err; - } - - return 0; -} - static struct of_regulator_match ab8500_regulator_match[] = { { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, }, { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, }, @@ -3050,6 +2965,15 @@ static struct of_regulator_match ab9540_regulator_match[] = { { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, }, }; +static struct { + struct ab8500_regulator_info *info; + int info_size; + struct ab8500_reg_init *init; + int init_size; + struct of_regulator_match *match; + int match_size; +} abx500_regulator; + static void abx500_get_regulator_info(struct ab8500 *ab8500) { if (is_ab9540(ab8500)) { @@ -3083,6 +3007,82 @@ static void abx500_get_regulator_info(struct ab8500 *ab8500) } } +static int ab8500_regulator_init_registers(struct platform_device *pdev, + int id, int mask, int value) +{ + struct ab8500_reg_init *reg_init = abx500_regulator.init; + int err; + + BUG_ON(value & ~mask); + BUG_ON(mask & ~reg_init[id].mask); + + /* initialize register */ + err = abx500_mask_and_set_register_interruptible( + &pdev->dev, + reg_init[id].bank, + reg_init[id].addr, + mask, value); + if (err < 0) { + dev_err(&pdev->dev, + "Failed to initialize 0x%02x, 0x%02x.\n", + reg_init[id].bank, + reg_init[id].addr); + return err; + } + dev_vdbg(&pdev->dev, + " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", + reg_init[id].bank, + reg_init[id].addr, + mask, value); + + return 0; +} + +static int ab8500_regulator_register(struct platform_device *pdev, + struct regulator_init_data *init_data, + int id, struct device_node *np) +{ + struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); + struct ab8500_regulator_info *info = NULL; + struct regulator_config config = { }; + int err; + + /* assign per-regulator data */ + info = &abx500_regulator.info[id]; + info->dev = &pdev->dev; + + config.dev = &pdev->dev; + config.init_data = init_data; + config.driver_data = info; + config.of_node = np; + + /* fix for hardware before ab8500v2.0 */ + if (is_ab8500_1p1_or_earlier(ab8500)) { + if (info->desc.id == AB8500_LDO_AUX3) { + info->desc.n_voltages = + ARRAY_SIZE(ldo_vauxn_voltages); + info->desc.volt_table = ldo_vauxn_voltages; + info->voltage_mask = 0xf; + } + } + + /* register regulator with framework */ + info->regulator = regulator_register(&info->desc, &config); + if (IS_ERR(info->regulator)) { + err = PTR_ERR(info->regulator); + dev_err(&pdev->dev, "failed to register regulator %s\n", + info->desc.name); + /* when we fail, un-register all earlier regulators */ + while (--id >= 0) { + info = &abx500_regulator.info[id]; + regulator_unregister(info->regulator); + } + return err; + } + + return 0; +} + static int ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np)