rfkill_blocked() reports the effective block state, i.e. set when the device is either hardware or software blocked, and rfkill_soft_blocked() reports only the software state. There is no equivalent accessor for the hardware-only state, and struct rfkill is opaque to drivers, so a caller that needs to distinguish a hardware block from a software block cannot do so. Add rfkill_hard_blocked(), which reads RFKILL_BLOCK_HW under rfkill->lock in the same way as rfkill_soft_blocked(), together with a stub returning false when CONFIG_RFKILL is disabled. The first user is the Bluetooth HCI debugfs force_hw_rfkill test hook, which must report and compare against the hardware state only. Signed-off-by: Sai Teja Aluvala --- include/linux/rfkill.h | 12 ++++++++++++ net/rfkill/core.c | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h index deea02a034c3..9877ed4ea6ab 100644 --- a/include/linux/rfkill.h +++ b/include/linux/rfkill.h @@ -231,6 +231,13 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw); */ bool rfkill_blocked(struct rfkill *rfkill); +/** + * rfkill_hard_blocked - Query hardware block state + * + * @rfkill: rfkill struct + */ +bool rfkill_hard_blocked(struct rfkill *rfkill); + /** * rfkill_soft_blocked - Query soft rfkill block state * @@ -310,6 +317,11 @@ static inline bool rfkill_blocked(struct rfkill *rfkill) return false; } +static inline bool rfkill_hard_blocked(struct rfkill *rfkill) +{ + return false; +} + static inline bool rfkill_soft_blocked(struct rfkill *rfkill) { return false; diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 9e143c4bfe6a..684139591e9d 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c @@ -979,6 +979,19 @@ bool rfkill_blocked(struct rfkill *rfkill) } EXPORT_SYMBOL(rfkill_blocked); +bool rfkill_hard_blocked(struct rfkill *rfkill) +{ + unsigned long flags; + u32 state; + + spin_lock_irqsave(&rfkill->lock, flags); + state = rfkill->state; + spin_unlock_irqrestore(&rfkill->lock, flags); + + return !!(state & RFKILL_BLOCK_HW); +} +EXPORT_SYMBOL(rfkill_hard_blocked); + bool rfkill_soft_blocked(struct rfkill *rfkill) { unsigned long flags; -- 2.53.0