mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 22:18:21 +00:00
u80211: sync with upstream and use new work system
This commit is contained in:
@@ -22,6 +22,7 @@ typedef struct {
|
||||
bool receiving;
|
||||
int current_channel;
|
||||
void *work;
|
||||
void *timer;
|
||||
} u80211_scan_state_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -38,22 +39,34 @@ static void wake_scan_waiters(u80211_device_t *device) {
|
||||
}
|
||||
|
||||
static void destroy_scan_state(u80211_scan_state_t *scan_state) {
|
||||
u80211_kernel_free_timer(scan_state->timer);
|
||||
u80211_kernel_free_work(scan_state->work);
|
||||
u80211_ringbuffer_destroy(&scan_state->buffer);
|
||||
u80211_kernel_free(scan_state);
|
||||
}
|
||||
|
||||
static void cleanup_scan(void *ctx);
|
||||
|
||||
static void complete_scan(u80211_scan_state_t *scan_state) {
|
||||
u80211_device_t *device = scan_state->device;
|
||||
|
||||
u80211_kernel_acquire_spinlock(device->scan_spinlock);
|
||||
|
||||
u80211_set_device_state(device, U80211_DEVICE_STATE_SCANNING, U80211_DEVICE_STATE_DOWN);
|
||||
wake_scan_waiters(device);
|
||||
|
||||
device->scan_context = NULL;
|
||||
u80211_kernel_release_spinlock(device->scan_spinlock);
|
||||
|
||||
u80211_kernel_enqueue_work(device->scan_cleanup_work, cleanup_scan, scan_state);
|
||||
}
|
||||
|
||||
static void cleanup_scan(void *ctx) {
|
||||
u80211_scan_state_t *scan_state = ctx;
|
||||
u80211_device_t *device = scan_state->device;
|
||||
|
||||
destroy_scan_state(scan_state);
|
||||
|
||||
u80211_kernel_acquire_spinlock(device->scan_spinlock);
|
||||
u80211_set_device_state(device, U80211_DEVICE_STATE_SCANNING, U80211_DEVICE_STATE_DOWN);
|
||||
wake_scan_waiters(device);
|
||||
u80211_kernel_release_spinlock(device->scan_spinlock);
|
||||
}
|
||||
|
||||
void u80211_scan_process_response(u80211_device_t *device, u80211_beacon_data_t *beacon_data) {
|
||||
@@ -151,7 +164,7 @@ static void scan_work(void *ctx) {
|
||||
|
||||
u80211_send_probe_request(device);
|
||||
|
||||
u80211_kernel_enqueue_work(scan_state->work, scan_work, scan_state, WAIT_MS);
|
||||
u80211_kernel_enqueue_delayed_work(scan_state->work, scan_state->timer, scan_work, scan_state, WAIT_MS);
|
||||
}
|
||||
|
||||
int u80211_scan(u80211_device_t *device) {
|
||||
@@ -172,6 +185,14 @@ int u80211_scan(u80211_device_t *device) {
|
||||
return U80211_STATUS_ENOMEM;
|
||||
}
|
||||
|
||||
scan_state->timer = u80211_kernel_allocate_timer();
|
||||
if (scan_state->timer == NULL) {
|
||||
u80211_kernel_free_work(scan_state->work);
|
||||
u80211_ringbuffer_destroy(&scan_state->buffer);
|
||||
u80211_kernel_free(scan_state);
|
||||
return U80211_STATUS_ENOMEM;
|
||||
}
|
||||
|
||||
scan_state->receiving = false;
|
||||
scan_state->device = device;
|
||||
scan_state->current_channel = next_channel(0);
|
||||
@@ -199,7 +220,7 @@ int u80211_scan(u80211_device_t *device) {
|
||||
|
||||
u80211_send_probe_request(device);
|
||||
|
||||
u80211_kernel_enqueue_work(scan_state->work, scan_work, scan_state, WAIT_MS);
|
||||
u80211_kernel_enqueue_delayed_work(scan_state->work, scan_state->timer, scan_work, scan_state, WAIT_MS);
|
||||
|
||||
return U80211_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user