From patchwork Thu Mar 28 16:11:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 15752 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 8474223E10 for ; Thu, 28 Mar 2013 16:13:01 +0000 (UTC) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by fiordland.canonical.com (Postfix) with ESMTP id 29081A18899 for ; Thu, 28 Mar 2013 16:13:01 +0000 (UTC) Received: by mail-ve0-f178.google.com with SMTP id db10so4359371veb.9 for ; Thu, 28 Mar 2013 09:13:00 -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=Eiy0jQAo3IaLYZEDKBOSHUrGxk3F5RJcCFNy+aI07XA=; b=m5FdzGijPRjYiP+2yo0CMCDEzVxm+SJtrsJbUNVUkJD2wVjOb3+TlAKJjc6hDIYHq1 YF6drb8wGGqdYzDPCmW2D+apa13hTuJ1jObYMZrpF/8jzAIzwXcgsYNoWxXngiIkMoYi kU88woMCNXu+bHUt2nVgDBwwCP8f9r+0iYU2emAKVp2iXfZJiWg9hbLpFs1hqczJSeis flc1eAmDY2A/nX2BNH5/gjQKYjnWyBEgcjFcQcgUoy2Z7Nc4rZyXktKzzx8Kl2siqucg /sXkmi2oqU30if1IAEOSuVrDwoc0K0VqfAhcPmjaoHNZu0SfrWkTf7akBApx4lFCS3Hy S++g== X-Received: by 10.52.93.20 with SMTP id cq20mr23717050vdb.38.1364487180645; Thu, 28 Mar 2013 09:13:00 -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.59.4.204 with SMTP id cg12csp22452ved; Thu, 28 Mar 2013 09:13:00 -0700 (PDT) X-Received: by 10.194.237.40 with SMTP id uz8mr39446632wjc.49.1364487176410; Thu, 28 Mar 2013 09:12:56 -0700 (PDT) Received: from mail-we0-x231.google.com ([2a00:1450:400c:c03::231]) by mx.google.com with ESMTPS id c19si5261091wjs.52.2013.03.28.09.12.56 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Mar 2013 09:12:56 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::231 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::231; Authentication-Results: mx.google.com; spf=neutral (google.com: 2a00:1450:400c:c03::231 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-we0-f177.google.com with SMTP id o45so3310626wer.36 for ; Thu, 28 Mar 2013 09:12:56 -0700 (PDT) X-Received: by 10.194.171.74 with SMTP id as10mr39282970wjc.0.1364487176012; Thu, 28 Mar 2013 09:12:56 -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 o5sm16765926wix.3.2013.03.28.09.12.54 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Mar 2013 09:12:55 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org, broonie@opensource.wolfsonmicro.com Cc: Lee Jones Subject: [PATCH 32/33] regulator: ab8500: Shuffle init functions into a more logical order Date: Thu, 28 Mar 2013 16:11:32 +0000 Message-Id: <1364487093-19551-33-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364487093-19551-1-git-send-email-lee.jones@linaro.org> References: <1364487093-19551-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQm5rAC+X0DNlMHZpfpyilzx1L3xS0LCqjE8vqkLUYNTCK9LpEExxDzOVgu8NqqrrKuxB7RA 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 bb574bf..535a94f 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -2916,91 +2916,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, }, @@ -3061,6 +2976,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)) { @@ -3094,6 +3018,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)