From patchwork Fri Jul 27 07:08:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 10291 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 A6CF323E56 for ; Fri, 27 Jul 2012 07:09:44 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 6FC3CA190C3 for ; Fri, 27 Jul 2012 07:09:44 +0000 (UTC) Received: by yenq6 with SMTP id q6so2855352yen.11 for ; Fri, 27 Jul 2012 00:09:44 -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=eejmfaV5tOWEkFxKqnjUG12O4dVNVo8yv2wMdZ56No8=; b=QQEPc4tigMxWCwm9cRM4NVQtn36XgJbUVCeRkcbk+jfuBAC4nwaArFIkY2k53ZQz3l Z+lTzP7MwfcIUdBAbQuEP6utK5N8DnyBu+dBd2xict+VjMvxWA8SoFnOkmECDUy2NOyZ A/UVxGBy/SiBSBpmbbOOKb9jiqvDhmLb3PrFcPDVTk5aMzIOPar8A28V+qFE1h9uePBo Hz9REhvWOCcZ5UytymHYYYAN95brcOWJ45bsBNdLn/qYwGr97LAc4pkwAJrgNbpy3/F1 y/RNoDe6MBXsR5NRS/aRrl3SrwimYHxSGh0GMNoH91UptyX33evKYqK2gSRygKx/NF2d Lctw== Received: by 10.50.10.166 with SMTP id j6mr1010959igb.38.1343372983581; Fri, 27 Jul 2012 00:09:43 -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 bs3csp14883icc; Fri, 27 Jul 2012 00:09:41 -0700 (PDT) Received: by 10.236.145.198 with SMTP id p46mr1309357yhj.49.1343372981553; Fri, 27 Jul 2012 00:09:41 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id d29si577263ano.203.2012.07.27.00.09.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:41 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.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-yw0-f50.google.com with SMTP id j63so3304216yhj.37 for ; Fri, 27 Jul 2012 00:09:41 -0700 (PDT) Received: by 10.68.231.132 with SMTP id tg4mr11482733pbc.159.1343372980919; Fri, 27 Jul 2012 00:09:40 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id qc5sm1355861pbb.6.2012.07.27.00.09.38 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:40 -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 01/11] Bluetooth: Use devm_kzalloc in bcm203x.c file. Date: Fri, 27 Jul 2012 12:38:31 +0530 Message-Id: <1343372921-18780-2-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: ALoCoQny0vOs7z0GABukZ1hk45tQQPOWHXJpFbGbeyT4vU1g6Kjwgb3tRQ8iGJ4YDWmpMz7A1LtN devm_kzalloc() eliminates the need to free memory explicitly thereby saving some cleanup code. Signed-off-by: Sachin Kamat --- drivers/bluetooth/bcm203x.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-) diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 37ae175..364f82b 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c @@ -177,7 +177,7 @@ static int bcm203x_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) { BT_ERR("Can't allocate memory for data structure"); return -ENOMEM; @@ -189,14 +189,12 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id data->urb = usb_alloc_urb(0, GFP_KERNEL); if (!data->urb) { BT_ERR("Can't allocate URB"); - kfree(data); return -ENOMEM; } if (request_firmware(&firmware, "BCM2033-MD.hex", &udev->dev) < 0) { BT_ERR("Mini driver request failed"); usb_free_urb(data->urb); - kfree(data); return -EIO; } @@ -209,7 +207,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id BT_ERR("Can't allocate memory for mini driver"); release_firmware(firmware); usb_free_urb(data->urb); - kfree(data); return -ENOMEM; } @@ -224,7 +221,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id BT_ERR("Firmware request failed"); usb_free_urb(data->urb); kfree(data->buffer); - kfree(data); return -EIO; } @@ -236,7 +232,6 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id release_firmware(firmware); usb_free_urb(data->urb); kfree(data->buffer); - kfree(data); return -ENOMEM; } @@ -271,7 +266,6 @@ static void bcm203x_disconnect(struct usb_interface *intf) usb_free_urb(data->urb); kfree(data->fw_data); kfree(data->buffer); - kfree(data); } static struct usb_driver bcm203x_driver = {