]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[RFKILL]: Add support for hardware-only rfkill buttons
authorMichael Buesch <mb@bu3sch.de>
Thu, 27 Sep 2007 19:34:23 +0000 (21:34 +0200)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:54:11 +0000 (16:54 -0700)
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>
include/linux/rfkill.h
net/rfkill/rfkill.c

index 26fddea12c2595a9216253927f1e8126228341d6..0ce5e0b52dbdef816607be8beae4c1b620b8b95a 100644 (file)
@@ -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 a8c5e0b914e41afdc94b3e119de972844112d401..51d151c0e9621169730881d3867fa70e50e20042 100644 (file)
@@ -190,6 +190,10 @@ static ssize_t rfkill_claim_store(struct device *dev,
        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 device *dev,
                rfkill->user_claim = claim;
        }
 
+out_unlock:
        mutex_unlock(&rfkill_mutex);
 
-       return count;
+       return error ? error : count;
 }
 
 static struct device_attribute rfkill_dev_attrs[] = {