From patchwork Fri Jul 27 07:08:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 10294 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0D74423E56 for ; Fri, 27 Jul 2012 07:09:52 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id D2915A190DC for ; Fri, 27 Jul 2012 07:09:51 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so2864191yhp.11 for ; Fri, 27 Jul 2012 00:09:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=eEjdWUiWAo9S462kLYVkFduSJXhL1dFbrLNf/jJsNOQ=; b=XxYzwcLcQcE5o18+a/C40FdO1CksyRPTASHMQJmZjsO0ltUso8xqMyvjEYOnvPHq6z TYAKaccuByf0si2U7YWvX6DHVwcHjRltWOM3NgHgMbj2F7O4F+OIcgvxXbO7dc5IUZcY mG6q3f8nzulG4E8bAo42Ug0OGwJgisxc6kWO7E2tN6UqNZaUIls7PlAKFJEiB+V1FeyF z0bFAG9Yz/aCRog/jS2aGIXEC6q3cEVeggnUkwtMkxBIM81s+njr6IR3kzc6ZFj/n1FA Nx+eVHSR6SgoEB7+3UxwDr0GNh8Hdiv9h84cmOVR+obU4B9jNr/lJ1WYCj1ulml/rGIA vWBw== Received: by 10.50.209.73 with SMTP id mk9mr954348igc.66.1343372991464; Fri, 27 Jul 2012 00:09:51 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.43.93.3 with SMTP id bs3csp14901icc; Fri, 27 Jul 2012 00:09:51 -0700 (PDT) Received: by 10.68.203.7 with SMTP id km7mr11718353pbc.7.1343372990869; Fri, 27 Jul 2012 00:09:50 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id ob3si3195489pbb.21.2012.07.27.00.09.50 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pb0-f50.google.com with SMTP id rr4so5197136pbb.37 for ; Fri, 27 Jul 2012 00:09:50 -0700 (PDT) Received: by 10.68.231.132 with SMTP id tg4mr11483840pbc.159.1343372990638; Fri, 27 Jul 2012 00:09:50 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id qc5sm1355861pbb.6.2012.07.27.00.09.47 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:50 -0700 (PDT) From: Sachin Kamat To: linux-bluetooth@vger.kernel.org Cc: marcel@holtmann.org, gustavo@padovan.org, johan.hedberg@gmail.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 04/11] Bluetooth: Use devm_kzalloc in bpa10x.c file Date: Fri, 27 Jul 2012 12:38:34 +0530 Message-Id: <1343372921-18780-5-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1343372921-18780-1-git-send-email-sachin.kamat@linaro.org> References: <1343372921-18780-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQnbC8otjUTwgtb7pAntCluqAVnF6aTyNRGc0KEPM6Cfh7ccgCjhrcFEloyYcjZsjTOh0e+2 devm_kzalloc() eliminates the need to free memory explicitly thereby saving some cleanup code. Signed-off-by: Sachin Kamat --- drivers/bluetooth/bpa10x.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 29caaed..2fe4a80 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c @@ -443,7 +443,7 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * if (intf->cur_altsetting->desc.bInterfaceNumber != 0) return -ENODEV; - data = kzalloc(sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -453,10 +453,8 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * init_usb_anchor(&data->rx_anchor); hdev = hci_alloc_dev(); - if (!hdev) { - kfree(data); + if (!hdev) return -ENOMEM; - } hdev->bus = HCI_USB; hci_set_drvdata(hdev, data); @@ -475,7 +473,6 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id * err = hci_register_dev(hdev); if (err < 0) { hci_free_dev(hdev); - kfree(data); return err; } @@ -500,7 +497,6 @@ static void bpa10x_disconnect(struct usb_interface *intf) hci_free_dev(data->hdev); kfree_skb(data->rx_skb[0]); kfree_skb(data->rx_skb[1]); - kfree(data); } static struct usb_driver bpa10x_driver = {