15 Oct, 2008

1 commit

  • For some m68k configs, I get:

    | net/rfkill/rfkill-input.c: In function 'rfkill_start':
    | net/rfkill/rfkill-input.c:208: error: dereferencing pointer to incomplete type

    As the incomplete type is `struct task_struct', including fixes
    it.

    Signed-off-by: Geert Uytterhoeven
    Signed-off-by: Linus Torvalds

    Geert Uytterhoeven
     

07 Oct, 2008

1 commit

  • The LED state was not being updated by rfkill_force_state(), which
    will cause regressions in wireless drivers that had old-style rfkill
    support and are updated to use rfkill_force_state().

    The LED state was not being updated when a change was detected through
    the rfkill->get_state() hook, either.

    Move the LED trigger update calls into notify_rfkill_state_change(),
    where it should have been in the first place. This takes care of both
    issues above.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: stable@kernel.org
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     

16 Sep, 2008

1 commit

  • 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: Henrique de Moraes Holschuh
    Cc: Ivo van Doorn
    Cc: Matthew Garrett
    Cc: Andrew Bird
    Cc: Greg Kroah-Hartman
    Cc: Cezary Jackiewicz
    Cc: Philip Langdale
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     

30 Aug, 2008

4 commits


23 Aug, 2008

4 commits

  • While it is interesting to not add last-enum-markers because it allows gcc
    to warn us of switch() statements missing a valid state, we really should
    be handling memory corruption on a rfkill state with default clauses,
    anyway.

    So add RFKILL_STATE_MAX and use it where applicable. It makes for safer
    code in the long run.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • rfkill is not a small, mere detail in wireless support. Once it starts
    supporting rfkill and users start counting on that support, a wireless
    device is at risk of operating in dangerous conditions should rfkill
    support fail to properly activate.

    Therefore, add the required __must_check annotations on some key functions
    of the rfkill API, for which the wireless drivers absolutely MUST handle
    the failure mode safely in order to avoid a potentially dangerous situation
    where the wireless transmitter is left enabled when the user don't want it
    to.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Matthew Garrett
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Add a second set of global states, "rfkill_default_states", to track the
    state that will be used when the first rfkill class of a given type is
    registered, and also to save "undo" information when rfkill_epo is called.

    Add a new exported function, rfkill_set_default(), which can be used by
    platform drivers to restore radio state saved by the platform across
    reboots or shutdown.

    Also, fix rfkill_epo to properly update rfkill_states, but still preserve a
    copy of the state so that we can undo the effect of rfkill_epo later if we
    want to. Add rfkill_restore_states() to restore rfkill_states from the
    copy.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Detect and abort with -EEXIST if rfkill_register is called twice on the
    same rfkill struct. And WARN_ON(it) for good measure.

    While at it, flag when we are adding the first switch of a type, we will
    need that information later.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Johannes Berg
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     

18 Aug, 2008

1 commit


02 Aug, 2008

3 commits

  • Provide default activate function to set the state of the led
    when the led becomes bound to the trigger

    Signed-off-by: Dmitry Baryshkov
    Acked-by: Ivo van Doorn
    Acked-by: Henrique de Moraes Holschuh
    Signed-off-by: John W. Linville

    Dmitry Baryshkov
     
  • Allow the rfkill driver to specify led trigger name.
    By default it still defaults to the name of rfkill switch.

    Signed-off-by: Dmitry Baryshkov
    Acked-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Dmitry Baryshkov
     
  • Every time a new input device that is capable of one of the
    rfkill EV_SW events (currently only SW_RFKILL_ALL) is connected to
    rfkill-input, we must check the states of the input EV_SW switches
    and take action. Otherwise, we will ignore the initial switch state.

    We also need to re-check the states of the EV_SW switches after
    a device that was under an exclusive grab is released back to us,
    since we got no input events from that device while it was grabbed.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Dmitry Torokhov
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     

30 Jul, 2008

4 commits

  • For some stupid reason, I sent and old version of the patch minor kernel
    doc-fix patch, and it got merged before I noticed the problem. This is an
    incremental fix on top.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • There are two mutexes in rfkill:

    rfkill->mutex, which protects some of the fields of a rfkill struct, and is
    also used for callback serialization.

    rfkill_mutex, which protects the global state, the list of registered
    rfkill structs and rfkill->claim.

    Make sure to use the correct mutex, and to not miss locking rfkill->mutex
    even when we already took rfkill_mutex.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • rfkill needs to unregister the led trigger AFTER a call to
    rfkill_remove_switch(), otherwise it will not update the LED state,
    possibly leaving it ON when it should be OFF.

    To make led-trigger unregistering safer, guard against unregistering a
    trigger twice, and also against issuing trigger events to a led trigger
    that was unregistered. This makes the error unwind paths more resilient.

    Refer to "rfkill: Register LED triggers before registering switch".

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Michael Buesch
    Cc: Dmitry Baryshkov
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • While the rfkill class does work with just get_state(), it doesn't work
    well on devices that are subject to external events that cause rfkill state
    changes.

    Document that rfkill_force_state() is required in those cases.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     

09 Jul, 2008

2 commits

  • 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 ".

    Signed-off-by: Henrique de Moraes Holschuh
    Cc: kionez
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Improve rfkill_toggle_radio's kernel-doc header a bit.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     

27 Jun, 2008

12 commits

  • The current naming of rfkill_state causes a lot of confusion: not only the
    "kill" in rfkill suggests negative logic, but also the fact that rfkill cannot
    turn anything on (it can just force something off or stop forcing something
    off) is often forgotten.

    Rename RFKILL_STATE_OFF to RFKILL_STATE_SOFT_BLOCKED (transmitter is blocked
    and will not operate; state can be changed by a toggle_radio request), and
    RFKILL_STATE_ON to RFKILL_STATE_UNBLOCKED (transmitter is not blocked, and may
    operate).

    Also, add a new third state, RFKILL_STATE_HARD_BLOCKED (transmitter is blocked
    and will not operate; state cannot be changed through a toggle_radio request),
    which is used by drivers to indicate a wireless transmiter was blocked by a
    hardware rfkill line that accepts no overrides.

    Keep the old names as #defines, but document them as deprecated. This way,
    drivers can be converted to the new names *and* verified to actually use rfkill
    correctly one by one.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • SW_RFKILL_ALL is the "emergency power-off all radios" input event. It must
    be handled, and must always do the same thing as far as the rfkill system
    is concerned: all transmitters are to go *immediately* offline.

    For safety, do NOT allow userspace to override EV_SW SW_RFKILL_ALL OFF. As
    long as rfkill-input is loaded, that event will *always* be processed, and
    it will *always* force all rfkill switches to disable all wireless
    transmitters, regardless of user_claim attribute or anything else.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Dmitry Torokhov
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • The whole current_state thing seems completely useless and a source of
    problems in rfkill-input, since state comparison is already done in rfkill,
    and rfkill-input is more than likely to become out of sync with the real
    state.

    Signed-off-by: Fabien Crespel
    Acked-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Dmitry Torokhov
    Signed-off-by: John W. Linville

    Fabien Crespel
     
  • Use the notification chains to also send uevents, so that userspace can be
    notified of state changes of every rfkill switch.

    Userspace should use these events for OSD/status report applications and
    rfkill GUI frontends. HAL might want to broadcast them over DBUS, for
    example. It might be also useful for userspace implementations of
    rfkill-input, or to use HAL as the platform driver which promotes rfkill
    switch change events into input events (to synchronize all other switches)
    when necessary for platforms that lack a convenient platform-specific
    kernel module to do it.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Dmitry Torokhov
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • We will need access to the rfkill switch type in string format for more
    than just sysfs. Therefore, move it to a generic helper.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Add a notifier chain for use by the rfkill class. This notifier chain
    signals the following events (more to be added when needed):

    1. rfkill: rfkill device state has changed

    A pointer to the rfkill struct will be passed as a parameter.

    The notifier message types have been added to include/linux/rfkill.h
    instead of to include/linux/notifier.h in order to avoid the madness of
    modifying a header used globally (and that triggers an almost full tree
    rebuild every time it is touched) with information that is of interest only
    to code that includes the rfkill.h header.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • The resume handler should reset the wireless transmitter rfkill
    state to exactly what it was when the system was suspended. Do it,
    and do it using the normal routines for state change while at it.

    The suspend handler should force-switch the transmitter to blocked
    state, ignoring caches. Do it.

    Also take an opportunity shot to rfkill_remove_switch() and also
    force the transmitter to blocked state there, bypassing caches.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Unfortunately, instead of adding a generic Wireless WAN type, a technology-
    specific type (WiMAX) was added. That's useless for other WWAN devices,
    such as EDGE, UMTS, X-RTT and other such radios.

    Add a WWAN rfkill type for generic wireless WAN devices. No keys are added
    as most devices really want to use KEY_WLAN for WWAN control (in a cycle of
    none, WLAN, WWAN, WLAN+WWAN) and need no specific keycode added.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Iñaky Pérez-González
    Cc: David S. Miller
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Currently, rfkill support for read/write rfkill switches is hacked through
    a round-trip over the input layer and rfkill-input to let a driver sync
    rfkill->state to hardware changes.

    This is buggy and sub-optimal. It causes real problems. It is best to
    think of the rfkill class as supporting only write-only switches at the
    moment.

    In order to implement the read/write functionality properly:

    Add a get_state() hook that is called by the class every time it needs to
    fetch the current state of the switch. Add a call to this hook every time
    the *current* state of the radio plays a role in a decision.

    Also add a force_state() method that can be used to forcefully syncronize
    the class' idea of the current state of the switch. This allows for a
    faster implementation of the read/write functionality, as a driver which
    get events on switch changes can avoid the need for a get_state() hook.

    If the get_state() hook is left as NULL, current behaviour is maintained,
    so this change is fully backwards compatible with the current rfkill
    drivers.

    For hardware that issues events when the rfkill state changes, leave
    get_state() NULL in the rfkill struct, set the initial state properly
    before registering with the rfkill class, and use the force_state() method
    in the driver to keep the rfkill interface up-to-date.

    get_state() can be called by the class from atomic context. It must not
    sleep.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Dmitry Torokhov
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Currently, radios are always enabled when their rfkill interface is
    registered. This is not optimal, the safest state for a radio is to be
    offline unless the user turns it on.

    Add a module parameter that causes all radios to be disabled when their
    rfkill interface is registered. The module default is not changed so
    unless the parameter is used, radios will still be forced to their enabled
    state when they are registered.

    The new rfkill module parameter is called "default_state".

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Teach rfkill-input how to handle SW_RFKILL_ALL events (new name for the
    SW_RADIO event).

    SW_RFKILL_ALL is an absolute enable-or-disable command that is tied to all
    radios in a system.

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Dmitry Torokhov
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     
  • Fix a minor typo in an exported function documentation

    Signed-off-by: Henrique de Moraes Holschuh
    Acked-by: Ivo van Doorn
    Cc: Dmitry Torokhov
    Signed-off-by: John W. Linville

    Henrique de Moraes Holschuh
     

16 Apr, 2008

1 commit

  • rfkill_switch_all() is supposed to only switch all the interfaces of a
    given type, but does not actually do this; instead, it just switches
    everything currently in the same state.

    Add the necessary type check in.

    (This fixes a bug I've been seeing while developing an rfkill laptop
    driver, with both bluetooth and wireless simultaneously changing state
    after only pressing either KEY_WLAN or KEY_BLUETOOTH).

    Signed-off-by: Carlos Corbacho
    Signed-off-by: John W. Linville

    Carlos Corbacho
     

24 Feb, 2008

1 commit

  • During the last step of hibernation in the "platform" mode (with the
    help of ACPI) we use the suspend code, including the devices'
    ->suspend() methods, to prepare the system for entering the ACPI S4
    system sleep state.

    But at least for some devices the operations performed by the
    ->suspend() callback in that case must be different from its operations
    during regular suspend.

    For this reason, introduce the new PM event type PM_EVENT_HIBERNATE and
    pass it to the device drivers' ->suspend() methods during the last phase
    of hibernation, so that they can distinguish this case and handle it as
    appropriate. Modify the drivers that handle PM_EVENT_SUSPEND in a
    special way and need to handle PM_EVENT_HIBERNATE in the same way.

    These changes are necessary to fix a hibernation regression related
    to the i915 driver (ref. http://lkml.org/lkml/2008/2/22/488).

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Pavel Machek
    Tested-by: Jeff Chua
    Signed-off-by: Linus Torvalds

    Rafael J. Wysocki
     

03 Feb, 2008

1 commit


01 Feb, 2008

1 commit

  • Teach rfkill about wimax radios.

    Had to define a KEY_WIMAX as a 'key for disabling only wimax radios',
    as other radio technologies have. This makes sense as hardware has
    specific keys for disabling specific radios.

    The RFKILL enabling part is, otherwise, a copy and paste of any other
    radio technology.

    Signed-off-by: Inaky Perez-Gonzalez
    Signed-off-by: Ivo van Doorn
    Signed-off-by: John W. Linville
    Signed-off-by: David S. Miller

    Iñaky Pérez-González
     

21 Jan, 2008

1 commit


30 Nov, 2007

1 commit

  • rfkill_toggle_radio is called from functions where
    rfkill->mutex is already aquired.

    Remove the lock from rfkill_toggle_radio() and add it to
    the only calling function that calls it without the lock held.

    Signed-off-by: Michael Buesch
    Acked-by: Ivo van Doorn
    Signed-off-by: John W. Linville

    Michael Buesch
     

11 Nov, 2007

1 commit