From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 605BC1C0539 for ; Thu, 26 Apr 2018 08:33:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5738686D2C for ; Thu, 26 Apr 2018 08:33:21 +0000 (UTC) Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bZJzJMOrFvHk for ; Thu, 26 Apr 2018 08:33:16 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by whitealder.osuosl.org (Postfix) with ESMTPS id 5E4C386E39 for ; Thu, 26 Apr 2018 08:33:16 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id c14-v6so15725111wrd.4 for ; Thu, 26 Apr 2018 01:33:16 -0700 (PDT) From: Sergio Paracuellos Subject: [PATCH 2/4] staging: ks7010: move tx and rx queues definitions into ks_wlan.h header Date: Thu, 26 Apr 2018 10:33:07 +0200 Message-Id: <1524731589-8628-3-git-send-email-sergio.paracuellos@gmail.com> In-Reply-To: <1524731589-8628-1-git-send-email-sergio.paracuellos@gmail.com> References: <1524731589-8628-1-git-send-email-sergio.paracuellos@gmail.com> List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: gregkh@linuxfoundation.org Cc: driverdev-devel@linuxdriverproject.org, wsa@the-dreams.de There are some definitions for rx and tx queues in ks7010_sdio which is not the best place to put them. Changing them into the ks_wlan header file there is no need to explicity include ks7010_sdio.h which makes no sense at all and can be resolved easily using forward declarations. The functions related with the queues circular buffers have been moved also into this header. Signed-off-by: Sergio Paracuellos --- drivers/staging/ks7010/ks7010_sdio.c | 45 -------------- drivers/staging/ks7010/ks7010_sdio.h | 63 +------------------- drivers/staging/ks7010/ks_wlan.h | 112 ++++++++++++++++++++++++++++++++++- 3 files changed, 112 insertions(+), 108 deletions(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 6a5565d..9c22a76 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -8,7 +8,6 @@ */ #include -#include #include #include #include @@ -98,50 +97,6 @@ enum gen_com_reg_b { #define KS7010_IO_BLOCK_SIZE 512 -static inline void inc_txqhead(struct ks_wlan_private *priv) -{ - priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE; -} - -static inline void inc_txqtail(struct ks_wlan_private *priv) -{ - priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE; -} - -static inline bool txq_has_space(struct ks_wlan_private *priv) -{ - return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail, - TX_DEVICE_BUFF_SIZE) > 0); -} - -static inline void inc_rxqhead(struct ks_wlan_private *priv) -{ - priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE; -} - -static inline void inc_rxqtail(struct ks_wlan_private *priv) -{ - priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE; -} - -static inline bool rxq_has_space(struct ks_wlan_private *priv) -{ - return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail, - RX_DEVICE_BUFF_SIZE) > 0); -} - -static inline unsigned int txq_count(struct ks_wlan_private *priv) -{ - return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail, - TX_DEVICE_BUFF_SIZE); -} - -static inline unsigned int rxq_count(struct ks_wlan_private *priv) -{ - return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail, - RX_DEVICE_BUFF_SIZE); -} - /* Read single byte from device address into byte (CMD52) */ static int ks7010_sdio_readb(struct ks_wlan_private *priv, u32 address, u8 *byte) diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 831b2f1..891a09f 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -8,6 +8,8 @@ #ifndef _KS7010_SDIO_H #define _KS7010_SDIO_H +struct ks_wlan_private; + /** * struct ks_sdio_card - SDIO device data. * @@ -21,65 +23,4 @@ struct ks_sdio_card { struct ks_wlan_private *priv; }; -/* Tx Device struct */ -#define TX_DEVICE_BUFF_SIZE 1024 - -/** - * struct tx_device_buffer - Queue item for the tx queue. - * @sendp: Pointer to the send request data. - * @size: Size of @sendp data. - * @complete_handler: Function called once data write to device is complete. - * @arg1: First argument to @complete_handler. - * @arg2: Second argument to @complete_handler. - */ -struct tx_device_buffer { - unsigned char *sendp; - unsigned int size; - void (*complete_handler)(struct ks_wlan_private *priv, - struct sk_buff *skb); - struct sk_buff *skb; -}; - -/** - * struct tx_device - Tx buffer queue. - * @tx_device_buffer: Queue buffer. - * @qhead: Head of tx queue. - * @qtail: Tail of tx queue. - * @tx_dev_lock: Queue lock. - */ -struct tx_device { - struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; - unsigned int qhead; - unsigned int qtail; - spinlock_t tx_dev_lock; /* protect access to the queue */ -}; - -/* Rx Device struct */ -#define RX_DATA_SIZE (2 + 2 + 2347 + 1) -#define RX_DEVICE_BUFF_SIZE 32 - -/** - * struct rx_device_buffer - Queue item for the rx queue. - * @data: rx data. - * @size: Size of @data. - */ -struct rx_device_buffer { - unsigned char data[RX_DATA_SIZE]; - unsigned int size; -}; - -/** - * struct rx_device - Rx buffer queue. - * @rx_device_buffer: Queue buffer. - * @qhead: Head of rx queue. - * @qtail: Tail of rx queue. - * @rx_dev_lock: Queue lock. - */ -struct rx_device { - struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; - unsigned int qhead; - unsigned int qtail; - spinlock_t rx_dev_lock; /* protect access to the queue */ -}; - #endif /* _KS7010_SDIO_H */ diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 5070af8..d73f622 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -10,14 +10,13 @@ #define _KS_WLAN_H #include /* struct atomic_t */ +#include #include /* struct completion */ #include /* struct net_device_stats, struct sk_buff */ #include /* wait_queue_head_t */ #include /* spinlock_t */ #include -#include "ks7010_sdio.h" - struct ks_wlan_parameter { u8 operation_mode; /* Operation Mode */ u8 channel; /* Channel */ @@ -366,6 +365,71 @@ struct wps_status { u8 ie[255]; }; +/* Tx Device struct */ +#define TX_DEVICE_BUFF_SIZE 1024 + +struct ks_wlan_private; + +/** + * struct tx_device_buffer - Queue item for the tx queue. + * @sendp: Pointer to the send request data. + * @size: Size of @sendp data. + * @complete_handler: Function called once data write to device is complete. + * @arg1: First argument to @complete_handler. + * @arg2: Second argument to @complete_handler. + */ +struct tx_device_buffer { + unsigned char *sendp; + unsigned int size; + void (*complete_handler)(struct ks_wlan_private *priv, + struct sk_buff *skb); + struct sk_buff *skb; +}; + +/** + * struct tx_device - Tx buffer queue. + * @tx_device_buffer: Queue buffer. + * @qhead: Head of tx queue. + * @qtail: Tail of tx queue. + * @tx_dev_lock: Queue lock. + */ +struct tx_device { + struct tx_device_buffer tx_dev_buff[TX_DEVICE_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; + spinlock_t tx_dev_lock; /* protect access to the queue */ +}; + +/* Rx Device struct */ +#define RX_DATA_SIZE (2 + 2 + 2347 + 1) +#define RX_DEVICE_BUFF_SIZE 32 + +/** + * struct rx_device_buffer - Queue item for the rx queue. + * @data: rx data. + * @size: Size of @data. + */ +struct rx_device_buffer { + unsigned char data[RX_DATA_SIZE]; + unsigned int size; +}; + +/** + * struct rx_device - Rx buffer queue. + * @rx_device_buffer: Queue buffer. + * @qhead: Head of rx queue. + * @qtail: Tail of rx queue. + * @rx_dev_lock: Queue lock. + */ +struct rx_device { + struct rx_device_buffer rx_dev_buff[RX_DEVICE_BUFF_SIZE]; + unsigned int qhead; + unsigned int qtail; + 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; @@ -452,6 +516,50 @@ struct ks_wlan_private { uint wakeup_count; /* for detect wakeup loop */ }; +static inline void inc_txqhead(struct ks_wlan_private *priv) +{ + priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE; +} + +static inline void inc_txqtail(struct ks_wlan_private *priv) +{ + priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE; +} + +static inline bool txq_has_space(struct ks_wlan_private *priv) +{ + return (CIRC_SPACE(priv->tx_dev.qhead, priv->tx_dev.qtail, + TX_DEVICE_BUFF_SIZE) > 0); +} + +static inline void inc_rxqhead(struct ks_wlan_private *priv) +{ + priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE; +} + +static inline void inc_rxqtail(struct ks_wlan_private *priv) +{ + priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE; +} + +static inline bool rxq_has_space(struct ks_wlan_private *priv) +{ + return (CIRC_SPACE(priv->rx_dev.qhead, priv->rx_dev.qtail, + RX_DEVICE_BUFF_SIZE) > 0); +} + +static inline unsigned int txq_count(struct ks_wlan_private *priv) +{ + return CIRC_CNT_TO_END(priv->tx_dev.qhead, priv->tx_dev.qtail, + TX_DEVICE_BUFF_SIZE); +} + +static inline unsigned int rxq_count(struct ks_wlan_private *priv) +{ + return CIRC_CNT_TO_END(priv->rx_dev.qhead, priv->rx_dev.qtail, + RX_DEVICE_BUFF_SIZE); +} + int ks_wlan_net_start(struct net_device *dev); int ks_wlan_net_stop(struct net_device *dev); bool is_connect_status(u32 status); -- 2.7.4 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel