Commit 07511629 authored by Sergio Paracuellos's avatar Sergio Paracuellos Committed by Greg Kroah-Hartman

staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header

ks_wlan_private struct has a pointer to struct ks_sdio_card in its
fields. Because of that a forward declaration in needed in ks_wlan.h
header and also it makes necessary to have ks_sdio_card public in
a ks7010_sdio.h header. Changing this pointer into a void pointer
makes no longer necessary to have ks7010_sdio.h header as well as
removes the forward dependency in ks_wlan.h. Declaration of
ks_sdio_card has been moved to ks7010_sdio.c source file and To make
code cleaner inside this file a new ks7010_to_func function has been
added. The code has been updated to this changes.
Signed-off-by: default avatarSergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 57c6f08d
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include "ks_wlan.h" #include "ks_wlan.h"
#include "ks_hostif.h" #include "ks_hostif.h"
#include "ks7010_sdio.h"
#define ROM_FILE "ks7010sd.rom" #define ROM_FILE "ks7010sd.rom"
...@@ -97,11 +96,31 @@ enum gen_com_reg_b { ...@@ -97,11 +96,31 @@ enum gen_com_reg_b {
#define KS7010_IO_BLOCK_SIZE 512 #define KS7010_IO_BLOCK_SIZE 512
/**
* struct ks_sdio_card - SDIO device data.
*
* Structure is used as the &struct sdio_func private data.
*
* @func: Pointer to the SDIO function device.
* @priv: Pointer to the &struct net_device private data.
*/
struct ks_sdio_card {
struct sdio_func *func;
struct ks_wlan_private *priv;
};
static struct sdio_func *ks7010_to_func(struct ks_wlan_private *priv)
{
struct ks_sdio_card *ks_sdio = priv->if_hw;
return ks_sdio->func;
}
/* Read single byte from device address into byte (CMD52) */ /* Read single byte from device address into byte (CMD52) */
static int ks7010_sdio_readb(struct ks_wlan_private *priv, static int ks7010_sdio_readb(struct ks_wlan_private *priv,
u32 address, u8 *byte) u32 address, u8 *byte)
{ {
struct sdio_func *func = priv->ks_sdio_card->func; struct sdio_func *func = ks7010_to_func(priv);
int ret; int ret;
*byte = sdio_readb(func, address, &ret); *byte = sdio_readb(func, address, &ret);
...@@ -113,7 +132,7 @@ static int ks7010_sdio_readb(struct ks_wlan_private *priv, ...@@ -113,7 +132,7 @@ static int ks7010_sdio_readb(struct ks_wlan_private *priv,
static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address, static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address,
u8 *buffer, unsigned int length) u8 *buffer, unsigned int length)
{ {
struct sdio_func *func = priv->ks_sdio_card->func; struct sdio_func *func = ks7010_to_func(priv);
return sdio_memcpy_fromio(func, buffer, address, length); return sdio_memcpy_fromio(func, buffer, address, length);
} }
...@@ -122,7 +141,7 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address, ...@@ -122,7 +141,7 @@ static int ks7010_sdio_read(struct ks_wlan_private *priv, u32 address,
static int ks7010_sdio_writeb(struct ks_wlan_private *priv, static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
u32 address, u8 byte) u32 address, u8 byte)
{ {
struct sdio_func *func = priv->ks_sdio_card->func; struct sdio_func *func = ks7010_to_func(priv);
int ret; int ret;
sdio_writeb(func, byte, address, &ret); sdio_writeb(func, byte, address, &ret);
...@@ -134,7 +153,7 @@ static int ks7010_sdio_writeb(struct ks_wlan_private *priv, ...@@ -134,7 +153,7 @@ static int ks7010_sdio_writeb(struct ks_wlan_private *priv,
static int ks7010_sdio_write(struct ks_wlan_private *priv, u32 address, static int ks7010_sdio_write(struct ks_wlan_private *priv, u32 address,
u8 *buffer, unsigned int length) u8 *buffer, unsigned int length)
{ {
struct sdio_func *func = priv->ks_sdio_card->func; struct sdio_func *func = ks7010_to_func(priv);
return sdio_memcpy_toio(func, address, buffer, length); return sdio_memcpy_toio(func, address, buffer, length);
} }
...@@ -449,12 +468,13 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, uint16_t size) ...@@ -449,12 +468,13 @@ static void ks_wlan_hw_rx(struct ks_wlan_private *priv, uint16_t size)
static void ks7010_rw_function(struct work_struct *work) static void ks7010_rw_function(struct work_struct *work)
{ {
struct ks_wlan_private *priv; struct ks_wlan_private *priv = container_of(work,
struct ks_wlan_private,
rw_dwork.work);
struct sdio_func *func = ks7010_to_func(priv);
unsigned char byte; unsigned char byte;
int ret; int ret;
priv = container_of(work, struct ks_wlan_private, rw_dwork.work);
/* wait after DOZE */ /* wait after DOZE */
if (time_after(priv->last_doze + msecs_to_jiffies(30), jiffies)) { if (time_after(priv->last_doze + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after DOZE\n"); netdev_dbg(priv->net_dev, "wait after DOZE\n");
...@@ -465,13 +485,12 @@ static void ks7010_rw_function(struct work_struct *work) ...@@ -465,13 +485,12 @@ static void ks7010_rw_function(struct work_struct *work)
/* wait after WAKEUP */ /* wait after WAKEUP */
while (time_after(priv->last_wakeup + msecs_to_jiffies(30), jiffies)) { while (time_after(priv->last_wakeup + msecs_to_jiffies(30), jiffies)) {
netdev_dbg(priv->net_dev, "wait after WAKEUP\n"); netdev_dbg(priv->net_dev, "wait after WAKEUP\n");
dev_info(&priv->ks_sdio_card->func->dev, dev_info(&func->dev, "wake: %lu %lu\n",
"wake: %lu %lu\n",
priv->last_wakeup + msecs_to_jiffies(30), jiffies); priv->last_wakeup + msecs_to_jiffies(30), jiffies);
msleep(30); msleep(30);
} }
sdio_claim_host(priv->ks_sdio_card->func); sdio_claim_host(func);
/* power save wakeup */ /* power save wakeup */
if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) { if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
...@@ -510,7 +529,7 @@ static void ks7010_rw_function(struct work_struct *work) ...@@ -510,7 +529,7 @@ static void ks7010_rw_function(struct work_struct *work)
_ks_wlan_hw_power_save(priv); _ks_wlan_hw_power_save(priv);
release_host: release_host:
sdio_release_host(priv->ks_sdio_card->func); sdio_release_host(func);
} }
static void ks_sdio_interrupt(struct sdio_func *func) static void ks_sdio_interrupt(struct sdio_func *func)
...@@ -726,13 +745,14 @@ static int ks7010_copy_firmware(struct ks_wlan_private *priv, ...@@ -726,13 +745,14 @@ static int ks7010_copy_firmware(struct ks_wlan_private *priv,
static int ks7010_upload_firmware(struct ks_sdio_card *card) static int ks7010_upload_firmware(struct ks_sdio_card *card)
{ {
struct ks_wlan_private *priv = card->priv; struct ks_wlan_private *priv = card->priv;
struct sdio_func *func = ks7010_to_func(priv);
unsigned int n; unsigned int n;
unsigned char byte = 0; unsigned char byte = 0;
int ret; int ret;
const struct firmware *fw_entry = NULL; const struct firmware *fw_entry = NULL;
sdio_claim_host(card->func); sdio_claim_host(func);
/* Firmware running ? */ /* Firmware running ? */
ret = ks7010_sdio_readb(priv, GCR_A_REG, &byte); ret = ks7010_sdio_readb(priv, GCR_A_REG, &byte);
...@@ -745,7 +765,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card) ...@@ -745,7 +765,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
} }
ret = request_firmware(&fw_entry, ROM_FILE, ret = request_firmware(&fw_entry, ROM_FILE,
&priv->ks_sdio_card->func->dev); &func->dev);
if (ret) if (ret)
goto release_host; goto release_host;
...@@ -774,7 +794,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card) ...@@ -774,7 +794,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
release_firmware: release_firmware:
release_firmware(fw_entry); release_firmware(fw_entry);
release_host: release_host:
sdio_release_host(card->func); sdio_release_host(func);
return ret; return ret;
} }
...@@ -907,7 +927,7 @@ static void ks7010_private_init(struct ks_wlan_private *priv, ...@@ -907,7 +927,7 @@ static void ks7010_private_init(struct ks_wlan_private *priv,
struct net_device *netdev) struct net_device *netdev)
{ {
/* private memory initialize */ /* private memory initialize */
priv->ks_sdio_card = card; priv->if_hw = card;
priv->dev_state = DEVICE_STATE_PREBOOT; priv->dev_state = DEVICE_STATE_PREBOOT;
priv->net_dev = netdev; priv->net_dev = netdev;
......
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Driver for KeyStream, KS7010 based SDIO cards.
*
* Copyright (C) 2006-2008 KeyStream Corp.
* Copyright (C) 2009 Renesas Technology Corp.
*/
#ifndef _KS7010_SDIO_H
#define _KS7010_SDIO_H
struct ks_wlan_private;
/**
* struct ks_sdio_card - SDIO device data.
*
* Structure is used as the &struct sdio_func private data.
*
* @func: Pointer to the SDIO function device.
* @priv: Pointer to the &struct net_device private data.
*/
struct ks_sdio_card {
struct sdio_func *func;
struct ks_wlan_private *priv;
};
#endif /* _KS7010_SDIO_H */
...@@ -428,11 +428,9 @@ struct rx_device { ...@@ -428,11 +428,9 @@ struct rx_device {
spinlock_t rx_dev_lock; /* protect access to the queue */ spinlock_t rx_dev_lock; /* protect access to the queue */
}; };
struct ks_sdio_card;
struct ks_wlan_private { struct ks_wlan_private {
/* hardware information */ /* hardware information */
struct ks_sdio_card *ks_sdio_card; void *if_hw;
struct workqueue_struct *wq; struct workqueue_struct *wq;
struct delayed_work rw_dwork; struct delayed_work rw_dwork;
struct tasklet_struct rx_bh_task; struct tasklet_struct rx_bh_task;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment