Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the error about the compilation of linux4.9.38, modify spi tra… #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions esp_hosted_ng/host/esp_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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,
Expand Down
11 changes: 10 additions & 1 deletion esp_hosted_ng/host/include/esp_kernel_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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

Expand Down
33 changes: 25 additions & 8 deletions esp_hosted_ng/host/spi/esp_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down
6 changes: 6 additions & 0 deletions esp_hosted_ng/host/spi/esp_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down