From patchwork Fri Jul 27 07:08:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 10296 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 A17FB23E56 for ; Fri, 27 Jul 2012 07:09:59 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 722C7A190DC for ; Fri, 27 Jul 2012 07:09:59 +0000 (UTC) Received: by ggnf1 with SMTP id f1so2862725ggn.11 for ; Fri, 27 Jul 2012 00:09:59 -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=pUQpy9qQANcRKgjIiCIbRphhF3/rgy6ohQ9EmF11UAA=; b=G4sox2fCearNanvQ3C5MinNieH6XQF5/RzVP1lICPB5zsjxCQ8zBBpRedPkEeaLx+h cGlWZVKo964xhY8L32CxZgJffDS8ds4CBkyy8FWkmNA7/Jyt8Sl61ROXxZCKQPZYWRnC DbGiEBqDgiPH80rhmry3kQw73KRO9So2ZH39+cs7A1pA3gA+aiBP7J6FXnQ0c3i/HRQi e9tyHhlBY3yBZP03nwHmhT2lvBpSO9Jfh58T8ZO58AQG6CoPEAyk/Y5Q6sQPZhFJp23y mYG+eeBkzIpbOsV/ofPbwRbsDJni0LA1P2WHvH3k9oPgY1yl1TdN6M8r6/A349TY4pSw HT3Q== Received: by 10.50.242.73 with SMTP id wo9mr1074016igc.1.1343372998530; Fri, 27 Jul 2012 00:09:58 -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 bs3csp14911icc; Fri, 27 Jul 2012 00:09:57 -0700 (PDT) Received: by 10.236.197.3 with SMTP id s3mr1437466yhn.1.1343372997466; Fri, 27 Jul 2012 00:09:57 -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.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:57 -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:57 -0700 (PDT) Received: by 10.66.87.138 with SMTP id ay10mr3372016pab.38.1343372996934; Fri, 27 Jul 2012 00:09:56 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id qc5sm1355861pbb.6.2012.07.27.00.09.54 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Jul 2012 00:09:56 -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 06/11] Bluetooth: Use devm_kzalloc in btmrvl_sdio.c file Date: Fri, 27 Jul 2012 12:38:36 +0530 Message-Id: <1343372921-18780-7-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: ALoCoQkR+4n+3tj1g8uIugKOCvwY79UIFidgNzJbBxOsFMuyOsqacClO2iZKXph2vSBr1glKluFh devm_kzalloc() eliminates the need to free memory explicitly thereby saving some cleanup code. Signed-off-by: Sachin Kamat --- drivers/bluetooth/btmrvl_sdio.c | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c index 6a9e971..03b3acb 100644 --- a/drivers/bluetooth/btmrvl_sdio.c +++ b/drivers/bluetooth/btmrvl_sdio.c @@ -956,11 +956,9 @@ static int btmrvl_sdio_probe(struct sdio_func *func, BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d", id->vendor, id->device, id->class, func->num); - card = kzalloc(sizeof(*card), GFP_KERNEL); - if (!card) { - ret = -ENOMEM; - goto done; - } + card = devm_kzalloc(&func->dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; card->func = func; @@ -974,8 +972,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func, if (btmrvl_sdio_register_dev(card) < 0) { BT_ERR("Failed to register BT device!"); - ret = -ENODEV; - goto free_card; + return -ENODEV; } /* Disable the interrupts on the card */ @@ -1023,9 +1020,6 @@ disable_host_int: btmrvl_sdio_disable_host_int(card); unreg_dev: btmrvl_sdio_unregister_dev(card); -free_card: - kfree(card); -done: return ret; } @@ -1047,7 +1041,6 @@ static void btmrvl_sdio_remove(struct sdio_func *func) BT_DBG("unregester dev"); btmrvl_sdio_unregister_dev(card); btmrvl_remove_card(card->priv); - kfree(card); } } }