From patchwork Tue Jul 21 13:50:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 6836411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8D1C49F380 for ; Tue, 21 Jul 2015 13:58:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD19C20670 for ; Tue, 21 Jul 2015 13:58:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2D3920648 for ; Tue, 21 Jul 2015 13:58:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHY2F-00014F-MG; Tue, 21 Jul 2015 13:56:43 +0000 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZHXyE-0004jk-Bl for linux-arm-kernel@lists.infradead.org; Tue, 21 Jul 2015 13:52:35 +0000 Received: by wicmv11 with SMTP id mv11so42326808wic.0 for ; Tue, 21 Jul 2015 06:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=+1Z9yjQQs13/ASScdipiXWA+w6LMcAMXgSUVCFGZSPA=; b=BvBTIj5MQVHEwpzrF+anKBoBgoE2GSVgBn6EfUrdruSyGQLrsRF1Cf0f0BMNvQ9Wxb I4GEb7ZC20M31uOYaR7hJax50c5xeNA9u8cIbYb4q3WsKfc6yKoOFYo3yYjaOMe0FujO Ps8EsJJY1z3q6wW0Z5+10zC9wMiPngMRiNJCY6eQlglGnFw9xZkJIz01dpv8CM/0YU2z Twnchv9WeJxcBUSbs+mTRgeEW60wYZ2qjfE9ZXPqYwezSmRxARhnRKXO9WKFF5CB9PLW sLIyWn6GQg/QtsyBTz9dlGe4ZjeO0+mX1+TlKI/bbEBnNbOtalwtnMW4cU4HTiQD3cny BxLw== X-Received: by 10.180.189.17 with SMTP id ge17mr31223091wic.90.1437486732644; Tue, 21 Jul 2015 06:52:12 -0700 (PDT) Received: from cizrna.lan ([109.72.12.178]) by smtp.gmail.com with ESMTPSA id pf4sm37172056wjb.23.2015.07.21.06.52.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 06:52:11 -0700 (PDT) From: Tomeu Vizoso To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 16/16] fixed-regulator: Use devm_resource Date: Tue, 21 Jul 2015 15:50:58 +0200 Message-Id: <1437486658-28365-17-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> References: <1437486658-28365-1-git-send-email-tomeu.vizoso@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150721_065234_581697_CF7E66B9 X-CRM114-Status: GOOD ( 15.76 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Tomeu Vizoso , Stephen Warren , "Rafael J. Wysocki" , Mark Brown , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Tomeu Vizoso --- drivers/regulator/fixed.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index ff62d69ba0be..4ece78c1260d 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -34,6 +34,7 @@ struct fixed_voltage_data { struct regulator_desc desc; struct regulator_dev *dev; + struct gpio_desc *gpio; }; @@ -78,20 +79,6 @@ of_get_fixed_voltage_config(struct device *dev, if (init_data->constraints.boot_on) config->enabled_at_boot = true; - config->gpio = of_get_named_gpio(np, "gpio", 0); - /* - * of_get_named_gpio() currently returns ENODEV rather than - * EPROBE_DEFER. This code attempts to be compatible with both - * for now; the ENODEV check can be removed once the API is fixed. - * of_get_named_gpio() doesn't differentiate between a missing - * property (which would be fine here, since the GPIO is optional) - * and some other error. Patches have been posted for both issues. - * Once they are check in, we should replace this with: - * if (config->gpio < 0 && config->gpio != -ENOENT) - */ - if ((config->gpio == -ENODEV) || (config->gpio == -EPROBE_DEFER)) - return ERR_PTR(-EPROBE_DEFER); - of_property_read_u32(np, "startup-delay-us", &config->startup_delay); config->enable_high = of_property_read_bool(np, "enable-active-high"); @@ -110,20 +97,17 @@ static struct regulator_ops fixed_voltage_ops = { static int reg_fixed_voltage_probe(struct platform_device *pdev) { struct fixed_voltage_config *config; - struct fixed_voltage_data *drvdata; + struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev); struct regulator_config cfg = { }; int ret; - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct fixed_voltage_data), - GFP_KERNEL); - if (!drvdata) - return -ENOMEM; - if (pdev->dev.of_node) { config = of_get_fixed_voltage_config(&pdev->dev, &drvdata->desc); if (IS_ERR(config)) return PTR_ERR(config); + + config->gpio = desc_to_gpio(drvdata->gpio); } else { config = dev_get_platdata(&pdev->dev); } @@ -193,8 +177,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) return ret; } - platform_set_drvdata(pdev, drvdata); - dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name, drvdata->desc.fixed_uV); @@ -209,11 +191,18 @@ static const struct of_device_id fixed_of_match[] = { MODULE_DEVICE_TABLE(of, fixed_of_match); #endif +static const struct devm_resource reg_fixed_resources[] = { + DEVM_ALLOC(fixed_voltage_data), + DEVM_GPIO_NAMED(fixed_voltage_data, gpio, NULL), + {}, +}; + static struct platform_driver regulator_fixed_voltage_driver = { .probe = reg_fixed_voltage_probe, .driver = { .name = "reg-fixed-voltage", .of_match_table = of_match_ptr(fixed_of_match), + .resources = reg_fixed_resources, }, };