Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[RFKILL]: Add support for hardware-only rfkill buttons

Buttons that work directly on hardware cannot support
the "user_claim" functionality. Add a flag to signal
this and return -EOPNOTSUPP in this case.
b43 is such a device.

Signed-off-by: Michael Buesch <mb@bu3sch.de>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Michael Buesch and committed by
David S. Miller
20405c08 135900c1

+9 -1
+3
include/linux/rfkill.h
··· 52 52 * @type: Radio type which the button controls, the value stored 53 53 * here should be a value from enum rfkill_type. 54 54 * @state: State of the switch (on/off). 55 + * @user_claim_unsupported: Whether the hardware supports exclusive 56 + * RF-kill control by userspace. Set this before registering. 55 57 * @user_claim: Set when the switch is controlled exlusively by userspace. 56 58 * @mutex: Guards switch state transitions 57 59 * @data: Pointer to the RF button drivers private data which will be ··· 71 69 enum rfkill_type type; 72 70 73 71 enum rfkill_state state; 72 + bool user_claim_unsupported; 74 73 bool user_claim; 75 74 76 75 struct mutex mutex;
+6 -1
net/rfkill/rfkill.c
··· 190 190 if (error) 191 191 return error; 192 192 193 + if (rfkill->user_claim_unsupported) { 194 + error = -EOPNOTSUPP; 195 + goto out_unlock; 196 + } 193 197 if (rfkill->user_claim != claim) { 194 198 if (!claim) 195 199 rfkill_toggle_radio(rfkill, ··· 201 197 rfkill->user_claim = claim; 202 198 } 203 199 200 + out_unlock: 204 201 mutex_unlock(&rfkill_mutex); 205 202 206 - return count; 203 + return error ? error : count; 207 204 } 208 205 209 206 static struct device_attribute rfkill_dev_attrs[] = {