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: 15519 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6470023E14 for ; Thu, 21 Mar 2013 16:01:34 +0000 (UTC) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by fiordland.canonical.com (Postfix) with ESMTP id 947F4A19E84 for ; Thu, 21 Mar 2013 16:01:33 +0000 (UTC) Received: by mail-ve0-f172.google.com with SMTP id cz11so2622570veb.3 for ; Thu, 21 Mar 2013 09:01:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=bgmrwS0b+B1pA9xSC2UDTY3tn+hbOUkxC64Q1Gtvnnk=; b=DeXGSvT0hbuw9fBCbikhPfF+yxjqauxlzac5975FaE43cOkSMWSdurNhdxfpqCxBw/ N71WOyxTKTYtSTpdNszrBk8DzKW1hoBgOqAYpOmRmFphV19M43jLd3TNnrBhuzunQZA+ iGOPrq8J9OVRx6xCmRsHZ1O5hp3XRnf9Cu7STrud4amm2q75+7pZM7wc6KAWXVuiydrj tI2AlgXDqDbb/284t5wjI2FpztEh5P78nL9h1LYaiS6QHxaejtiWuPglfTUsLJ9Um8Dk xRwKIwQwSvKQ5ggMzgs3Ws6hMeeRXyp13s9l6u3xXRo+2pMrIsx+7X7fqA7qyxcJ02lV 3zlA== X-Received: by 10.220.225.200 with SMTP id it8mr13984268vcb.39.1363881693040; Thu, 21 Mar 2013 09:01:33 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.233.198 with SMTP id ty6csp66848vec; Thu, 21 Mar 2013 09:01:32 -0700 (PDT) X-Received: by 10.194.109.35 with SMTP id hp3mr18309254wjb.15.1363881691965; Thu, 21 Mar 2013 09:01:31 -0700 (PDT) Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]) by mx.google.com with ESMTPS id f4si1437777wiw.99.2013.03.21.09.01.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 21 Mar 2013 09:01:31 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::235 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c05::235; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c05::235 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f181.google.com with SMTP id hm6so3278581wib.8 for ; Thu, 21 Mar 2013 09:01:31 -0700 (PDT) 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 Cc: arnd@arndb.de, linus.walleij@stericsson.com, Lee Jones 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: ALoCoQkAGE++iujIW5OLFcfr+FR4EJA7jtiVgSbJ4UP7+ZTSR5x5PCOrct1urZYN7t/4AghNDBD6 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)