From patchwork Tue Jan 28 03:12:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manish Badarkhe X-Patchwork-Id: 3544991 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3B66BC02DC for ; Tue, 28 Jan 2014 03:12:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28D4A2011E for ; Tue, 28 Jan 2014 03:12:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3568120114 for ; Tue, 28 Jan 2014 03:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754163AbaA1DM3 (ORCPT ); Mon, 27 Jan 2014 22:12:29 -0500 Received: from mail-pb0-f46.google.com ([209.85.160.46]:33636 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753347AbaA1DM2 (ORCPT ); Mon, 27 Jan 2014 22:12:28 -0500 Received: by mail-pb0-f46.google.com with SMTP id um1so6658295pbc.5 for ; Mon, 27 Jan 2014 19:12:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=QdahMPhSrbQXErGsMaCbazVvPh3nbY9IkPs1lAfZQRA=; b=V8jWl6m2TEXghtivwWmbRMR2mxrvo58YENgUCm2Sv7XCQgmWONkrsm/qPK66uljQkM pRJwGCbUu9RSU5+Keu63gkbjEjQVZ24WE35oCW+pCK6oCOtRVJF8RIPsrYlGEyufOLkj PKWwiYDkpurh+w1ojEgbZLewY4ri/go9McJWlffKWjf4tEausdbgk7fxhhttvNw6i+yP 99IJ/A2QgGQcJCzwwIikEwZEnfTyyVOZwqWNYChyg2z153RJiumZI0i0P+va8Rn1AbI2 YHkI/2b4CFmOTHWgl29MAjKri1A+Z8FBr+34XOnjdPpELfEAr2ou9v0fK9z2lZ1YGNQT kNcA== X-Received: by 10.68.137.195 with SMTP id qk3mr34304513pbb.9.1390878732668; Mon, 27 Jan 2014 19:12:12 -0800 (PST) Received: from manish-HP-Pavilion-dv4-Notebook-PC.connectify ([113.193.146.71]) by mx.google.com with ESMTPSA id bz4sm36775185pbb.12.2014.01.27.19.12.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Jan 2014 19:12:12 -0800 (PST) From: Manish Badarkhe To: linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: broonie@kernel.org, lgirdwood@gmail.com, badarkhe.manish@gmail.com Subject: [PATCH V2] regulator: fixed: update to devm_* API Date: Tue, 28 Jan 2014 08:42:00 +0530 Message-Id: <1390878720-8676-1-git-send-email-badarkhe.manish@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 Update the code to use devm_* API so that driver core will manage resources. Signed-off-by: Manish Badarkhe --- Changes since V1: 1. Updated driver to use "devm_kzalloc" to "kstrdup". 2. Updated commit message. Not tested on any board. :100644 100644 5ea64b9... e9763a4... M drivers/regulator/fixed.c drivers/regulator/fixed.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 5ea64b9..e9763a4 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -132,15 +132,15 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) GFP_KERNEL); if (drvdata == NULL) { dev_err(&pdev->dev, "Failed to allocate device data\n"); - ret = -ENOMEM; - goto err; + return -ENOMEM; } - drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); + drvdata->desc.name = devm_kzalloc(&pdev->dev, + strlen(config->supply_name) + 1, + GFP_KERNEL); if (drvdata->desc.name == NULL) { dev_err(&pdev->dev, "Failed to allocate supply name\n"); - ret = -ENOMEM; - goto err; + return -ENOMEM; } drvdata->desc.type = REGULATOR_VOLTAGE; drvdata->desc.owner = THIS_MODULE; @@ -149,13 +149,13 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.enable_time = config->startup_delay; if (config->input_supply) { - drvdata->desc.supply_name = kstrdup(config->input_supply, - GFP_KERNEL); + drvdata->desc.supply_name = devm_kzalloc(&pdev->dev, + strlen(config->input_supply) + 1, + GFP_KERNEL); if (!drvdata->desc.supply_name) { dev_err(&pdev->dev, "Failed to allocate input supply\n"); - ret = -ENOMEM; - goto err_name; + return -ENOMEM; } } @@ -186,11 +186,12 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) cfg.driver_data = drvdata; cfg.of_node = pdev->dev.of_node; - drvdata->dev = regulator_register(&drvdata->desc, &cfg); + drvdata->dev = devm_regulator_register(&pdev->dev, &drvdata->desc, + &cfg); if (IS_ERR(drvdata->dev)) { ret = PTR_ERR(drvdata->dev); dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); - goto err_input; + return ret; } platform_set_drvdata(pdev, drvdata); @@ -199,24 +200,6 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) drvdata->desc.fixed_uV); return 0; - -err_input: - kfree(drvdata->desc.supply_name); -err_name: - kfree(drvdata->desc.name); -err: - return ret; -} - -static int reg_fixed_voltage_remove(struct platform_device *pdev) -{ - struct fixed_voltage_data *drvdata = platform_get_drvdata(pdev); - - regulator_unregister(drvdata->dev); - kfree(drvdata->desc.supply_name); - kfree(drvdata->desc.name); - - return 0; } #if defined(CONFIG_OF) @@ -229,7 +212,6 @@ MODULE_DEVICE_TABLE(of, fixed_of_match); static struct platform_driver regulator_fixed_voltage_driver = { .probe = reg_fixed_voltage_probe, - .remove = reg_fixed_voltage_remove, .driver = { .name = "reg-fixed-voltage", .owner = THIS_MODULE,