Commit a2ce952c authored by Prameela Rani Garnepudi's avatar Prameela Rani Garnepudi Committed by Kalle Valo

rsi: Add host interface operations as separate structure.

Host interface operations are currently function pointers in rsi_hw
structure. As more host interface operations are going to be introduced,
separate structure is added for these for convenience.
Signed-off-by: default avatarPrameela Rani Garnepudi <prameela.j04cs@gmail.com>
Signed-off-by: default avatarAmitkumar Karwar <amit.karwar@redpinesignals.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 88fa51e1
...@@ -100,9 +100,8 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb) ...@@ -100,9 +100,8 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb)
(skb->priority & 0xf) | (skb->priority & 0xf) |
(tx_params->sta_id << 8)); (tx_params->sta_id << 8));
status = adapter->host_intf_write_pkt(common->priv, status = adapter->host_intf_ops->write_pkt(common->priv, skb->data,
skb->data, skb->len);
skb->len);
if (status) if (status)
rsi_dbg(ERR_ZONE, "%s: Failed to write pkt\n", rsi_dbg(ERR_ZONE, "%s: Failed to write pkt\n",
__func__); __func__);
...@@ -148,9 +147,9 @@ int rsi_send_mgmt_pkt(struct rsi_common *common, ...@@ -148,9 +147,9 @@ int rsi_send_mgmt_pkt(struct rsi_common *common,
} }
skb_push(skb, extnd_size); skb_push(skb, extnd_size);
skb->data[extnd_size + 4] = extnd_size; skb->data[extnd_size + 4] = extnd_size;
status = adapter->host_intf_write_pkt(common->priv, status = adapter->host_intf_ops->write_pkt(common->priv,
(u8 *)skb->data, (u8 *)skb->data,
skb->len); skb->len);
if (status) { if (status) {
rsi_dbg(ERR_ZONE, rsi_dbg(ERR_ZONE,
"%s: Failed to write the packet\n", __func__); "%s: Failed to write the packet\n", __func__);
...@@ -203,9 +202,8 @@ int rsi_send_mgmt_pkt(struct rsi_common *common, ...@@ -203,9 +202,8 @@ int rsi_send_mgmt_pkt(struct rsi_common *common,
msg[7] |= cpu_to_le16(vap_id << 8); msg[7] |= cpu_to_le16(vap_id << 8);
status = adapter->host_intf_write_pkt(common->priv, status = adapter->host_intf_ops->write_pkt(common->priv, (u8 *)msg,
(u8 *)msg, skb->len);
skb->len);
if (status) if (status)
rsi_dbg(ERR_ZONE, "%s: Failed to write the packet\n", __func__); rsi_dbg(ERR_ZONE, "%s: Failed to write the packet\n", __func__);
......
...@@ -676,8 +676,6 @@ static int rsi_init_sdio_interface(struct rsi_hw *adapter, ...@@ -676,8 +676,6 @@ static int rsi_init_sdio_interface(struct rsi_hw *adapter,
} }
sdio_release_host(pfunction); sdio_release_host(pfunction);
adapter->host_intf_write_pkt = rsi_sdio_host_intf_write_pkt;
adapter->host_intf_read_pkt = rsi_sdio_host_intf_read_pkt;
adapter->determine_event_timeout = rsi_sdio_determine_event_timeout; adapter->determine_event_timeout = rsi_sdio_determine_event_timeout;
adapter->check_hw_queue_status = rsi_sdio_read_buffer_status_register; adapter->check_hw_queue_status = rsi_sdio_read_buffer_status_register;
...@@ -691,6 +689,13 @@ static int rsi_init_sdio_interface(struct rsi_hw *adapter, ...@@ -691,6 +689,13 @@ static int rsi_init_sdio_interface(struct rsi_hw *adapter,
return status; return status;
} }
static struct rsi_host_intf_ops sdio_host_intf_ops = {
.write_pkt = rsi_sdio_host_intf_write_pkt,
.read_pkt = rsi_sdio_host_intf_read_pkt,
.read_reg_multiple = rsi_sdio_read_register_multiple,
.write_reg_multiple = rsi_sdio_write_register_multiple,
};
/** /**
* rsi_probe() - This function is called by kernel when the driver provided * rsi_probe() - This function is called by kernel when the driver provided
* Vendor and device IDs are matched. All the initialization * Vendor and device IDs are matched. All the initialization
...@@ -713,6 +718,8 @@ static int rsi_probe(struct sdio_func *pfunction, ...@@ -713,6 +718,8 @@ static int rsi_probe(struct sdio_func *pfunction,
__func__); __func__);
return 1; return 1;
} }
adapter->rsi_host_intf = RSI_HOST_INTF_SDIO;
adapter->host_intf_ops = &sdio_host_intf_ops;
if (rsi_init_sdio_interface(adapter, pfunction)) { if (rsi_init_sdio_interface(adapter, pfunction)) {
rsi_dbg(ERR_ZONE, "%s: Failed to init sdio interface\n", rsi_dbg(ERR_ZONE, "%s: Failed to init sdio interface\n",
......
...@@ -392,6 +392,12 @@ static int rsi_usb_host_intf_write_pkt(struct rsi_hw *adapter, ...@@ -392,6 +392,12 @@ static int rsi_usb_host_intf_write_pkt(struct rsi_hw *adapter,
len); len);
} }
static struct rsi_host_intf_ops usb_host_intf_ops = {
.write_pkt = rsi_usb_host_intf_write_pkt,
.read_reg_multiple = rsi_usb_read_register_multiple,
.write_reg_multiple = rsi_usb_write_register_multiple,
};
/** /**
* rsi_deinit_usb_interface() - This function deinitializes the usb interface. * rsi_deinit_usb_interface() - This function deinitializes the usb interface.
* @adapter: Pointer to the adapter structure. * @adapter: Pointer to the adapter structure.
...@@ -457,9 +463,10 @@ static int rsi_init_usb_interface(struct rsi_hw *adapter, ...@@ -457,9 +463,10 @@ static int rsi_init_usb_interface(struct rsi_hw *adapter,
/* Initializing function callbacks */ /* Initializing function callbacks */
adapter->rx_urb_submit = rsi_rx_urb_submit; adapter->rx_urb_submit = rsi_rx_urb_submit;
adapter->host_intf_write_pkt = rsi_usb_host_intf_write_pkt;
adapter->check_hw_queue_status = rsi_usb_check_queue_status; adapter->check_hw_queue_status = rsi_usb_check_queue_status;
adapter->determine_event_timeout = rsi_usb_event_timeout; adapter->determine_event_timeout = rsi_usb_event_timeout;
adapter->rsi_host_intf = RSI_HOST_INTF_USB;
adapter->host_intf_ops = &usb_host_intf_ops;
rsi_init_event(&rsi_dev->rx_thread.event); rsi_init_event(&rsi_dev->rx_thread.event);
status = rsi_create_kthread(common, &rsi_dev->rx_thread, status = rsi_create_kthread(common, &rsi_dev->rx_thread,
......
...@@ -209,6 +209,11 @@ struct rsi_common { ...@@ -209,6 +209,11 @@ struct rsi_common {
u8 ant_in_use; u8 ant_in_use;
}; };
enum host_intf {
RSI_HOST_INTF_SDIO = 0,
RSI_HOST_INTF_USB
};
struct rsi_hw { struct rsi_hw {
struct rsi_common *priv; struct rsi_common *priv;
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
...@@ -219,16 +224,25 @@ struct rsi_hw { ...@@ -219,16 +224,25 @@ struct rsi_hw {
struct device *device; struct device *device;
u8 sc_nvifs; u8 sc_nvifs;
enum host_intf rsi_host_intf;
#ifdef CONFIG_RSI_DEBUGFS #ifdef CONFIG_RSI_DEBUGFS
struct rsi_debugfs *dfsentry; struct rsi_debugfs *dfsentry;
u8 num_debugfs_entries; u8 num_debugfs_entries;
#endif #endif
u8 dfs_region; u8 dfs_region;
void *rsi_dev; void *rsi_dev;
int (*host_intf_read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len); struct rsi_host_intf_ops *host_intf_ops;
int (*host_intf_write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num); int (*check_hw_queue_status)(struct rsi_hw *adapter, u8 q_num);
int (*rx_urb_submit)(struct rsi_hw *adapter); int (*rx_urb_submit)(struct rsi_hw *adapter);
int (*determine_event_timeout)(struct rsi_hw *adapter); int (*determine_event_timeout)(struct rsi_hw *adapter);
}; };
struct rsi_host_intf_ops {
int (*read_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
int (*write_pkt)(struct rsi_hw *adapter, u8 *pkt, u32 len);
int (*read_reg_multiple)(struct rsi_hw *adapter, u32 addr,
u8 *data, u16 count);
int (*write_reg_multiple)(struct rsi_hw *adapter, u32 addr,
u8 *data, u16 count);
};
#endif #endif
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