aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/rfkill.h3
-rw-r--r--net/rfkill/rfkill.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index 26fddea12c25..0ce5e0b52dbd 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -52,6 +52,8 @@ enum rfkill_state {
52 * @type: Radio type which the button controls, the value stored 52 * @type: Radio type which the button controls, the value stored
53 * here should be a value from enum rfkill_type. 53 * here should be a value from enum rfkill_type.
54 * @state: State of the switch (on/off). 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 * @user_claim: Set when the switch is controlled exlusively by userspace. 57 * @user_claim: Set when the switch is controlled exlusively by userspace.
56 * @mutex: Guards switch state transitions 58 * @mutex: Guards switch state transitions
57 * @data: Pointer to the RF button drivers private data which will be 59 * @data: Pointer to the RF button drivers private data which will be
@@ -69,6 +71,7 @@ struct rfkill {
69 enum rfkill_type type; 71 enum rfkill_type type;
70 72
71 enum rfkill_state state; 73 enum rfkill_state state;
74 bool user_claim_unsupported;
72 bool user_claim; 75 bool user_claim;
73 76
74 struct mutex mutex; 77 struct mutex mutex;
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c
index a8c5e0b914e4..51d151c0e962 100644
--- a/net/rfkill/rfkill.c
+++ b/net/rfkill/rfkill.c
@@ -190,6 +190,10 @@ static ssize_t rfkill_claim_store(struct device *dev,
190 if (error) 190 if (error)
191 return error; 191 return error;
192 192
193 if (rfkill->user_claim_unsupported) {
194 error = -EOPNOTSUPP;
195 goto out_unlock;
196 }
193 if (rfkill->user_claim != claim) { 197 if (rfkill->user_claim != claim) {
194 if (!claim) 198 if (!claim)
195 rfkill_toggle_radio(rfkill, 199 rfkill_toggle_radio(rfkill,
@@ -197,9 +201,10 @@ static ssize_t rfkill_claim_store(struct device *dev,
197 rfkill->user_claim = claim; 201 rfkill->user_claim = claim;
198 } 202 }
199 203
204out_unlock:
200 mutex_unlock(&rfkill_mutex); 205 mutex_unlock(&rfkill_mutex);
201 206
202 return count; 207 return error ? error : count;
203} 208}
204 209
205static struct device_attribute rfkill_dev_attrs[] = { 210static struct device_attribute rfkill_dev_attrs[] = {