Home | History | Annotate | Download | only in drivers

Lines Matching refs:rfkill

2  * Linux rfkill helper functions for driver wrappers
20 #include "rfkill.h"
61 struct rfkill_data *rfkill = eloop_ctx;
66 len = read(rfkill->fd, &event, sizeof(event));
68 wpa_printf(MSG_ERROR, "rfkill: Event read failed: %s",
73 wpa_printf(MSG_DEBUG, "rfkill: Unexpected event size "
78 wpa_printf(MSG_DEBUG, "rfkill: event: idx=%u type=%d "
86 wpa_printf(MSG_INFO, "rfkill: WLAN hard blocked");
89 wpa_printf(MSG_INFO, "rfkill: WLAN soft blocked");
92 wpa_printf(MSG_INFO, "rfkill: WLAN unblocked");
96 if (new_blocked != rfkill->blocked) {
97 rfkill->blocked = new_blocked;
99 rfkill->cfg->blocked_cb(rfkill->cfg->ctx);
101 rfkill->cfg->unblocked_cb(rfkill->cfg->ctx);
108 struct rfkill_data *rfkill;
112 rfkill = os_zalloc(sizeof(*rfkill));
113 if (rfkill == NULL)
116 rfkill->cfg = cfg;
117 rfkill->fd = open("/dev/rfkill", O_RDONLY);
118 if (rfkill->fd < 0) {
119 wpa_printf(MSG_INFO, "rfkill: Cannot open RFKILL control "
124 if (fcntl(rfkill->fd, F_SETFL, O_NONBLOCK) < 0) {
125 wpa_printf(MSG_ERROR, "rfkill: Cannot set non-blocking mode: "
131 len = read(rfkill->fd, &event, sizeof(event));
135 wpa_printf(MSG_ERROR, "rfkill: Event read failed: %s",
140 wpa_printf(MSG_DEBUG, "rfkill: Unexpected event size "
145 wpa_printf(MSG_DEBUG, "rfkill: initial event: idx=%u type=%d "
153 wpa_printf(MSG_INFO, "rfkill: WLAN hard blocked");
154 rfkill->blocked = 1;
156 wpa_printf(MSG_INFO, "rfkill: WLAN soft blocked");
157 rfkill->blocked = 1;
161 eloop_register_read_sock(rfkill->fd, rfkill_receive, rfkill, NULL);
163 return rfkill;
166 close(rfkill->fd);
168 os_free(rfkill);
173 void rfkill_deinit(struct rfkill_data *rfkill)
175 if (rfkill == NULL)
178 if (rfkill->fd >= 0) {
179 eloop_unregister_read_sock(rfkill->fd);
180 close(rfkill->fd);
183 os_free(rfkill->cfg);
184 os_free(rfkill);
188 int rfkill_is_blocked(struct rfkill_data *rfkill)
190 if (rfkill == NULL)
193 return rfkill->blocked;