From patchwork Tue Oct 20 22:47:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7453271 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 31D7B9F302 for ; Tue, 20 Oct 2015 22:51:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3195F20881 for ; Tue, 20 Oct 2015 22:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22A582083A for ; Tue, 20 Oct 2015 22:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753171AbbJTWuV (ORCPT ); Tue, 20 Oct 2015 18:50:21 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:50930 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754429AbbJTWsP (ORCPT ); Tue, 20 Oct 2015 18:48:15 -0400 Received: from wuerfel.lan. ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0LzHnN-1abBoO1VQn-014QIe; Wed, 21 Oct 2015 00:48:09 +0200 From: Arnd Bergmann To: linux-wireless@vger.kernel.org Cc: Rachel Kim , devel@driverdev.osuosl.org, Chris Park , gregkh@linuxfoundation.org, Stanislav Kholmanskikh , Johnny Kim , linux-kernel@vger.kernel.org, Tony Cho , Glen Lee , Leo Kim , Arnd Bergmann Subject: [PATCH 10/19] staging/wilc1000: unify device pointer Date: Wed, 21 Oct 2015 00:47:29 +0200 Message-Id: <1445381258-1455986-11-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.1.0.rc2 In-Reply-To: <1445381258-1455986-1-git-send-email-arnd@arndb.de> References: <1445381258-1455986-1-git-send-email-arnd@arndb.de> X-Provags-ID: V03:K0:IQ54DdzSK4vhEWP4KprzbvzAKC/wCi9ugywz7omOEU6suX56Dmc BkNnLUN/1HUyvR4Qq4Xz3rUKk3k8scQ0lnI0/iBD/KttLxiLYMDPSVVrvvlplihbxozQqVp nlMpyTXA+jZUpQ2xItnEM2vloGwvQ2N+PEIfJEuOdnd6ruy2KRiUSxsGSOVMMc6g4jy3aqP IR9irRr2NIiAx9VqWI8kQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:cKtAn/imc1E=:0+Fl5K0b69zxsEp8Jpp2BI d3I4glzEiIevNVrRjT/UNLaJsJcCE4ccvsL0tIQ3zbLmSDzeSnG15hOnNZdAEFDa51UGXkwTd lmGCoD6jVs+CD0pQ/we/yQQ209zYETimP4AqAeUbNw8+j3gSSja8PqffaC1K0vaW2KBFmpH/C c+nqC2EYJZbFB0oSpQDuCbonwGdj4jz8gTGuY8/1qEwfKi9xdsctljtsnvCq3ittDoYHAHFKM dlxiEWUIPoX9zdqgX0gUZ1QiBt57Ioy4yAKjysMUPE1OKk6DKNQf7oqBhoxbzcAm6JTAax/Mn VvN3jBuqFRNSPC3rpUMtvGmn18eA9XERKkNCyLzz5vDfvMEuq2N+slObJeK07NQUs4So4vRB7 DqhZHAXF5G1gMXWXQQCUOk75Og4WZu/DNSBiELX8IjHnkRIrehkeYZj33z1+mOVr3VRN5uoFS JL24i5gOHLeWB4qcTbuqpyjcrux1Vsxt1XAuNm4lpWeOMVru3Nfqeh+lnDgaWCCqHGtdAPbnq HLg7mgeRwhwV02BWHr2gdBwXs443wK86uaEaJ2XvuxTFFb7GL3DS17dwuo6AJLHMNYT5XIVkA 8p9pocPT6FiO1+pMj/hnqxGFyuutWgDkEzUk3+3O9N2iP2PvhqUvZ1Vpt4+ie+J1uZqycELWc ZAwNvZ7XXJhFiK3J5z17TBft1N8lrnQi2zb+WzvoaDJUKYEUExD8o+kiiishgD/Sn7hQ= 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 struct wilc has two pointers to store the device, one for sdio_func and one for spi_device. By changing the pointer to a 'struct device', we can simplify the logic and avoid a few #ifdefs. Signed-off-by: Arnd Bergmann --- drivers/staging/wilc1000/linux_wlan.c | 29 +++++---------------------- drivers/staging/wilc1000/linux_wlan_sdio.c | 5 +++-- drivers/staging/wilc1000/linux_wlan_spi.c | 17 +++++++++++++++- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 6 +----- 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index caa85442c12d..4ca045bcf537 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -474,19 +474,11 @@ int wilc1000_wlan_get_firmware(perInterface_wlan_t *p_nic) /* the firmare should be located in /lib/firmware in * root file system with the name specified above */ -#ifdef WILC_SDIO - if (request_firmware(&wilc_firmware, firmware, &wilc1000_dev->wilc_sdio_func->dev) != 0) { + if (request_firmware(&wilc_firmware, firmware, wilc1000_dev->dev) != 0) { PRINT_ER("%s - firmare not available\n", firmware); ret = -1; goto _fail_; } -#else - if (request_firmware(&wilc_firmware, firmware, &wilc1000_dev->wilc_spidev->dev) != 0) { - PRINT_ER("%s - firmare not available\n", firmware); - ret = -1; - goto _fail_; - } -#endif wilc1000_dev->wilc_firmware = wilc_firmware; _fail_: @@ -1008,7 +1000,7 @@ static u8 wilc1000_prepare_11b_core(struct wilc *nic) while (!wilc1000_probe) msleep(100); wilc1000_probe = 0; - wilc1000_dev->wilc_sdio_func = wilc1000_sdio_func; + wilc1000_dev->dev = &wilc1000_sdio_func->dev; nic->ops = &wilc1000_sdio_ops; wilc_wlan_init(nic); } @@ -1031,7 +1023,7 @@ static int repeat_power_cycle(perInterface_wlan_t *nic) while (!wilc1000_probe) msleep(100); wilc1000_probe = 0; - wilc1000_dev->wilc_sdio_func = wilc1000_sdio_func; + wilc1000_dev->dev = &wilc1000_sdio_func->dev; wilc1000_dev->ops = &wilc1000_sdio_ops; ret = wilc_wlan_init(wilc1000_dev); @@ -1214,12 +1206,11 @@ int wilc1000_mac_open(struct net_device *ndev) int i = 0; struct wilc_priv *priv; -#ifdef WILC_SPI - if (!wilc1000_dev || !wilc1000_dev->wilc_spidev) { + if (!wilc1000_dev || !wilc1000_dev->dev) { netdev_err(ndev, "wilc1000: SPI device not ready\n"); return -ENODEV; } -#endif + nic = netdev_priv(ndev); priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev); @@ -1712,16 +1703,6 @@ int wilc_netdev_init(void) } - #ifndef WILC_SDIO - if (!wilc1000_spi_init(&wilc1000_dev->wilc_spidev)) { - PRINT_ER("Can't initialize SPI\n"); - return -1; /* ERROR */ - } - wilc1000_dev->wilc_spidev = wilc_spi_dev; - #else - wilc1000_dev->wilc_sdio_func = wilc1000_sdio_func; - #endif - return 0; } diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c index badcae57875c..a6ae26739dd8 100644 --- a/drivers/staging/wilc1000/linux_wlan_sdio.c +++ b/drivers/staging/wilc1000/linux_wlan_sdio.c @@ -46,7 +46,7 @@ static void wilc_sdio_interrupt(struct sdio_func *func) int wilc1000_sdio_cmd52(sdio_cmd52_t *cmd) { - struct sdio_func *func = wilc1000_dev->wilc_sdio_func; + struct sdio_func *func = container_of(wilc1000_dev->dev, struct sdio_func, dev); int ret; u8 data; @@ -78,7 +78,7 @@ int wilc1000_sdio_cmd52(sdio_cmd52_t *cmd) int wilc1000_sdio_cmd53(sdio_cmd53_t *cmd) { - struct sdio_func *func = wilc1000_dev->wilc_sdio_func; + struct sdio_func *func = container_of(wilc1000_dev->dev, struct sdio_func, dev); int size, ret; sdio_claim_host(func); @@ -126,6 +126,7 @@ static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id PRINT_ER("Couldn't initialize netdev\n"); return -1; } + wilc1000_dev->dev = &wilc1000_sdio_func->dev; printk("Driver Initializing success\n"); return 0; diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c index c90b741824dc..b5e9a1b9f509 100644 --- a/drivers/staging/wilc1000/linux_wlan_spi.c +++ b/drivers/staging/wilc1000/linux_wlan_spi.c @@ -9,8 +9,11 @@ #include #include +#include "wilc_wfi_netdevice.h" #include "linux_wlan_common.h" #include "linux_wlan_spi.h" +#include "wilc_wlan_if.h" +#include "wilc_wlan.h" #define USE_SPI_DMA 0 /* johnny add */ @@ -409,8 +412,20 @@ int wilc1000_spi_set_max_speed(void) static int __init init_wilc_spi_driver(void) { + int ret; + wilc1000_init_driver(); - return wilc_netdev_init(); + ret = wilc_netdev_init(); + if (ret) + return ret; + + if (!wilc1000_spi_init(NULL)) { + PRINT_ER("Can't initialize SPI\n"); + return -ENXIO; + } + wilc1000_dev->dev = &wilc_spi_dev->dev; + + return ret; } late_initcall(init_wilc_spi_driver); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 485df4768e78..1e5e7dcee11d 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -185,11 +185,7 @@ struct wilc { const struct firmware *wilc_firmware; -#ifdef WILC_SDIO - struct sdio_func *wilc_sdio_func; -#else - struct spi_device *wilc_spidev; -#endif + struct device *dev; }; typedef struct {