From patchwork Thu May 23 15:25:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 17151 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-fa0-f71.google.com (mail-fa0-f71.google.com [209.85.161.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6B3F92395B for ; Thu, 23 May 2013 15:26:52 +0000 (UTC) Received: by mail-fa0-f71.google.com with SMTP id s1sf2525884fas.10 for ; Thu, 23 May 2013 08:25:56 -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=diO7z77HaUL0uviJ88ZNer5ljj3zbNrXfGPuUA4GTBU=; b=m/+7rOCp3Tkj898RsV//rLhTQmDCSoZ/mbFfLoa8OP0Oh7ThB+wJgdi2Qc83JPfHlK mv8P8UGlMCOz+cXIAdf0f32TNzzUaKFK7fPUFS9c8DfRf5boBDSdEF8BUVMj2B2Wshgh di7Q04/u4FLHw4x3aAyIsYNxXmq+fVMyNk14v8ZmKPgoJ2CJPSsLgQuircbdjhZYrXea +SQgCnAyufhkspuW44Sf3InUEhG9jzQHRYhL49gyh0mh3RD6bjXI+OHVd4u3CqmjUkro dcKW39HJXgUj0GoMYqWjJs0JQTv6dadAgqWpz0dPghvEyiSlznNhVXXNmBYZxBzLnYh2 4rrg== X-Received: by 10.180.76.174 with SMTP id l14mr6192355wiw.5.1369322756489; Thu, 23 May 2013 08:25:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.84.234 with SMTP id c10ls1869789wiz.5.canary; Thu, 23 May 2013 08:25:56 -0700 (PDT) X-Received: by 10.180.107.104 with SMTP id hb8mr39646557wib.26.1369322756292; Thu, 23 May 2013 08:25:56 -0700 (PDT) Received: from mail-ve0-x231.google.com (mail-ve0-x231.google.com [2607:f8b0:400c:c01::231]) by mx.google.com with ESMTPS id p6si9212396wia.102.2013.05.23.08.25.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:25:56 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::231 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::231; Received: by mail-ve0-f177.google.com with SMTP id ox1so2524756veb.36 for ; Thu, 23 May 2013 08:25:55 -0700 (PDT) X-Received: by 10.52.233.34 with SMTP id tt2mr4735029vdc.70.1369322755208; Thu, 23 May 2013 08:25:55 -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.220.126.138 with SMTP id c10csp57030vcs; Thu, 23 May 2013 08:25:54 -0700 (PDT) X-Received: by 10.180.37.133 with SMTP id y5mr25421544wij.20.1369322754145; Thu, 23 May 2013 08:25:54 -0700 (PDT) Received: from mail-wi0-x229.google.com (mail-wi0-x229.google.com [2a00:1450:400c:c05::229]) by mx.google.com with ESMTPS id ll18si9235297wic.47.2013.05.23.08.25.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:25:54 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::229 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c05::229; Received: by mail-wi0-f169.google.com with SMTP id hn14so5087841wib.2 for ; Thu, 23 May 2013 08:25:53 -0700 (PDT) X-Received: by 10.181.13.74 with SMTP id ew10mr26033649wid.9.1369322753767; Thu, 23 May 2013 08:25:53 -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 d10sm36397561wik.0.2013.05.23.08.25.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:25:52 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org, sameo@linux.intel.com Cc: Lee Jones Subject: [PATCH 15/16] mfd: max77686: Convert to managed resources for allocating memory Date: Thu, 23 May 2013 16:25:16 +0100 Message-Id: <1369322717-30429-15-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369322717-30429-1-git-send-email-lee.jones@linaro.org> References: <1369322717-30429-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkMu4XlPCIUMNVrBHk/aV/v+jEEG4mGm8hMFa1JRRqBejlFzp5cx1vZ/lmETOnsY8mjgeng X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::231 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: , Signed-off-by: Lee Jones --- drivers/mfd/max77686.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c index 1cbb176..b094ac5 100644 --- a/drivers/mfd/max77686.c +++ b/drivers/mfd/max77686.c @@ -84,12 +84,12 @@ static int max77686_i2c_probe(struct i2c_client *i2c, pdata = max77686_i2c_parse_dt_pdata(&i2c->dev); if (!pdata) { - ret = -EIO; dev_err(&i2c->dev, "No platform data found.\n"); - goto err; + return -EIO; } - max77686 = kzalloc(sizeof(struct max77686_dev), GFP_KERNEL); + max77686 = devm_kzalloc(&i2c->dev, + sizeof(struct max77686_dev), GFP_KERNEL); if (max77686 == NULL) return -ENOMEM; @@ -107,7 +107,6 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ret = PTR_ERR(max77686->regmap); dev_err(max77686->dev, "Failed to allocate register map: %d\n", ret); - kfree(max77686); return ret; } @@ -115,8 +114,7 @@ static int max77686_i2c_probe(struct i2c_client *i2c, MAX77686_REG_DEVICE_ID, &data) < 0) { dev_err(max77686->dev, "device not found on this channel (this is not an error)\n"); - ret = -ENODEV; - goto err; + return -ENODEV; } else dev_info(max77686->dev, "device found\n"); @@ -127,17 +125,11 @@ static int max77686_i2c_probe(struct i2c_client *i2c, ret = mfd_add_devices(max77686->dev, -1, max77686_devs, ARRAY_SIZE(max77686_devs), NULL, 0, NULL); + if (ret < 0) { + mfd_remove_devices(max77686->dev); + i2c_unregister_device(max77686->rtc); + } - if (ret < 0) - goto err_mfd; - - return ret; - -err_mfd: - mfd_remove_devices(max77686->dev); - i2c_unregister_device(max77686->rtc); -err: - kfree(max77686); return ret; } @@ -147,7 +139,6 @@ static int max77686_i2c_remove(struct i2c_client *i2c) mfd_remove_devices(max77686->dev); i2c_unregister_device(max77686->rtc); - kfree(max77686); return 0; }