diff --git a/esp_hosted_ng/host/esp_cmd.c b/esp_hosted_ng/host/esp_cmd.c index a02351dfec..dd5b6280d6 100644 --- a/esp_hosted_ng/host/esp_cmd.c +++ b/esp_hosted_ng/host/esp_cmd.c @@ -905,7 +905,12 @@ int cmd_auth_request(struct esp_wifi_device *priv, adapter = priv->adapter; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 38) + cmd_len = sizeof(struct cmd_sta_auth) + req->sae_data_len; +#else cmd_len = sizeof(struct cmd_sta_auth) + req->auth_data_len; +#endif cmd_node = prepare_command_request(adapter, CMD_STA_AUTH, cmd_len); @@ -918,8 +923,13 @@ int cmd_auth_request(struct esp_wifi_device *priv, memcpy(cmd->bssid, bss->bssid, MAC_ADDR_LEN); cmd->channel = bss->channel->hw_value; cmd->auth_type = req->auth_type; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 38) + cmd->auth_data_len = req->sae_data_len; + memcpy(cmd->auth_data, req->sae_data, req->sae_data_len); +#else cmd->auth_data_len = req->auth_data_len; memcpy(cmd->auth_data, req->auth_data, req->auth_data_len); +#endif printk(KERN_INFO "Authentication request: %pM %d %d %d %d\n", cmd->bssid, cmd->channel, cmd->auth_type, cmd->auth_data_len, diff --git a/esp_hosted_ng/host/include/esp_kernel_port.h b/esp_hosted_ng/host/include/esp_kernel_port.h index 42d730a0ed..f3f52b0f5c 100644 --- a/esp_hosted_ng/host/include/esp_kernel_port.h +++ b/esp_hosted_ng/host/include/esp_kernel_port.h @@ -209,7 +209,12 @@ void CFG80211_RX_ASSOC_RESP(struct net_device *dev, cfg80211_rx_assoc_resp(dev, &resp); #else - cfg80211_rx_assoc_resp(dev, bss, buf, len, uapsd_queues, req_ies, req_ies_len) + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 38) + cfg80211_rx_assoc_resp(dev,bss,buf,len,0); +#else + cfg80211_rx_assoc_resp(dev, bss, buf, len, uapsd_queues, req_ies, req_ies_len); +#endif #endif } @@ -237,7 +242,11 @@ static inline bool wireless_dev_current_bss_exists(struct wireless_dev *wdev) #if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 15, 0)) static inline void eth_hw_addr_set(struct net_device *dev, const u8 *addr) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 38) + ether_addr_copy(dev->dev_addr, addr); +#else ether_addr_copy(dev->dev_addr, addr, ETH_ALEN); +#endif } #endif diff --git a/esp_hosted_ng/host/spi/esp_spi.c b/esp_hosted_ng/host/spi/esp_spi.c index dbf34ae7d0..c0b4c69e03 100644 --- a/esp_hosted_ng/host/spi/esp_spi.c +++ b/esp_hosted_ng/host/spi/esp_spi.c @@ -26,11 +26,11 @@ #include "esp_kernel_port.h" #include "esp_stats.h" -#define SPI_INITIAL_CLK_MHZ 10 #define NUMBER_1M 1000000 #define TX_MAX_PENDING_COUNT 100 #define TX_RESUME_THRESHOLD (TX_MAX_PENDING_COUNT/5) +static struct spi_master * esp_spi_master = NULL; static struct sk_buff * read_packet(struct esp_adapter *adapter); static int write_packet(struct esp_adapter *adapter, struct sk_buff *skb); static void spi_exit(void); @@ -363,11 +363,22 @@ static int process_rx_buf(struct sk_buff *skb) static void esp_spi_work(struct work_struct *work) { struct spi_transfer trans; + static struct spi_message m; struct sk_buff *tx_skb = NULL, *rx_skb = NULL; struct esp_skb_cb * cb = NULL; u8 *rx_buf = NULL; int ret = 0; volatile int trans_ready, rx_pending; + unsigned long flags; + + /*check spi_message is finish?*/ + spin_lock_irqsave(&esp_spi_master->queue_lock, flags); + if(m.state != NULL) { + spin_unlock_irqrestore(&esp_spi_master->queue_lock, flags); + pr_err("spi_message not finish\n"); + return; + } + spin_unlock_irqrestore(&esp_spi_master->queue_lock, flags); mutex_lock(&spi_lock); @@ -435,7 +446,14 @@ static void esp_spi_work(struct work_struct *work) } #endif +#if 0 ret = spi_sync_transfer(spi_context.esp_spi_dev, &trans, 1); +#else + memset(&m,0,sizeof(m)); + spi_message_init(&m); + spi_message_add_tail(&trans, &m); + ret = spi_sync(spi_context.esp_spi_dev,&m); +#endif if (ret) { printk(KERN_ERR "SPI Transaction failed: %d", ret); dev_kfree_skb(rx_skb); @@ -506,21 +524,20 @@ static int spi_dev_init(int spi_clk_mhz) { int status = 0; struct spi_board_info esp_board = {{0}}; - struct spi_master *master = NULL; strlcpy(esp_board.modalias, "esp_spi", sizeof(esp_board.modalias)); - esp_board.mode = SPI_MODE_2; + esp_board.mode = ESP_SPI_MODE; esp_board.max_speed_hz = spi_clk_mhz * NUMBER_1M; - esp_board.bus_num = 0; - esp_board.chip_select = 0; + esp_board.bus_num = ESP_SPI_MASTER; + esp_board.chip_select = ESP_SPI_DEVICE; - master = spi_busnum_to_master(esp_board.bus_num); - if (!master) { + esp_spi_master = spi_busnum_to_master(esp_board.bus_num); + if (IS_ERR(esp_spi_master)) { printk(KERN_ERR "Failed to obtain SPI master handle\n"); return -ENODEV; } - spi_context.esp_spi_dev = spi_new_device(master, &esp_board); + spi_context.esp_spi_dev = spi_new_device(esp_spi_master, &esp_board); if (!spi_context.esp_spi_dev) { printk(KERN_ERR "Failed to add new SPI device\n"); diff --git a/esp_hosted_ng/host/spi/esp_spi.h b/esp_hosted_ng/host/spi/esp_spi.h index 577c5627f9..c5d6ffd616 100644 --- a/esp_hosted_ng/host/spi/esp_spi.h +++ b/esp_hosted_ng/host/spi/esp_spi.h @@ -19,6 +19,12 @@ #include "esp.h" +#define ESP_SPI_MASTER 1 +#define ESP_SPI_DEVICE 0 +#define ESP_SPI_MODE SPI_MODE_2 + +#define SPI_INITIAL_CLK_MHZ 10 + #define HANDSHAKE_PIN 22 #define SPI_IRQ gpio_to_irq(HANDSHAKE_PIN) #define SPI_DATA_READY_PIN 27