From patchwork Sat Jan 24 17:47:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 5699991 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 249A29F302 for ; Sat, 24 Jan 2015 17:47:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 23BF4202E5 for ; Sat, 24 Jan 2015 17:47:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 439EC20254 for ; Sat, 24 Jan 2015 17:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753759AbbAXRrb (ORCPT ); Sat, 24 Jan 2015 12:47:31 -0500 Received: from mail-wg0-f54.google.com ([74.125.82.54]:35723 "EHLO mail-wg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753169AbbAXRrb (ORCPT ); Sat, 24 Jan 2015 12:47:31 -0500 Received: by mail-wg0-f54.google.com with SMTP id b13so2638372wgh.13 for ; Sat, 24 Jan 2015 09:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=kq+ILwOPnjr8RKbQF02Mtr4qbfi09ptVYkmsr83Xwmc=; b=Q2PZ0oFc1520zFF6SEhWGmU+WMYgbI356gVypFWzaT2dUJMVfMjJhYC5fSd+MjONnR f3Te4BV8EDUmkRS5zrSEfZ45Mh+cC1dkeUDSGESfElE/WewI0WsOO87+nVJ4/Ydls016 sCJwxv84KUaSeB+NTmVcgSlrHwB5gg60WyPGR7JHa80VeqVfC8sSCuo3lAokqWkf8NVl Km9yAMcvNdlnIP8Tq90hpPy1sJD3UmiOFg0gbTe1/LzjxXEoRwp8I0EAOnFvENoT9o4B 02XjS2++ZI5M5bREdmEMi6qtsgYz7l/3Cp+MGVUynr/SF8+4EmlE76vGwd4IrqRvTf6v IMZw== X-Received: by 10.181.12.112 with SMTP id ep16mr15956837wid.38.1422121649859; Sat, 24 Jan 2015 09:47:29 -0800 (PST) Received: from linux-tdhb.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by mx.google.com with ESMTPSA id x10sm6675763wif.15.2015.01.24.09.47.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Jan 2015 09:47:28 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: Kalle Valo , linux-wireless@vger.kernel.org Cc: Hauke Mehrtens , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= Subject: [PATCH] bcma: simplify freeing cores (internal devices structs) Date: Sat, 24 Jan 2015 18:47:19 +0100 Message-Id: <1422121640-9227-1-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.8.4.5 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Rafa? Mi?ecki --- drivers/bcma/main.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index c3c5e0a..73b2ee3 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -368,12 +368,19 @@ static void bcma_unregister_cores(struct bcma_bus *bus) struct bcma_device *core, *tmp; list_for_each_entry_safe(core, tmp, &bus->cores, list) { + if (!core->dev_registered) + continue; list_del(&core->list); - if (core->dev_registered) - device_unregister(&core->dev); + device_unregister(&core->dev); } if (bus->hosttype == BCMA_HOSTTYPE_SOC) platform_device_unregister(bus->drv_cc.watchdog); + + /* Now noone uses internally-handled cores, we can free them */ + list_for_each_entry_safe(core, tmp, &bus->cores, list) { + list_del(&core->list); + kfree(core); + } } int bcma_bus_register(struct bcma_bus *bus) @@ -467,7 +474,6 @@ int bcma_bus_register(struct bcma_bus *bus) void bcma_bus_unregister(struct bcma_bus *bus) { - struct bcma_device *cores[3]; int err; err = bcma_gpio_unregister(&bus->drv_cc); @@ -478,15 +484,7 @@ void bcma_bus_unregister(struct bcma_bus *bus) bcma_core_chipcommon_b_free(&bus->drv_cc_b); - cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K); - cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE); - cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON); - bcma_unregister_cores(bus); - - kfree(cores[2]); - kfree(cores[1]); - kfree(cores[0]); } /*