16 Nov, 2010

1 commit


23 Aug, 2010

1 commit

  • __packed is only defined in kernel space, so we should use
    __attribute__((packed)) for the code shared between kernel and user space.

    Two __attribute() annotations are replaced with __attribute__() too.

    Signed-off-by: Changli Gao
    Signed-off-by: David S. Miller

    Changli Gao
     

03 Mar, 2010

1 commit

  • Add support for handling KEY_RFKILL in the rfkill input module. This
    simply toggles the state of all rfkill devices. The comment in rfkill.h
    is also updated to reflect that RFKILL_TYPE_ALL may be used inside the
    kernel.

    Signed-off-by: Matthew Garrett
    Acked-by: Marcel Holtmann
    Signed-off-by: John W. Linville

    Matthew Garrett
     

19 Nov, 2009

2 commits


02 Sep, 2009

1 commit

  • This header file is copied into userspace tools that
    need not be GPLv2 licensed, make that easier.

    Signed-off-by: Johannes Berg
    Acked-by: Alan Jenkins
    Acked-by: Henrique de Moraes Holschuh
    Acked-by: Iñaky Pérez-González
    Acked-by: Ivo van Doorn
    Acked-by: Jaswinder Singh Rajput
    Acked-by: Michael Buesch
    Acked-by: Tomas Winkler
    Signed-off-by: John W. Linville

    Johannes Berg
     

05 Aug, 2009

1 commit

  • Althoug GPS is a technology w/o transmitting radio
    and thus not a primary candidate for rfkill switch,
    rfkill gives unified interface point for devices with
    wireless technology.

    The input key is not supplied as it is too be deprecated.

    Cc: johannes@sipsolutions.net
    Signed-off-by: Tomas Winkler
    Acked-by: Marcel Holtmann
    Signed-off-by: John W. Linville

    Tomas Winkler
     

24 Jul, 2009

1 commit


22 Jul, 2009

1 commit


11 Jul, 2009

1 commit

  • We've designed the /dev/rfkill API in a way that we
    can increase the event struct by adding members at
    the end, should it become necessary. To validate the
    events, userspace and the kernel need to have the
    proper event size to check for -- when reading from
    the other end they need to verify that it's at least
    version 1 of the event API, with the current struct
    size, so define a constant for that and make the
    code a little more 'future proof'.

    Not that I expect that we'll have to change the event
    size any time soon, but it's better to write the code
    in a way that lends itself to extending.

    Due to the current size of the event struct, the code
    is currently equivalent, but should the event struct
    ever need to be increased the new code might not need
    changing.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     

09 Jul, 2009

1 commit


19 Jun, 2009

2 commits

  • This information allows userspace to implement a hybrid policy where
    it can store the rfkill soft-blocked state in platform non-volatile
    storage if available, and if not then file-based storage can be used.

    Some users prefer platform non-volatile storage because of the behaviour
    when dual-booting multiple versions of Linux, or if the rfkill setting
    is changed in the BIOS setting screens, or if the BIOS responds to
    wireless-toggle hotkeys itself before the relevant platform driver has
    been loaded.

    Signed-off-by: Alan Jenkins
    Acked-by: Henrique de Moraes Holschuh
    Signed-off-by: John W. Linville

    Alan Jenkins
     
  • The setting of the "persistent" flag is also made more explicit using
    a new rfkill_init_sw_state() function, instead of special-casing
    rfkill_set_sw_state() when it is called before registration.

    Suspend is a bit of a corner case so we try to get away without adding
    another hack to rfkill-input - it's going to be removed soon.
    If the state does change over suspend, users will simply have to prod
    rfkill-input twice in order to toggle the state.

    Userspace policy agents will be able to implement a more consistent user
    experience. For example, they can avoid the above problem if they
    toggle devices individually. Then there would be no "global state"
    to get out of sync.

    Currently there are only two rfkill drivers with persistent soft-blocked
    state. thinkpad-acpi already checks the software state on resume.
    eeepc-laptop will require modification.

    Signed-off-by: Alan Jenkins
    CC: Marcel Holtmann
    Acked-by: Henrique de Moraes Holschuh
    Signed-off-by: John W. Linville

    Alan Jenkins
     

