From patchwork Thu May 23 15:25:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 17148 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f200.google.com (mail-gg0-f200.google.com [209.85.161.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A453F23976 for ; Thu, 23 May 2013 15:26:48 +0000 (UTC) Received: by mail-gg0-f200.google.com with SMTP id w6sf3675583ggk.11 for ; Thu, 23 May 2013 08:25:53 -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=gR8It1UBTyIB6Ev59HxCzNYyI7Pk1AqgvjZPQre+xqs=; b=OtSh/lIOu6hk/UZRvmIIewsoR6L7jP4JdJ7nKnecpzEdo8bKjMxIbxbpPSHKHinZQI U5cUyCeykXEmlcbTDxJO4MK6hYIeRd5EtshdUda6OxULDNOW2nFQ1Jk7vSt9WLSpTKOS ay+YLvpC5lmezHL8QRld/hFzERzPAE33HX61BdN6Wvtq3pLqJZGFmnu+jclSl/q45Okm 1dLZSm9vigmhLPUTDzj6SdZq7cGCruxGnBCc9xT2aWpgCRtOuPvZty9E3+R+gcqKuC4K FBUGNDTYl1ty44+PhNC2GW1CTPOzOivKH2BCW9cIoSB7jXkGSZ1wvws+nnC5a6aVcI/6 XTcA== X-Received: by 10.236.70.170 with SMTP id p30mr6671129yhd.5.1369322753276; Thu, 23 May 2013 08:25:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.34.205 with SMTP id b13ls1433419qej.62.gmail; Thu, 23 May 2013 08:25:53 -0700 (PDT) X-Received: by 10.221.7.67 with SMTP id on3mr5563177vcb.70.1369322752960; Thu, 23 May 2013 08:25:52 -0700 (PDT) Received: from mail-vb0-x235.google.com (mail-vb0-x235.google.com [2607:f8b0:400c:c02::235]) by mx.google.com with ESMTPS id sc6si6597178vdc.151.2013.05.23.08.25.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:25:52 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::235 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:c02::235; Received: by mail-vb0-f53.google.com with SMTP id p13so968350vbe.12 for ; Thu, 23 May 2013 08:25:52 -0700 (PDT) X-Received: by 10.58.225.228 with SMTP id rn4mr5611486vec.35.1369322752776; Thu, 23 May 2013 08:25:52 -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 c10csp57025vcs; Thu, 23 May 2013 08:25:52 -0700 (PDT) X-Received: by 10.180.107.104 with SMTP id hb8mr39645920wib.26.1369322751759; Thu, 23 May 2013 08:25:51 -0700 (PDT) Received: from mail-we0-x236.google.com (mail-we0-x236.google.com [2a00:1450:400c:c03::236]) by mx.google.com with ESMTPS id t9si14711328wiv.63.2013.05.23.08.25.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:25:51 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::236 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::236; Received: by mail-we0-f182.google.com with SMTP id q57so1920556wes.13 for ; Thu, 23 May 2013 08:25:51 -0700 (PDT) X-Received: by 10.180.21.167 with SMTP id w7mr25829425wie.2.1369322743302; Thu, 23 May 2013 08:25:43 -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.41 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 May 2013 08:25:42 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org, sameo@linux.intel.com Cc: Lee Jones Subject: [PATCH 09/16] mfd: cros_ec: Convert to managed resources for allocating memory Date: Thu, 23 May 2013 16:25:10 +0100 Message-Id: <1369322717-30429-9-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: ALoCoQkrLoDiNy8C513LwMG+8UHfKeXRzgaR4fVoawwzVSAelouZFBZP8JsxEledX/tXhabJQVXy X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::235 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/cros_ec.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c index 10cd14e..1f36885 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -104,23 +104,19 @@ int cros_ec_register(struct cros_ec_device *ec_dev) ec_dev->command_sendrecv = cros_ec_command_sendrecv; if (ec_dev->din_size) { - ec_dev->din = kmalloc(ec_dev->din_size, GFP_KERNEL); - if (!ec_dev->din) { - err = -ENOMEM; - goto fail_din; - } + ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL); + if (!ec_dev->din) + return -ENOMEM; } if (ec_dev->dout_size) { - ec_dev->dout = kmalloc(ec_dev->dout_size, GFP_KERNEL); - if (!ec_dev->dout) { - err = -ENOMEM; - goto fail_dout; - } + ec_dev->dout = devm_kzalloc(dev, ec_dev->dout_size, GFP_KERNEL); + if (!ec_dev->dout) + return -ENOMEM; } if (!ec_dev->irq) { dev_dbg(dev, "no valid IRQ: %d\n", ec_dev->irq); - goto fail_irq; + return err; } err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread, @@ -128,7 +124,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) "chromeos-ec", ec_dev); if (err) { dev_err(dev, "request irq %d: error %d\n", ec_dev->irq, err); - goto fail_irq; + return err; } err = mfd_add_devices(dev, 0, cros_devs, @@ -145,11 +141,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) fail_mfd: free_irq(ec_dev->irq, ec_dev); -fail_irq: - kfree(ec_dev->dout); -fail_dout: - kfree(ec_dev->din); -fail_din: + return err; } EXPORT_SYMBOL(cros_ec_register); @@ -158,8 +150,6 @@ int cros_ec_remove(struct cros_ec_device *ec_dev) { mfd_remove_devices(ec_dev->dev); free_irq(ec_dev->irq, ec_dev); - kfree(ec_dev->dout); - kfree(ec_dev->din); return 0; }