1. 04 6月, 2009 3 次提交
    • J
      rfkill: add function to query state · 6081162e
      Johannes Berg 提交于
      Sometimes it is necessary to know how the state is,
      and it is easier to query rfkill than keep track of
      it somewhere else, so add a function for that. This
      could later be expanded to return hard/soft block,
      but so far that isn't necessary.
      Signed-off-by: NJohannes Berg <johannes@sipsolutions.net>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      6081162e
    • J
      rfkill: create useful userspace interface · c64fb016
      Johannes Berg 提交于
      The new code added by this patch will make rfkill create
      a misc character device /dev/rfkill that userspace can use
      to control rfkill soft blocks and get status of devices as
      well as events when the status changes.
      
      Using it is very simple -- when you open it you can read
      a number of times to get the initial state, and every
      further read blocks (you can poll) on getting the next
      event from the kernel. The same structure you read is
      also used when writing to it to change the soft block of
      a given device, all devices of a given type, or all
      devices.
      
      This also makes CONFIG_RFKILL_INPUT selectable again in
      order to be able to test without it present since its
      functionality can now be replaced by userspace entirely
      and distros and users may not want the input part of
      rfkill interfering with their userspace code. We will
      also write a userspace daemon to handle all that and
      consequently add the input code to the feature removal
      schedule.
      
      In order to have rfkilld support both kernels with and
      without CONFIG_RFKILL_INPUT (or new kernels after its
      eventual removal) we also add an ioctl (that only exists
      if rfkill-input is present) to disable rfkill-input.
      It is not very efficient, but at least gives the correct
      behaviour in all cases.
      Signed-off-by: NJohannes Berg <johannes@sipsolutions.net>
      Acked-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      c64fb016
    • J
      rfkill: rewrite · 19d337df
      Johannes Berg 提交于
      This patch completely rewrites the rfkill core to address
      the following deficiencies:
      
       * all rfkill drivers need to implement polling where necessary
         rather than having one central implementation
      
       * updating the rfkill state cannot be done from arbitrary
         contexts, forcing drivers to use schedule_work and requiring
         lots of code
      
       * rfkill drivers need to keep track of soft/hard blocked
         internally -- the core should do this
      
       * the rfkill API has many unexpected quirks, for example being
         asymmetric wrt. alloc/free and register/unregister
      
       * rfkill can call back into a driver from within a function the
         driver called -- this is prone to deadlocks and generally
         should be avoided
      
       * rfkill-input pointlessly is a separate module
      
       * drivers need to #ifdef rfkill functions (unless they want to
         depend on or select RFKILL) -- rfkill should provide inlines
         that do nothing if it isn't compiled in
      
       * the rfkill structure is not opaque -- drivers need to initialise
         it correctly (lots of sanity checking code required) -- instead
         force drivers to pass the right variables to rfkill_alloc()
      
       * the documentation is hard to read because it always assumes the
         reader is completely clueless and contains way TOO MANY CAPS
      
       * the rfkill code needlessly uses a lot of locks and atomic
         operations in locked sections
      
       * fix LED trigger to actually change the LED when the radio state
         changes -- this wasn't done before
      Tested-by: NAlan Jenkins <alan-jenkins@tuffmail.co.uk>
      Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br> [thinkpad]
      Signed-off-by: NJohannes Berg <johannes@sipsolutions.net>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      19d337df
  2. 07 5月, 2009 1 次提交
  3. 23 4月, 2009 3 次提交
  4. 05 1月, 2009 1 次提交
  5. 13 12月, 2008 1 次提交
  6. 26 11月, 2008 2 次提交
  7. 11 11月, 2008 1 次提交
  8. 07 11月, 2008 1 次提交
  9. 01 11月, 2008 5 次提交
    • H
      rfkill: rate-limit rfkill-input workqueue usage (v3) · 78236571
      Henrique de Moraes Holschuh 提交于
      Limit the number of "expensive" rfkill workqueue operations per second, in
      order to not hog system resources too much when faced with a rogue source
      of rfkill input events.
      
      The old rfkill-input code (before it was refactored) had such a limit in
      place.  It used to drop new events that were past the rate limit.  This
      behaviour was not implemented as an anti-DoS measure, but rather as an
      attempt to work around deficiencies in input device drivers which would
      issue multiple KEY_FOO events too soon for a given key FOO (i.e. ones that
      do not implement mechanical debouncing properly).
      
      However, we can't really expect such issues to be worked around by every
      input handler out there, and also by every userspace client of input
      devices.  It is the input device driver's responsability to do debouncing
      instead of spamming the input layer with bogus events.
      
      The new limiter code is focused only on anti-DoS behaviour, and tries to
      not lose events (instead, it coalesces them when possible).
      
      The transmitters are updated once every 200ms, maximum.  Care is taken not
      to delay a request to _enter_ rfkill transmitter Emergency Power Off (EPO)
      mode.
      
      If mistriggered (e.g. by a jiffies counter wrap), the code delays processing
      *once* by 200ms.
      Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Cc: Dmitry Torokhov <dtor@mail.ru>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      78236571
    • H
      rfkill: honour EPO state when resuming a rfkill controller · 17670799
      Henrique de Moraes Holschuh 提交于
      rfkill_resume() would always restore the rfkill controller state to its
      pre-suspend state.
      
      Now that we know when we are under EPO, kick the rfkill controller to
      SOFT_BLOCKED state instead of to its pre-suspend state when it is resumed
      while EPO mode is active.
      Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      17670799
    • H
      rfkill: add master_switch_mode and EPO lock to rfkill and rfkill-input · d003922d
      Henrique de Moraes Holschuh 提交于
      Add of software-based sanity to rfkill and rfkill-input so that it can
      reproduce what hardware-based EPO switches do, blocking all transmitters
      and locking down any further attempts to unblock them until the switch is
      deactivated.
      
      rfkill-input is responsible for issuing the EPO control requests, like
      before.
      
      While an rfkill EPO is active, all transmitters are locked to one of the
      BLOCKED states and all attempts to change that through the rfkill API
      (userspace and kernel) will be either ignored or return -EPERM errors.
      
      The lock will be released upon receipt of EV_SW SW_RFKILL_ALL ON by
      rfkill-input, or should modular rfkill-input be unloaded.
      
      This makes rfkill and rfkill-input extend the operation of an existing
      wireless master kill switch to all wireless devices in the system, even
      those that are not under hardware or firmware control.
      
      Since the above is the expected operational behavior for the master rfkill
      switch, the EPO lock functionality is not optional.
      
      Also, extend rfkill-input to allow for three different behaviors when it
      receives an EV_SW SW_RFKILL_ALL ON input event.  The user can set which
      behavior he wants through the master_switch_mode parameter:
      
      master_switch_mode = 0: EV_SW SW_RFKILL_ALL ON just unlocks rfkill
      controller state changes (so that the rfkill userspace and kernel APIs can
      now be used to change rfkill controller states again), but doesn't change
      any of their states (so they will all remain blocked).  This is the safest
      mode of operation, as it requires explicit operator action to re-enable a
      transmitter.
      
      master_switch_mode = 1: EV_SW SW_RFKILL_ALL ON causes rfkill-input to
      attempt to restore the system to the state before the last EV_SW
      SW_RFKILL_ALL OFF event, or to the default global states if no EV_SW
      SW_RFKILL_ALL OFF ever happened.   This is the recommended mode of
      operation for laptops.
      
      master_switch_mode = 2: tries to unblock all rfkill controllers (i.e.
      enable all transmitters) when an EV_SW SW_RFKILL_ALL ON event is received.
      This is the default mode of operation, as it mimics the previous behavior
      of rfkill-input.
      
      In order to implement these features in a clean way, the entire event
      handling of rfkill-input was refactored into a single worker function.
      
      Protection against input event DoS (repeatedly firing rfkill events for
      rfkill-input to process) was removed during the code refactoring.  It will
      be added back in a future patch.
      
      Note that with these changes, rfkill-input doesn't need to explicitly
      handle any radio types for which KEY_<radio type> or SW_<radio type> events
      do not exist yet.
      
      Code to handle EV_SW SW_{WLAN,WWAN,BLUETOOTH,WIMAX,...} was added as it
      might be needed in the future (and its implementation is not that obvious),
      but is currently #ifdef'd out to avoid wasting resources.
      Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Cc: Dmitry Torokhov <dtor@mail.ru>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      d003922d
    • H
      rfkill: export global states to rfkill-input · 68d2413b
      Henrique de Moraes Holschuh 提交于
      Export the the global switch states to rfkill-input.  This is needed to
      properly implement KEY_* handling without disregarding the initial state.
      Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      68d2413b
    • H
      rfkill: use killable locks instead of interruptible · cf4b4aab
      Henrique de Moraes Holschuh 提交于
      Apparently, many applications don't expect to get EAGAIN from fd read/write
      operations, since POSIX doesn't mandate it.
      
      Use mutex_lock_killable instead of mutex_lock_interruptible, which won't
      cause issues.
      Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      cf4b4aab
  10. 28 10月, 2008 1 次提交
  11. 15 10月, 2008 1 次提交
  12. 07 10月, 2008 1 次提交
  13. 16 9月, 2008 1 次提交
    • H
      rfkill: remove transmitter blocking on suspend · bed7aac9
      Henrique de Moraes Holschuh 提交于
      Currently, rfkill would stand in the way of properly supporting wireless
      devices that are capable of waking the system up from sleep or hibernation
      when they receive a special wireless message.  It would also get in the way
      of mesh devices that need to remain operational even during platform
      suspend.
      
      To avoid that, stop trying to block the transmitters on the rfkill class
      suspend handler.
      
      Drivers that need rfkill's older behaviour will have to implement it by
      themselves in their own suspend handling.
      
      Do note that rfkill *will* attempt to restore the transmitter state on
      resume in any situation.  This happens after the driver's resume method is
      called by the suspend core (class devices resume after the devices they are
      attached to have been resumed).
      
      The following drivers need to check if they need to explicitly block
      their transmitters in their own suspend handlers (maintainers Cc'd):
      	arch/arm/mach-pxa/tosa-bt.c
      	drivers/net/usb/hso.c
      	drivers/net/wireless/rt2x00/* (USB might need it?)
      	drivers/net/wireless/b43/ (SSB over USB might need it?)
      	drivers/misc/hp-wmi.c
      	eeepc-laptop w/rfkill support (not in mainline yet)
      	Compal laptop w/rfkill support (not in mainline yet)
      	toshiba-acpi w/rfkill support (not in mainline yet)
      Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: Ivo van Doorn <IvDoorn@gmail.com>
      Cc: Matthew Garrett <mjg@redhat.com>
      Cc: Andrew Bird <ajb@spheresystems.co.uk>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
      Cc: Philip Langdale <philipl@overt.org>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      bed7aac9
  14. 30 8月, 2008 4 次提交
  15. 27 8月, 2008 1 次提交
  16. 23 8月, 2008 4 次提交
  17. 18 8月, 2008 1 次提交
  18. 02 8月, 2008 3 次提交
  19. 30 7月, 2008 4 次提交
  20. 09 7月, 2008 1 次提交
    • H
      rfkill: ignore errors from rfkill_toggle_radio in rfkill_add_switch · fd4484af
      Henrique de Moraes Holschuh 提交于
      rfkill_add_switch() calls rfkill_toggle_radio() to set the state of a
      recently registered rfkill class to the current global state [for that
      rfkill->type].
      
      The rfkill_toggle_radio() call is going to error out if the hardware is
      RFKILL_STATE_HARD_BLOCKED, and the global state is RFKILL_STATE_UNBLOCKED.
      
      That is a quite normal situation which I missed to account for.  As things
      stand, the error return from rfkill_toggle_radio ends up causing
      rfkill_register to bail out with an error (de-registering the new switch in
      the process), which is Not Nice.
      
      Change rfkill_add_switch() to not return errors because of a failed call to
      rfkill_toggle_radio().  We can go back to returning errors again (if that's
      indeed the right thing to do) if we define the exact error codes the
      rfkill->toggle_radio callbacks are to return in each situation, so that we
      can ignore the right ones only.
      
      Bug reported by "kionez <kionez@anche.no>".
      Signed-off-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: kionez <kionez@anche.no>
      Acked-by: NIvo van Doorn <IvDoorn@gmail.com>
      Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
      fd4484af