11 Jun, 2009

2 commits

  • Once rfkill-input is disabled, the "global" states will only be used as
    default initial states.

    Since the states will always be the same after resume, we shouldn't
    generate events on resume.

    Signed-off-by: Alan Jenkins
    Signed-off-by: John W. Linville

    Alan Jenkins
     
  • rfkill_set_global_sw_state() (previously rfkill_set_default()) will no
    longer be exported by the rewritten rfkill core.

    Instead, platform drivers which can provide persistent soft-rfkill state
    across power-down/reboot should indicate their initial state by calling
    rfkill_set_sw_state() before registration. Otherwise, they will be
    initialized to a default value during registration by a set_block call.

    We remove existing calls to rfkill_set_sw_state() which happen before
    registration, since these had no effect in the old model. If these
    drivers do have persistent state, the calls can be put back (subject
    to testing :-). This affects hp-wmi and acer-wmi.

    Drivers with persistent state will affect the global state only if
    rfkill-input is enabled. This is required, otherwise booting with
    wireless soft-blocked and pressing the wireless-toggle key once would
    have no apparent effect. This special case will be removed in future
    along with rfkill-input, in favour of a more flexible userspace daemon
    (see Documentation/feature-removal-schedule.txt).

    Now rfkill_global_states[n].def is only used to preserve global states
    over EPO, it is renamed to ".sav".

    Signed-off-by: Alan Jenkins
    Acked-by: Henrique de Moraes Holschuh
    Signed-off-by: John W. Linville

    Alan Jenkins
     

10 Jun, 2009

1 commit


04 Jun, 2009

3 commits

  • 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: Johannes Berg
    Signed-off-by: John W. Linville

    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: Johannes Berg
    Acked-by: Marcel Holtmann
    Signed-off-by: John W. Linville

    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: Alan Jenkins
    Signed-off-by: Henrique de Moraes Holschuh [thinkpad]
    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     

23 Apr, 2009

2 commits

  • Almost all drivers do not support user_claim, so remove it
    completely and always report -EOPNOTSUPP to userspace. Since
    userspace cannot really drive rfkill _anyway_ (due to the
    odd restrictions imposed by the documentation) having this
    code is just pointless.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • I only did superficial review, but these constants are stupid
    to have and without proper warnings nobody will review the
    code anyway, no amount of shouting will help.

    Also fix wimax to use correct states.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     

13 Dec, 2008

1 commit


26 Nov, 2008

1 commit

  • The rfkill class API requires that the driver connected to a class
    call rfkill_force_state() on resume to update the real state of the
    rfkill controller, OR that it provides a get_state() hook.

    This means there is potentially a hidden call in the resume code flow
    that changes rfkill->state (i.e. rfkill_force_state()), so the
    previous state of the transmitter was being lost.

    The simplest and most future-proof way to fix this is to explicitly
    store the pre-sleep state on the rfkill structure, and restore from
    that on resume.

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

    Henrique de Moraes Holschuh
     

23 Aug, 2008

3 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
     

30 Jul, 2008

1 commit


27 Jun, 2008

5 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
     
  • 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
     
  • 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
     
  • rfkill really should have been named rfswitch. As it is, one can get
    confused whether RFKILL_STATE_ON means the KILL switch is on (and
    therefore, the radio is being *blocked* from operating), or whether it
    means the RADIO rf output is on.

    Clearly state that RFKILL_STATE_ON means the radio is *unblocked* from
    operating (i.e. there is no rf killing going on).

    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
     

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
     

11 Oct, 2007

6 commits


08 Jun, 2007

1 commit