Skip to contentSkip to conversation

rfkill: Add support for hardware-only rfkill buttons

PATCH In review Michael Buesch 2 participants 2 messages Sep 27, 2007 Rfkill

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

include/linux/rfkill.h +3 -0
Index: wireless-2.6/include/linux/rfkill.h
===================================================================
@@ -52,6 +52,8 @@ enum rfkill_state {
  * @type: Radio type which the button controls, the value stored
  *	here should be a value from enum rfkill_type.
  * @state: State of the switch (on/off).
+ * @user_claim_unsupported: Whether the hardware supports exclusive
+ *	RF-kill control by userspace. Set this before registering.
  * @user_claim: Set when the switch is controlled exlusively by userspace.
  * @mutex: Guards switch state transitions
  * @data: Pointer to the RF button drivers private data which will be
@@ -69,6 +71,7 @@ struct rfkill {
 	enum rfkill_type type;
 
 	enum rfkill_state state;
+	bool user_claim_unsupported;
 	bool user_claim;
 
 	struct mutex mutex;
net/rfkill/rfkill.c +6 -1
Index: wireless-2.6/net/rfkill/rfkill.c
===================================================================
@@ -190,6 +190,10 @@ static ssize_t rfkill_claim_store(struct
 	if (error)
 		return error;
 
+	if (rfkill->user_claim_unsupported) {
+		error = -EOPNOTSUPP;
+		goto out_unlock;
+	}
 	if (rfkill->user_claim != claim) {
 		if (!claim)
 			rfkill_toggle_radio(rfkill,
@@ -197,9 +201,10 @@ static ssize_t rfkill_claim_store(struct
 		rfkill->user_claim = claim;
 	}
 
+out_unlock:
 	mutex_unlock(&rfkill_mutex);
 
-	return count;
+	return error ? error : count;
 }
 
 static struct device_attribute rfkill_dev_attrs[] = {
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Michael Buesch

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.

Quoted 49 lines

Index: wireless-2.6/include/linux/rfkill.h
===================================================================

include/linux/rfkill.h +3 -0
@@ -52,6 +52,8 @@ enum rfkill_state {
  * @type: Radio type which the button controls, the value stored
  *	here should be a value from enum rfkill_type.
  * @state: State of the switch (on/off).
+ * @user_claim_unsupported: Whether the hardware supports exclusive
+ *	RF-kill control by userspace. Set this before registering.
  * @user_claim: Set when the switch is controlled exlusively by userspace.
  * @mutex: Guards switch state transitions
  * @data: Pointer to the RF button drivers private data which will be
@@ -69,6 +71,7 @@ struct rfkill {
 	enum rfkill_type type;
 
 	enum rfkill_state state;
+	bool user_claim_unsupported;
 	bool user_claim;
 
 	struct mutex mutex;

Index: wireless-2.6/net/rfkill/rfkill.c
===================================================================

net/rfkill/rfkill.c +6 -1
@@ -190,6 +190,10 @@ static ssize_t rfkill_claim_store(struct
 	if (error)
 		return error;
 
+	if (rfkill->user_claim_unsupported) {
+		error = -EOPNOTSUPP;
+		goto out_unlock;
+	}
 	if (rfkill->user_claim != claim) {
 		if (!claim)
 			rfkill_toggle_radio(rfkill,
@@ -197,9 +201,10 @@ static ssize_t rfkill_claim_store(struct
 		rfkill->user_claim = claim;
 	}
 
+out_unlock:
 	mutex_unlock(&rfkill_mutex);
 
-	return count;
+	return error ? error : count;
 }
 
 static struct device_attribute rfkill_dev_attrs[] = {