Lines Matching refs:rfkill

2  * Linux rfkill helper functions for driver wrappers
14 #include "rfkill.h"
55 struct rfkill_data *rfkill = eloop_ctx;
60 len = read(rfkill->fd, &event, sizeof(event));
62 wpa_printf(MSG_ERROR, "rfkill: Event read failed: %s",
67 wpa_printf(MSG_DEBUG, "rfkill: Unexpected event size "
72 wpa_printf(MSG_DEBUG, "rfkill: event: idx=%u type=%d "
80 wpa_printf(MSG_INFO, "rfkill: WLAN hard blocked");
83 wpa_printf(MSG_INFO, "rfkill: WLAN soft blocked");
86 wpa_printf(MSG_INFO, "rfkill: WLAN unblocked");
90 if (new_blocked != rfkill->blocked) {
91 rfkill->blocked = new_blocked;
93 rfkill->cfg->blocked_cb(rfkill->cfg->ctx);
95 rfkill->cfg->unblocked_cb(rfkill->cfg->ctx);
102 struct rfkill_data *rfkill;
106 rfkill = os_zalloc(sizeof(*rfkill));
107 if (rfkill == NULL)
110 rfkill->cfg = cfg;
111 rfkill->fd = open("/dev/rfkill", O_RDONLY);
112 if (rfkill->fd < 0) {
113 wpa_printf(MSG_INFO, "rfkill: Cannot open RFKILL control "
118 if (fcntl(rfkill->fd, F_SETFL, O_NONBLOCK) < 0) {
119 wpa_printf(MSG_ERROR, "rfkill: Cannot set non-blocking mode: "
125 len = read(rfkill->fd, &event, sizeof(event));
129 wpa_printf(MSG_ERROR, "rfkill: Event read failed: %s",
134 wpa_printf(MSG_DEBUG, "rfkill: Unexpected event size "
139 wpa_printf(MSG_DEBUG, "rfkill: initial event: idx=%u type=%d "
147 wpa_printf(MSG_INFO, "rfkill: WLAN hard blocked");
148 rfkill->blocked = 1;
150 wpa_printf(MSG_INFO, "rfkill: WLAN soft blocked");
151 rfkill->blocked = 1;
155 eloop_register_read_sock(rfkill->fd, rfkill_receive, rfkill, NULL);
157 return rfkill;
160 close(rfkill->fd);
162 os_free(rfkill);
167 void rfkill_deinit(struct rfkill_data *rfkill)
169 if (rfkill == NULL)
172 if (rfkill->fd >= 0) {
173 eloop_unregister_read_sock(rfkill->fd);
174 close(rfkill->fd);
177 os_free(rfkill->cfg);
178 os_free(rfkill);
182 int rfkill_is_blocked(struct rfkill_data *rfkill)
184 if (rfkill == NULL)
187 return rfkill->blocked;