From patchwork Fri Jul 27 07:08:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 10292 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 664BC23E56 for ; Fri, 27 Jul 2012 07:09:47 +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 377A4A190DC for ; Fri, 27 Jul 2012 07:09:47 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so2864191yhp.11 for ; Fri, 27 Jul 2012 00:09:47 -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=YNh/wvVRbojbtcP4MOZAngCyIu5xVgk6fBNrpw69Z48=; b=BlXJ9+6t/Fgy+psYK8vreRBNTB33BcH282HOlQ7QkP31lbmbC4PRhp0Ui6jPDSjK0c LjnoTtip0Boh+PUafyG9pXoqZvOISrXZKyboWdQtBVshn6eSSAEzGNmyUE8aTX4cIp8/ wmxiPCOx+C6lMVkTJ4XAki39S5ooajV89HB+4uJPiLFigEMRATmMkGUmFVUiJBgcJgV1 5pDVIuI2as9JTrLJPHhygBbjPGNjxQyEcG8Ize6pySo3ar3c+UA+ulmrcQxXTF/gSsdd BHe6Z236lBlN+/46fyt05A6OiQL6R0n2VcJ+EBc3vgji+W6MRfYVn2Q1BkQQNAcxO2vy 2QpQ== Received: by 10.42.189.73 with SMTP id dd9mr792931icb.49.1343372986844; Fri, 27 Jul 2012 00:09:46 -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 bs3csp14889icc; Fri, 27 Jul 2012 00:09:45 -0700 (PDT) Received: by 10.68.223.198 with SMTP id qw6mr11461734pbc.94.1343372984445; Fri, 27 Jul 2012 00:09:44 -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.44 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:44 -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 pbbrr4 with SMTP id rr4so5197136pbb.37 for ; Fri, 27 Jul 2012 00:09:44 -0700 (PDT) Received: by 10.68.236.102 with SMTP id ut6mr11343352pbc.113.1343372984061; Fri, 27 Jul 2012 00:09:44 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id qc5sm1355861pbb.6.2012.07.27.00.09.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:43 -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 02/11] Bluetooth: Use devm_kzalloc in bfusb.c file Date: Fri, 27 Jul 2012 12:38:32 +0530 Message-Id: <1343372921-18780-3-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: ALoCoQmSpX+zuX1V81QURJ4RBB2t2JH9YLUn9xxxEdmxveQwtoD4bgYtevXgWlsmgJ8n8j/KseQU devm_kzalloc() eliminates the need to free memory explicitly thereby saving some cleanup code. Signed-off-by: Sachin Kamat --- drivers/bluetooth/bfusb.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 32e8251..995aee9 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c @@ -653,7 +653,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i } /* Initialize control structure and load firmware */ - data = kzalloc(sizeof(struct bfusb_data), GFP_KERNEL); + data = devm_kzalloc(&intf->dev, sizeof(struct bfusb_data), GFP_KERNEL); if (!data) { BT_ERR("Can't allocate memory for control structure"); goto done; @@ -674,7 +674,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) { BT_ERR("Firmware request failed"); - goto error; + goto done; } BT_DBG("firmware data %p size %zu", firmware->data, firmware->size); @@ -690,7 +690,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); - goto error; + goto done; } data->hdev = hdev; @@ -708,7 +708,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); - goto error; + goto done; } usb_set_intfdata(intf, data); @@ -718,9 +718,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i release: release_firmware(firmware); -error: - kfree(data); - done: return -EIO; } @@ -741,7 +738,6 @@ static void bfusb_disconnect(struct usb_interface *intf) hci_unregister_dev(hdev); hci_free_dev(hdev); - kfree(data); } static struct usb_driver bfusb_driver = {