Home | History | Annotate | Download | only in drivers

Lines Matching defs:rfkill

2  * Linux rfkill helper functions for driver wrappers
15 #include "rfkill.h"
57 struct rfkill_data *rfkill = eloop_ctx;
62 len = read(rfkill->fd, &event, sizeof(event));
64 wpa_printf(MSG_ERROR, "rfkill: Event read failed: %s",
69 wpa_printf(MSG_DEBUG, "rfkill: Unexpected event size "
74 if (event.op != RFKILL_OP_CHANGE || event.idx != rfkill->idx)
77 wpa_printf(MSG_DEBUG, "rfkill: event: idx=%u type=%d "
83 wpa_printf(MSG_INFO, "rfkill: WLAN hard blocked");
86 wpa_printf(MSG_INFO, "rfkill: WLAN soft blocked");
89 wpa_printf(MSG_INFO, "rfkill: WLAN unblocked");
93 if (new_blocked != rfkill->blocked) {
94 rfkill->blocked = new_blocked;
96 rfkill->cfg->blocked_cb(rfkill->cfg->ctx);
98 rfkill->cfg->unblocked_cb(rfkill->cfg->ctx);
105 struct rfkill_data *rfkill;
113 rfkill = os_zalloc(sizeof(*rfkill));
114 if (rfkill == NULL)
121 wpa_printf(MSG_INFO, "rfkill: Cannot get wiphy information");
125 rfkill->cfg = cfg;
126 rfkill->fd = open("/dev/rfkill", O_RDONLY);
127 if (rfkill->fd < 0) {
128 wpa_printf(MSG_INFO, "rfkill: Cannot open RFKILL control "
133 if (fcntl(rfkill->fd, F_SETFL, O_NONBLOCK) < 0) {
134 wpa_printf(MSG_ERROR, "rfkill: Cannot set non-blocking mode: "
140 len = read(rfkill->fd, &event, sizeof(event));
144 wpa_printf(MSG_ERROR, "rfkill: Event read failed: %s",
149 wpa_printf(MSG_DEBUG, "rfkill: Unexpected event size "
159 "/sys/class/rfkill/rfkill%d/device", event.idx);
169 wpa_printf(MSG_DEBUG, "rfkill: initial event: idx=%u type=%d "
174 rfkill->idx = event.idx;
176 wpa_printf(MSG_INFO, "rfkill: WLAN hard blocked");
177 rfkill->blocked = 1;
179 wpa_printf(MSG_INFO, "rfkill: WLAN soft blocked");
180 rfkill->blocked = 1;
189 eloop_register_read_sock(rfkill->fd, rfkill_receive, rfkill, NULL);
191 return rfkill;
194 close(rfkill->fd);
196 os_free(rfkill);
203 void rfkill_deinit(struct rfkill_data *rfkill)
205 if (rfkill == NULL)
208 if (rfkill->fd >= 0) {
209 eloop_unregister_read_sock(rfkill->fd);
210 close(rfkill->fd);
213 os_free(rfkill->cfg);
214 os_free(rfkill);
218 int rfkill_is_blocked(struct rfkill_data *rfkill)
220 if (rfkill == NULL)
223 return rfkill->blocked;