From patchwork Mon Oct 24 17:56:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 9392777 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 914DE60231 for ; Mon, 24 Oct 2016 17:57:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A8B62913D for ; Mon, 24 Oct 2016 17:57:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F658291D9; Mon, 24 Oct 2016 17:57:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FA8D2913D for ; Mon, 24 Oct 2016 17:57:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938480AbcJXR5P (ORCPT ); Mon, 24 Oct 2016 13:57:15 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:33988 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936498AbcJXR5L (ORCPT ); Mon, 24 Oct 2016 13:57:11 -0400 Received: by mail-pf0-f174.google.com with SMTP id r16so102812619pfg.1 for ; Mon, 24 Oct 2016 10:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4HCcXXRAMqSRf7/rzi8zaQxseL5YggVbIAenkc0t7Dw=; b=VOuVJzkcOpLV3T2WW/di5OOlvjNj+vKZjwfgsaALDPUjK0SoZvwdvFWWkVq2x7ABFv SToYrBUlZJm+EhYHGBN38/czi59VUAGGuPyU5FIvUgqsgqXYd6sI1wfHuyPI5CBWqkHv JGlX64EIm0R3mmkfLj0B0v2PWwqJLLTW3mkeDZrliNevfj9wj6Or3sxS1QupuR0q49qR I06eRAoAa5GRFu3v7LD8oYCeSxtlT4ZKaDCxPWQWwvR8/IRUUihslsZ2ZxmYUg/+OTUT ihROhh/N1S7aPyMNFKr8ySy8Cun+E1tlmd8Bhky2C9wqUcA5uk07h+wYIx0bFkJkU45s 6DCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4HCcXXRAMqSRf7/rzi8zaQxseL5YggVbIAenkc0t7Dw=; b=KNrrDAxf8GMpJWxSOjq6ZHsP7PyGDPD8lILvvcAvfY8DLfD0Oius+toJ+bjmQFY6ID GUCTxNCwwQ3/0ndaMvT99KEwV7OtDez64mDQgRrJwumjnqNSilrTVe3SPLyJF3uTI0+v /6Nhq+8MQThRSaZu2BkKuaJ0lCV4UKYvOALjAjldvLf17pEfUAGIjaNKN/bwYacNhkcV u3vpo5UY8ZKuCjmsSz1w6SvA86GwW6Er+NFZUdw49dqef6l+ZWbOR4aRxYpN3IF9jBHa eLoh5XJAbhaOuG+sZ4u0NPXVfV2Nglk1uyMoiblX1+fSrZ9CWcIPDcP1ypeqS92jnjwI 4bDw== X-Gm-Message-State: ABUngvepXF/+FDb3di9cJAvT0iq/iwCcfssB4a9vcjQYLmTTJ7xecj4BP0qeBp1oHfReIF7l X-Received: by 10.99.36.65 with SMTP id k62mr25349930pgk.88.1477331830459; Mon, 24 Oct 2016 10:57:10 -0700 (PDT) Received: from rajat.mtv.corp.google.com ([172.22.64.13]) by smtp.gmail.com with ESMTPSA id e74sm26996567pfk.13.2016.10.24.10.57.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Oct 2016 10:57:09 -0700 (PDT) From: Rajat Jain To: Amitkumar Karwar , Nishant Sarmukadam , Kalle Valo , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Xinming Hu Cc: Rajat Jain , Brian Norris , rajatxjain@gmail.com Subject: [PATCH 1/3] mwifiex: Allow mwifiex early access to device structure Date: Mon, 24 Oct 2016 10:56:51 -0700 Message-Id: <1477331813-42151-2-git-send-email-rajatja@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1477331813-42151-1-git-send-email-rajatja@google.com> References: <1477331813-42151-1-git-send-email-rajatja@google.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Today all the interface drivers (usb/pcie/sdio) assign the adapter->dev in the register_dev() callback, although they have this piece of info well before hand. This patch makes the device structure available for mwifiex right at the beginning, so that it can be used for early initialization if needed. This is needed for subsequent patches in this patchset that intend to unify and consolidate some of the code that would otherwise have to be duplicated among the interface drivers (sdio, pcie, usb). Signed-off-by: Rajat Jain --- drivers/net/wireless/marvell/mwifiex/main.c | 4 +++- drivers/net/wireless/marvell/mwifiex/main.h | 3 ++- drivers/net/wireless/marvell/mwifiex/pcie.c | 4 +--- drivers/net/wireless/marvell/mwifiex/sdio.c | 5 +---- drivers/net/wireless/marvell/mwifiex/usb.c | 3 +-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index 2478ccd..dcceab2 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -1567,7 +1567,8 @@ EXPORT_SYMBOL_GPL(mwifiex_do_flr); */ int mwifiex_add_card(void *card, struct semaphore *sem, - struct mwifiex_if_ops *if_ops, u8 iface_type) + struct mwifiex_if_ops *if_ops, u8 iface_type, + struct device *dev) { struct mwifiex_adapter *adapter; @@ -1579,6 +1580,7 @@ mwifiex_add_card(void *card, struct semaphore *sem, goto err_init_sw; } + adapter->dev = dev; adapter->iface_type = iface_type; adapter->card_sem = sem; diff --git a/drivers/net/wireless/marvell/mwifiex/main.h b/drivers/net/wireless/marvell/mwifiex/main.h index 26df28f..91218a1 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.h +++ b/drivers/net/wireless/marvell/mwifiex/main.h @@ -1411,7 +1411,8 @@ static inline u8 mwifiex_is_tdls_link_setup(u8 status) int mwifiex_init_shutdown_fw(struct mwifiex_private *priv, u32 func_init_shutdown); -int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8); +int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8, + struct device *); int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *); void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version, diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index f7c84d3..49b5835 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -224,7 +224,7 @@ static int mwifiex_pcie_probe(struct pci_dev *pdev, } ret = mwifiex_add_card(card, &add_remove_card_sem, &pcie_ops, - MWIFIEX_PCIE); + MWIFIEX_PCIE, &pdev->dev); if (ret) { pr_err("%s failed\n", __func__); goto err_free; @@ -2990,11 +2990,9 @@ static void mwifiex_pcie_get_fw_name(struct mwifiex_adapter *adapter) static int mwifiex_register_dev(struct mwifiex_adapter *adapter) { struct pcie_service_card *card = adapter->card; - struct pci_dev *pdev = card->dev; /* save adapter pointer in card */ card->adapter = adapter; - adapter->dev = &pdev->dev; if (mwifiex_pcie_request_irq(adapter)) return -1; diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index 807af13..c95f41f 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -206,7 +206,7 @@ mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) } ret = mwifiex_add_card(card, &add_remove_card_sem, &sdio_ops, - MWIFIEX_SDIO); + MWIFIEX_SDIO, &func->dev); if (ret) { dev_err(&func->dev, "add card failed\n"); goto err_disable; @@ -2106,9 +2106,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) return ret; } - - adapter->dev = &func->dev; - strcpy(adapter->fw_name, card->firmware); if (card->fw_dump_enh) { adapter->mem_type_mapping_tbl = generic_mem_type_map; diff --git a/drivers/net/wireless/marvell/mwifiex/usb.c b/drivers/net/wireless/marvell/mwifiex/usb.c index 73eb084..f847fff 100644 --- a/drivers/net/wireless/marvell/mwifiex/usb.c +++ b/drivers/net/wireless/marvell/mwifiex/usb.c @@ -476,7 +476,7 @@ static int mwifiex_usb_probe(struct usb_interface *intf, usb_set_intfdata(intf, card); ret = mwifiex_add_card(card, &add_remove_card_sem, &usb_ops, - MWIFIEX_USB); + MWIFIEX_USB, &card->udev->dev); if (ret) { pr_err("%s: mwifiex_add_card failed: %d\n", __func__, ret); usb_reset_device(udev); @@ -932,7 +932,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) struct usb_card_rec *card = (struct usb_card_rec *)adapter->card; card->adapter = adapter; - adapter->dev = &card->udev->dev; switch (le16_to_cpu(card->udev->descriptor.idProduct)) { case USB8997_PID_1: