From patchwork Fri Jul 27 07:08:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 10299 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 1187923E56 for ; Fri, 27 Jul 2012 07:10:08 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id D6658A190C3 for ; Fri, 27 Jul 2012 07:10:07 +0000 (UTC) Received: by mail-gh0-f180.google.com with SMTP id z12so2859785ghb.11 for ; Fri, 27 Jul 2012 00:10:07 -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=ojCUKsW1kl+K+dyn4b4iAVJY8wbGvUs3NKarsyKu++k=; b=cwY+p85Io9pXnARn2Z/Fgy15UN3CqRYvFzak7xpnd+qSdtmQC0PUtjER332O+1A0ZP 9PZorymdXdd3zIJ7tZF/qBh+jFoYNmvI5CHm75BGvmAoLAbzxTc74VKl8AknsSRmrmsL TUI1/afN5yplhHXUjOMGWNQKK3TC22Zc9Xjz3v0iXhDixbuzBwf3iewBSFv0vs1ux4CP we3lB1kCC88iFFjGDgmPqgqHjG8bIhzD4sTvkY3jyvr6PnnzqdJSmbkYoH2byoMZFHLB JqBDBKSZHYd5MJBc4N8a0mUbkt0/maQ+MjMZFQ9rQzUO7fqvu8AqpsC6uHyya+29drEW FVOg== Received: by 10.50.87.201 with SMTP id ba9mr3671393igb.66.1343373007518; Fri, 27 Jul 2012 00:10:07 -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 bs3csp14920icc; Fri, 27 Jul 2012 00:10:07 -0700 (PDT) Received: by 10.236.75.229 with SMTP id z65mr1427977yhd.7.1343373006949; Fri, 27 Jul 2012 00:10:06 -0700 (PDT) Received: from mail-gg0-f178.google.com (mail-gg0-f178.google.com [209.85.161.178]) by mx.google.com with ESMTPS id g67si1354064yhk.56.2012.07.27.00.10.06 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:10:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.161.178 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.161.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.161.178 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-gg0-f178.google.com with SMTP id q6so3306379ggc.37 for ; Fri, 27 Jul 2012 00:10:06 -0700 (PDT) Received: by 10.66.88.68 with SMTP id be4mr3447338pab.23.1343373006450; Fri, 27 Jul 2012 00:10:06 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id qc5sm1355861pbb.6.2012.07.27.00.10.03 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:10:05 -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 09/11] Bluetooth: Use devm_kzalloc in btusb.c file Date: Fri, 27 Jul 2012 12:38:39 +0530 Message-Id: <1343372921-18780-10-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: ALoCoQlncjwPPXNxBJqkmSXNBfNdoAHY+MMmajQJb3rUo3dFteHSvp1LvXP74AEcBo0omlj+pTvJ devm_kzalloc() eliminates the need to free memory explicitly thereby saving some cleanup code. Signed-off-by: Sachin Kamat --- drivers/bluetooth/btusb.c | 13 +++---------- 1 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index e272214..f637c25 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -952,7 +952,7 @@ static int btusb_probe(struct usb_interface *intf, return -ENODEV; } - data = kzalloc(sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -975,10 +975,8 @@ static int btusb_probe(struct usb_interface *intf, } } - if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { - kfree(data); + if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) return -ENODEV; - } data->cmdreq_type = USB_TYPE_CLASS; @@ -998,10 +996,8 @@ static int btusb_probe(struct usb_interface *intf, init_usb_anchor(&data->deferred); hdev = hci_alloc_dev(); - if (!hdev) { - kfree(data); + if (!hdev) return -ENOMEM; - } hdev->bus = HCI_USB; hci_set_drvdata(hdev, data); @@ -1069,7 +1065,6 @@ static int btusb_probe(struct usb_interface *intf, data->isoc, data); if (err < 0) { hci_free_dev(hdev); - kfree(data); return err; } } @@ -1077,7 +1072,6 @@ static int btusb_probe(struct usb_interface *intf, err = hci_register_dev(hdev); if (err < 0) { hci_free_dev(hdev); - kfree(data); return err; } @@ -1110,7 +1104,6 @@ static void btusb_disconnect(struct usb_interface *intf) usb_driver_release_interface(&btusb_driver, data->isoc); hci_free_dev(hdev); - kfree(data); } #ifdef CONFIG_PM