From patchwork Mon Apr 13 09:18:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Fenkart X-Patchwork-Id: 6206741 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 8ABB89F313 for ; Mon, 13 Apr 2015 09:18:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AABF72021F for ; Mon, 13 Apr 2015 09:18:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C618A201BB for ; Mon, 13 Apr 2015 09:18:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753557AbbDMJSa (ORCPT ); Mon, 13 Apr 2015 05:18:30 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:35737 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753415AbbDMJSa (ORCPT ); Mon, 13 Apr 2015 05:18:30 -0400 Received: by wgyo15 with SMTP id o15so73900740wgy.2 for ; Mon, 13 Apr 2015 02:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=avVXZmksAORv9HMZbwly3aqFugDlpamKIpDYp+PZ9I4=; b=ADF1YsqI6XUdwjsJFynLz56jlxuCs11HvJzcKfCpuz3WuQWHSjHVrFrXIQ1SZ6j/2I 9CFQHv/eirrz8gri7BDBKkSfD/KSnJQwlr0qiM+0Qc51HIVUIIlcFJsAwSEz4GStDrXG O3IkFvJh9kax1adrDxolBf8NBwE4pdK047Fb2OzjuavHvoP/9wkcW0wGaJrUOw+N/Le5 SQC4SWE6uSAL7ulkLR5/uVJfXbeCe1Lp+ycCZv8JHXYttrR0idwjLlaMAuUbNz5pNlhj p7DPRJ6r3YShl9WaDJgDRHrNcUWOX55+MMceYq87oPwokRN88dkPp7+tNrWgoiBCJuTx LpLw== X-Received: by 10.194.187.41 with SMTP id fp9mr26309654wjc.58.1428916709092; Mon, 13 Apr 2015 02:18:29 -0700 (PDT) Received: from localhost (ip-94-112-1-170.net.upcbroadband.cz. [94.112.1.170]) by mx.google.com with ESMTPSA id w8sm10605159wja.4.2015.04.13.02.18.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 02:18:28 -0700 (PDT) From: Andreas Fenkart To: linux-wireless@vger.kernel.org Cc: Amitkumar Karwar , Avinash Patil , Andreas Fenkart Subject: [PATCH 1/2] mwifiex: sdio: create global list of adapters Date: Mon, 13 Apr 2015 11:18:23 +0200 Message-Id: <1428916704-9635-1-git-send-email-afenkart@gmail.com> X-Mailer: git-send-email 2.1.4 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 we need to verify that a an adapter pointer, still points to a valid adapter. this is not possible through other global structures, such as net_namespace_list. the problem with the net_namespace_list is that an adapter can have multiple interfaces, hence we had to de-reference the maybe invalid pointer to get the interface struct. Signed-off-by: Andreas Fenkart --- drivers/net/wireless/mwifiex/sdio.c | 14 ++++++++++++++ drivers/net/wireless/mwifiex/sdio.h | 1 + 2 files changed, 15 insertions(+) diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 91e36cd..a70e114 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -69,6 +69,12 @@ static struct memory_type_mapping mem_type_mapping_tbl[] = { }; /* + * list of active cards + */ +static LIST_HEAD(cards); +static DEFINE_MUTEX(cards_mutex); + +/* * SDIO probe. * * This function probes an mwifiex device and registers it. It allocates @@ -130,6 +136,10 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) ret = -1; } + mutex_lock(&cards_mutex); + list_add(&card->next, &cards); + mutex_unlock(&cards_mutex); + return ret; } @@ -196,6 +206,10 @@ mwifiex_sdio_remove(struct sdio_func *func) if (!card) return; + mutex_lock(&cards_mutex); + list_del(&card->next); + mutex_unlock(&cards_mutex); + adapter = card->adapter; if (!adapter || !adapter->priv_num) return; diff --git a/drivers/net/wireless/mwifiex/sdio.h b/drivers/net/wireless/mwifiex/sdio.h index 957cca2..9be5650 100644 --- a/drivers/net/wireless/mwifiex/sdio.h +++ b/drivers/net/wireless/mwifiex/sdio.h @@ -260,6 +260,7 @@ struct sdio_mmc_card { struct mwifiex_sdio_mpa_tx mpa_tx; struct mwifiex_sdio_mpa_rx mpa_rx; + struct list_head next; }; struct mwifiex_sdio_device {