From patchwork Fri Jun 7 16:11:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 17687 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5391D25E27 for ; Fri, 7 Jun 2013 16:12:05 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id z5sf5272923lbh.6 for ; Fri, 07 Jun 2013 09:12:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=MR7JpwCgrIrdIe/nB7O+GLGBIcfbVI6wt93QkjmbLrQ=; b=JdNq3Nf3YIrsD6vbpeQ0sbOGVwM8IKn6mYclc8u5LZaweQL9E6a3Vw+ZV+4uzMkJXx jLMfmK6SyleZdoV39v1gGyfyYndLNTbK56FqEIwJB89MQ4+chMJtlNxjn/awLiPC8bv1 W9pPSum91OHTTRtZlphTabHwOHqFU9hPYdySsI4pAk7YDHC+H1+45ht3D+tADK8gGXFm GavoLWEiJdqIv0GcRIkw0Ms8eNvNPVgHCg+Uqu/Mu9ntb5sn5AYvsEGA28pBIatocNgA P/o7sWR48t546uf1dzqCiA6JPiYN81mwny/z+mLFbh+1NJzcaHrYQ/E6+1NR0RR9eqrM 1h4g== X-Received: by 10.180.95.5 with SMTP id dg5mr1326963wib.6.1370621523597; Fri, 07 Jun 2013 09:12:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.181.12.70 with SMTP id eo6ls274758wid.21.canary; Fri, 07 Jun 2013 09:12:03 -0700 (PDT) X-Received: by 10.180.206.9 with SMTP id lk9mr1962582wic.0.1370621523503; Fri, 07 Jun 2013 09:12:03 -0700 (PDT) Received: from mail-ve0-x22a.google.com (mail-ve0-x22a.google.com [2607:f8b0:400c:c01::22a]) by mx.google.com with ESMTPS id gc10si8928256wic.6.2013.06.07.09.12.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Jun 2013 09:12:03 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22a; Received: by mail-ve0-f170.google.com with SMTP id 14so3210213vea.15 for ; Fri, 07 Jun 2013 09:12:02 -0700 (PDT) X-Received: by 10.58.29.42 with SMTP id g10mr1161860veh.59.1370621522293; Fri, 07 Jun 2013 09:12:02 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp120730vcb; Fri, 7 Jun 2013 09:12:01 -0700 (PDT) X-Received: by 10.15.22.14 with SMTP id e14mr38443865eeu.124.1370621521108; Fri, 07 Jun 2013 09:12:01 -0700 (PDT) Received: from mail-ea0-x231.google.com (mail-ea0-x231.google.com [2a00:1450:4013:c01::231]) by mx.google.com with ESMTPS id z43si58386837een.253.2013.06.07.09.12.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Jun 2013 09:12:01 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4013:c01::231 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:4013:c01::231; Received: by mail-ea0-f177.google.com with SMTP id j14so3724383eak.22 for ; Fri, 07 Jun 2013 09:12:00 -0700 (PDT) X-Received: by 10.15.33.13 with SMTP id b13mr11289335eev.0.1370621520612; Fri, 07 Jun 2013 09:12:00 -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 ESMTPSA id c5sm97260340eeu.8.2013.06.07.09.11.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Jun 2013 09:11:58 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, srinidhi.kasagar@stericsson.com, broonie@linaro.org, Lee Jones Subject: [PATCH 08/10] regulator: ab8500-ext: Register as a device in its own right Date: Fri, 7 Jun 2013 17:11:26 +0100 Message-Id: <1370621488-18130-9-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1370621488-18130-1-git-send-email-lee.jones@linaro.org> References: <1370621488-18130-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnNtZp7Yls38yKRHIz7k0c94WTn9kJQZFndmzd24sICns5Gr4k/IMfeI76WjnU3dd0umldz X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22a is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Some platforms don't support the AB8500 external regulators, so instead of having a list of is_() calls prior to calling ab8500_ext_regulator_init() from ab8500_regulator_probe(), we can only register as a platform device on platforms which require them. It means we also have more control over them when booting with Device Tree. Signed-off-by: Lee Jones --- drivers/regulator/ab8500-ext.c | 33 +++++++++++++++++++++++++++++++-- drivers/regulator/ab8500.c | 17 +---------------- include/linux/regulator/ab8500.h | 4 ---- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index e4975bc..95f495f 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -333,7 +333,7 @@ static struct ab8500_ext_regulator_info }, }; -int ab8500_ext_regulator_init(struct platform_device *pdev) +int ab8500_ext_regulator_probe(struct platform_device *pdev) { struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); struct ab8500_platform_data *ppdata; @@ -409,7 +409,7 @@ int ab8500_ext_regulator_init(struct platform_device *pdev) return 0; } -void ab8500_ext_regulator_exit(struct platform_device *pdev) +int ab8500_ext_regulator_remove(struct platform_device *pdev) { int i; @@ -422,7 +422,36 @@ void ab8500_ext_regulator_exit(struct platform_device *pdev) regulator_unregister(info->rdev); } + + return 0; +} + +static struct platform_driver ab8500_ext_regulator_driver = { + .probe = ab8500_ext_regulator_probe, + .remove = ab8500_ext_regulator_remove, + .driver = { + .name = "ab8500-ext-regulator", + .owner = THIS_MODULE, + }, +}; + +static int __init ab8500_ext_regulator_init(void) +{ + int ret; + + ret = platform_driver_register(&ab8500_ext_regulator_driver); + if (ret) + pr_err("Failed to register ab8500 ext regulator: %d\n", ret); + + return ret; +} +subsys_initcall(ab8500_ext_regulator_init); + +static void __exit ab8500_ext_regulator_exit(void) +{ + platform_driver_unregister(&ab8500_ext_regulator_driver); } +module_exit(ab8500_ext_regulator_exit); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Bengt Jonsson "); diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index a19045e..aea9fdae 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -3156,22 +3156,12 @@ static int ab8500_regulator_probe(struct platform_device *pdev) return err; } - if (!is_ab8505(ab8500)) { - /* register external regulators (before Vaux1, 2 and 3) */ - err = ab8500_ext_regulator_init(pdev); - if (err) - return err; - } - /* register all regulators */ for (i = 0; i < abx500_regulator.info_size; i++) { err = ab8500_regulator_register(pdev, &pdata->regulator[i], i, NULL); - if (err < 0) { - if (!is_ab8505(ab8500)) - ab8500_ext_regulator_exit(pdev); + if (err < 0) return err; - } } return 0; @@ -3180,7 +3170,6 @@ static int ab8500_regulator_probe(struct platform_device *pdev) static int ab8500_regulator_remove(struct platform_device *pdev) { int i, err; - struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); for (i = 0; i < abx500_regulator.info_size; i++) { struct ab8500_regulator_info *info = NULL; @@ -3192,10 +3181,6 @@ static int ab8500_regulator_remove(struct platform_device *pdev) regulator_unregister(info->regulator); } - /* remove external regulators (after Vaux1, 2 and 3) */ - if (!is_ab8505(ab8500)) - ab8500_ext_regulator_exit(pdev); - /* remove regulator debug */ err = ab8500_regulator_debug_exit(pdev); if (err) diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h index 7c5ff0c..7530744 100644 --- a/include/linux/regulator/ab8500.h +++ b/include/linux/regulator/ab8500.h @@ -336,8 +336,4 @@ static inline int ab8500_regulator_debug_exit(struct platform_device *pdev) } #endif -/* AB8500 external regulator functions. */ -int ab8500_ext_regulator_init(struct platform_device *pdev); -void ab8500_ext_regulator_exit(struct platform_device *pdev); - #endif