Skip to content

Commit

Permalink
rfkill: allow to get the software rfkill state
Browse files Browse the repository at this point in the history
iwlwifi needs to be able to differentiate between the
software rfkill state and the hardware rfkill state.

The reason for this is that iwlwifi needs to notify any
change in the software rfkill state even when it doesn't
own the device (which means even when the hardware rfkill
is asserted).

In order to be able to know the software rfkill when the
host does not own the device, iwlwifi needs to be able to
ask the state of the software rfkill ignoring the state
of the hardware rfkill.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Link: https://lore.kernel.org/r/20211219195124.125689-1-emmanuel.grumbach@intel.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Emmanuel Grumbach authored and Johannes Berg committed Dec 20, 2021
1 parent 75cca1f commit 5bc9a9d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/linux/rfkill.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw);
*/
bool rfkill_blocked(struct rfkill *rfkill);

/**
* rfkill_soft_blocked - Query soft rfkill block state
*
* @rfkill: rfkill struct to query
*/
bool rfkill_soft_blocked(struct rfkill *rfkill);

/**
* rfkill_find_type - Helper for finding rfkill type by name
* @name: the name of the type
Expand Down
12 changes: 12 additions & 0 deletions net/rfkill/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,18 @@ bool rfkill_blocked(struct rfkill *rfkill)
}
EXPORT_SYMBOL(rfkill_blocked);

bool rfkill_soft_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_SW);
}
EXPORT_SYMBOL(rfkill_soft_blocked);

struct rfkill * __must_check rfkill_alloc(const char *name,
struct device *parent,
Expand Down

0 comments on commit 5bc9a9d

Please sign in to comment.