All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: gregkh@linuxfoundation.org
Cc: driverdev-devel@linuxdriverproject.org, wsa@the-dreams.de
Subject: [PATCH 3/4] staging: ks7010: avoid ks_sdio_card dependency in ks_wlan header
Date: Thu, 26 Apr 2018 10:33:08 +0200	[thread overview]
Message-ID: <1524731589-8628-4-git-send-email-sergio.paracuellos@gmail.com> (raw)
In-Reply-To: <1524731589-8628-1-git-send-email-sergio.paracuellos@gmail.com>

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: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 52 +++++++++++++++++++++++++-----------
 drivers/staging/ks7010/ks7010_sdio.h | 26 ------------------
 drivers/staging/ks7010/ks_wlan.h     |  4 +--
 3 files changed, 37 insertions(+), 45 deletions(-)
 delete mode 100644 drivers/staging/ks7010/ks7010_sdio.h

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 9c22a76..d71c826 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -16,7 +16,6 @@
 #include <linux/workqueue.h>
 #include "ks_wlan.h"
 #include "ks_hostif.h"
-#include "ks7010_sdio.h"
 
 #define ROM_FILE "ks7010sd.rom"
 
@@ -97,11 +96,31 @@ enum gen_com_reg_b {
 
 #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) */
 static int ks7010_sdio_readb(struct ks_wlan_private *priv,
 			     u32 address, u8 *byte)
 {
-	struct sdio_func *func = priv->ks_sdio_card->func;
+	struct sdio_func *func = ks7010_to_func(priv);
 	int ret;
 
 	*byte = sdio_readb(func, address, &ret);
@@ -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,
 			    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);
 }
@@ -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,
 			      u32 address, u8 byte)
 {
-	struct sdio_func *func = priv->ks_sdio_card->func;
+	struct sdio_func *func = ks7010_to_func(priv);
 	int ret;
 
 	sdio_writeb(func, byte, address, &ret);
@@ -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,
 			     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);
 }
@@ -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)
 {
-	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;
 	int ret;
 
-	priv = container_of(work, struct ks_wlan_private, rw_dwork.work);
-
 	/* wait after DOZE */
 	if (time_after(priv->last_doze + msecs_to_jiffies(30), jiffies)) {
 		netdev_dbg(priv->net_dev, "wait after DOZE\n");
@@ -465,13 +485,12 @@ static void ks7010_rw_function(struct work_struct *work)
 	/* wait after WAKEUP */
 	while (time_after(priv->last_wakeup + msecs_to_jiffies(30), jiffies)) {
 		netdev_dbg(priv->net_dev, "wait after WAKEUP\n");
-		dev_info(&priv->ks_sdio_card->func->dev,
-			 "wake: %lu %lu\n",
+		dev_info(&func->dev, "wake: %lu %lu\n",
 			 priv->last_wakeup + msecs_to_jiffies(30), jiffies);
 		msleep(30);
 	}
 
-	sdio_claim_host(priv->ks_sdio_card->func);
+	sdio_claim_host(func);
 
 	/* power save wakeup */
 	if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
@@ -510,7 +529,7 @@ static void ks7010_rw_function(struct work_struct *work)
 	_ks_wlan_hw_power_save(priv);
 
 release_host:
-	sdio_release_host(priv->ks_sdio_card->func);
+	sdio_release_host(func);
 }
 
 static void ks_sdio_interrupt(struct sdio_func *func)
@@ -726,13 +745,14 @@ static int ks7010_copy_firmware(struct ks_wlan_private *priv,
 static int ks7010_upload_firmware(struct ks_sdio_card *card)
 {
 	struct ks_wlan_private *priv = card->priv;
+	struct sdio_func *func = ks7010_to_func(priv);
 	unsigned int n;
 	unsigned char byte = 0;
 	int ret;
 	const struct firmware *fw_entry = NULL;
 
 
-	sdio_claim_host(card->func);
+	sdio_claim_host(func);
 
 	/* Firmware running ? */
 	ret = ks7010_sdio_readb(priv, GCR_A_REG, &byte);
@@ -745,7 +765,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
 	}
 
 	ret = request_firmware(&fw_entry, ROM_FILE,
-			       &priv->ks_sdio_card->func->dev);
+			       &func->dev);
 	if (ret)
 		goto release_host;
 
@@ -774,7 +794,7 @@ static int ks7010_upload_firmware(struct ks_sdio_card *card)
  release_firmware:
 	release_firmware(fw_entry);
  release_host:
-	sdio_release_host(card->func);
+	sdio_release_host(func);
 
 	return ret;
 }
@@ -907,7 +927,7 @@ static void ks7010_private_init(struct ks_wlan_private *priv,
 				struct net_device *netdev)
 {
 	/* private memory initialize */
-	priv->ks_sdio_card = card;
+	priv->if_hw = card;
 
 	priv->dev_state = DEVICE_STATE_PREBOOT;
 	priv->net_dev = netdev;
diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h
deleted file mode 100644
index 891a09f..0000000
--- a/drivers/staging/ks7010/ks7010_sdio.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* 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 */
diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h
index d73f622..ad349ef 100644
--- a/drivers/staging/ks7010/ks_wlan.h
+++ b/drivers/staging/ks7010/ks_wlan.h
@@ -428,11 +428,9 @@ struct rx_device {
 	spinlock_t rx_dev_lock;	/* protect access to the queue */
 };
 
-struct ks_sdio_card;
-
 struct ks_wlan_private {
 	/* hardware information */
-	struct ks_sdio_card *ks_sdio_card;
+	void *if_hw;
 	struct workqueue_struct *wq;
 	struct delayed_work rw_dwork;
 	struct tasklet_struct rx_bh_task;
-- 
2.7.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  parent reply	other threads:[~2018-04-26  8:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26  8:33 [PATCH 0/4] staging: ks7010: next cleanups Sergio Paracuellos
2018-04-26  8:33 ` [PATCH 1/4] staging: ks7010: add SPDX identifiers to all files Sergio Paracuellos
2018-04-26  8:33 ` [PATCH 2/4] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header Sergio Paracuellos
2018-04-26  8:33 ` Sergio Paracuellos [this message]
2018-04-26  8:33 ` [PATCH 4/4] staging: ks7010: change netdev_dbg msg to avoid a long line Sergio Paracuellos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524731589-8628-4-git-send-email-sergio.paracuellos@gmail.com \
    --to=sergio.paracuellos@gmail.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.