Commit b46b28d1 authored by Dan Williams's avatar Dan Williams

wifi: remove old ipw rfkill polling functionality

Older Intel "ipw" devices (ipw2100, ipw2200, and ipw2915) only gained
kernel rfkill subsystem integration with 2.6.33.  Before then their
custom rfkill functionality had to be polled via sysfs.  Since we now
require at least a 3.x kernel, remove this old code.
parent b5ffcf46
......@@ -96,7 +96,6 @@ enum {
PROP_ACTIVE_ACCESS_POINT,
PROP_CAPABILITIES,
PROP_SCANNING,
PROP_IPW_RFKILL_STATE,
LAST_PROP
};
......@@ -129,11 +128,6 @@ struct _NMDeviceWifiPrivate {
guint8 perm_hw_addr[ETH_ALEN]; /* Permanent MAC address */
guint8 initial_hw_addr[ETH_ALEN]; /* Initial MAC address (as seen when NM starts) */
/* Legacy rfkill for ipw2x00; will be fixed with 2.6.33 kernel */
char * ipw_rfkill_path;
guint ipw_rfkill_id;
RfKillState ipw_rfkill_state;
gint8 invalid_strength_counter;
GSList * ap_list;
......@@ -218,68 +212,6 @@ nm_wifi_error_quark (void)
/*****************************************************************/
/* IPW rfkill handling (until 2.6.33) */
RfKillState
nm_device_wifi_get_ipw_rfkill_state (NMDeviceWifi *self)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
char *contents = NULL;
RfKillState state = RFKILL_UNBLOCKED;
const char *str_state = NULL;
if ( priv->ipw_rfkill_path
&& (contents = nm_platform_sysctl_get (priv->ipw_rfkill_path))) {
if (strlen (contents) != 1)
contents[0] = 0;
/* 0 - RF kill not enabled
* 1 - SW based RF kill active (sysfs)
* 2 - HW based RF kill active
* 3 - Both HW and SW baed RF kill active
*/
switch (contents[0]) {
case '1':
state = RFKILL_SOFT_BLOCKED;
str_state = "soft-blocked";
break;
case '2':
case '3':
state = RFKILL_HARD_BLOCKED;
str_state = "hard-blocked";
break;
case '0':
str_state = "unblocked";
default:
break;
}
g_free (contents);
nm_log_dbg (LOGD_RFKILL, "(%s): ipw rfkill state '%s'",
nm_device_get_iface (NM_DEVICE (self)),
str_state ? str_state : "(unknown)");
}
return state;
}
static gboolean
ipw_rfkill_state_work (gpointer user_data)
{
NMDeviceWifi *self = NM_DEVICE_WIFI (user_data);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
RfKillState old_state;
old_state = priv->ipw_rfkill_state;
priv->ipw_rfkill_state = nm_device_wifi_get_ipw_rfkill_state (self);
if (priv->ipw_rfkill_state != old_state)
g_object_notify (G_OBJECT (self), NM_DEVICE_WIFI_IPW_RFKILL_STATE);
return TRUE;
}
/*****************************************************************/
static GObject*
constructor (GType type,
guint n_construct_params,
......@@ -319,22 +251,6 @@ constructor (GType type,
priv->supplicant.mgr = nm_supplicant_manager_get ();
g_assert (priv->supplicant.mgr);
/* The ipw2x00 drivers don't integrate with the kernel rfkill subsystem until
* 2.6.33. Thus all our nice libgudev magic is useless. So we get to poll.
*
* FIXME: when 2.6.33 comes lands, we can do some sysfs parkour to figure out
* if we need to poll or not by matching /sys/class/net/ethX/device to one
* of the /sys/class/rfkill/rfkillX/device links. If there's a match, we
* don't have to poll.
*/
priv->ipw_rfkill_path = g_strdup_printf ("/sys/class/net/%s/device/rf_kill",
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (NM_DEVICE (self))));
if (!g_file_test (priv->ipw_rfkill_path, G_FILE_TEST_IS_REGULAR)) {
g_free (priv->ipw_rfkill_path);
priv->ipw_rfkill_path = NULL;
}
priv->ipw_rfkill_state = nm_device_wifi_get_ipw_rfkill_state (self);
return object;
}
......@@ -3388,19 +3304,6 @@ device_state_changed (NMDevice *device,
remove_all_aps (self);
}
/* Start or stop the rfkill poll worker for ipw cards */
if (priv->ipw_rfkill_path) {
if (new_state > NM_DEVICE_STATE_UNMANAGED) {
if (!priv->ipw_rfkill_id)
priv->ipw_rfkill_id = g_timeout_add_seconds (3, ipw_rfkill_state_work, self);
} else if (new_state <= NM_DEVICE_STATE_UNMANAGED) {
if (priv->ipw_rfkill_id) {
g_source_remove (priv->ipw_rfkill_id);
priv->ipw_rfkill_id = 0;
}
}
}
switch (new_state) {
case NM_DEVICE_STATE_UNMANAGED:
clear_aps = TRUE;
......@@ -3551,12 +3454,6 @@ dispose (GObject *object)
remove_all_aps (self);
g_free (priv->ipw_rfkill_path);
if (priv->ipw_rfkill_id) {
g_source_remove (priv->ipw_rfkill_id);
priv->ipw_rfkill_id = 0;
}
G_OBJECT_CLASS (nm_device_wifi_parent_class)->dispose (object);
}
......@@ -3597,9 +3494,6 @@ get_property (GObject *object, guint prop_id,
case PROP_SCANNING:
g_value_set_boolean (value, nm_supplicant_interface_get_scanning (priv->supplicant.iface));
break;
case PROP_IPW_RFKILL_STATE:
g_value_set_uint (value, nm_device_wifi_get_ipw_rfkill_state (device));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -3610,13 +3504,7 @@ static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (object);
switch (prop_id) {
case PROP_IPW_RFKILL_STATE:
/* construct only */
priv->ipw_rfkill_state = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -3714,13 +3602,6 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
FALSE,
G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_IPW_RFKILL_STATE,
g_param_spec_uint (NM_DEVICE_WIFI_IPW_RFKILL_STATE,
"IpwRfkillState",
"ipw rf-kill state",
RFKILL_UNBLOCKED, RFKILL_HARD_BLOCKED, RFKILL_UNBLOCKED,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/* Signals */
signals[ACCESS_POINT_ADDED] =
g_signal_new ("access-point-added",
......
......@@ -26,7 +26,6 @@
#include <dbus/dbus.h>
#include <net/ethernet.h>
#include "nm-rfkill-manager.h"
#include "nm-device.h"
#include "nm-wifi-ap.h"
......@@ -58,7 +57,6 @@ typedef enum {
#define NM_DEVICE_WIFI_ACTIVE_ACCESS_POINT "active-access-point"
#define NM_DEVICE_WIFI_CAPABILITIES "wireless-capabilities"
#define NM_DEVICE_WIFI_SCANNING "scanning"
#define NM_DEVICE_WIFI_IPW_RFKILL_STATE "ipw-rfkill-state"
#ifndef NM_DEVICE_WIFI_DEFINED
#define NM_DEVICE_WIFI_DEFINED
......@@ -92,8 +90,6 @@ GType nm_device_wifi_get_type (void);
NMDevice *nm_device_wifi_new (NMPlatformLink *platform_device);
RfKillState nm_device_wifi_get_ipw_rfkill_state (NMDeviceWifi *self);
G_END_DECLS
#endif /* NM_DEVICE_WIFI_H */
......@@ -168,7 +168,6 @@ typedef struct {
const char *key;
const char *prop;
const char *hw_prop;
RfKillState (*other_enabled_func) (NMManager *);
} RadioState;
typedef struct {
......@@ -1343,40 +1342,25 @@ manager_hidden_ap_found (NMDevice *device,
g_slist_free (connections);
}
static RfKillState
nm_manager_get_ipw_rfkill_state (NMManager *self)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
GSList *iter;
RfKillState ipw_state = RFKILL_UNBLOCKED;
for (iter = priv->devices; iter; iter = g_slist_next (iter)) {
NMDevice *candidate = NM_DEVICE (iter->data);
RfKillState candidate_state;
if (nm_device_get_device_type (candidate) == NM_DEVICE_TYPE_WIFI) {
candidate_state = nm_device_wifi_get_ipw_rfkill_state (NM_DEVICE_WIFI (candidate));
if (candidate_state > ipw_state)
ipw_state = candidate_state;
}
}
return ipw_state;
}
static void
update_rstate_from_rfkill (RadioState *rstate, RfKillState rfkill)
update_rstate_from_rfkill (NMRfkillManager *rfkill_mgr, RadioState *rstate)
{
if (rfkill == RFKILL_UNBLOCKED) {
switch (nm_rfkill_manager_get_rfkill_state (rfkill_mgr, rstate->rtype)) {
case RFKILL_UNBLOCKED:
rstate->sw_enabled = TRUE;
rstate->hw_enabled = TRUE;
} else if (rfkill == RFKILL_SOFT_BLOCKED) {
break;
case RFKILL_SOFT_BLOCKED:
rstate->sw_enabled = FALSE;
rstate->hw_enabled = TRUE;
} else if (rfkill == RFKILL_HARD_BLOCKED) {
break;
case RFKILL_HARD_BLOCKED:
rstate->sw_enabled = FALSE;
rstate->hw_enabled = FALSE;
break;
default:
g_warn_if_reached ();
break;
}
}
......@@ -1386,29 +1370,14 @@ manager_rfkill_update_one_type (NMManager *self,
RfKillType rtype)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
RfKillState udev_state = RFKILL_UNBLOCKED;
RfKillState other_state = RFKILL_UNBLOCKED;
RfKillState composite;
gboolean old_enabled, new_enabled, old_rfkilled, new_rfkilled, old_hwe;
old_enabled = radio_enabled_for_rstate (rstate, TRUE);
old_rfkilled = rstate->hw_enabled && rstate->sw_enabled;
old_hwe = rstate->hw_enabled;
udev_state = nm_rfkill_manager_get_rfkill_state (priv->rfkill_mgr, rtype);
if (rstate->other_enabled_func)
other_state = rstate->other_enabled_func (self);
/* The composite state is the "worst" of either udev or other states */
if (udev_state == RFKILL_HARD_BLOCKED || other_state == RFKILL_HARD_BLOCKED)
composite = RFKILL_HARD_BLOCKED;
else if (udev_state == RFKILL_SOFT_BLOCKED || other_state == RFKILL_SOFT_BLOCKED)
composite = RFKILL_SOFT_BLOCKED;
else
composite = RFKILL_UNBLOCKED;
update_rstate_from_rfkill (rstate, composite);
/* recheck kernel rfkill state */
update_rstate_from_rfkill (priv->rfkill_mgr, rstate);
/* Print out all states affecting device enablement */
if (rstate->desc) {
......@@ -1455,14 +1424,6 @@ nm_manager_rfkill_update (NMManager *self, RfKillType rtype)
}
}
static void
manager_ipw_rfkill_state_changed (NMDeviceWifi *device,
GParamSpec *pspec,
gpointer user_data)
{
nm_manager_rfkill_update (NM_MANAGER (user_data), RFKILL_TYPE_WLAN);
}
static void
device_auth_done_cb (NMAuthChain *chain,
GError *auth_error,
......@@ -1735,13 +1696,6 @@ add_device (NMManager *self, NMDevice *device, gboolean generate_con)
g_signal_connect (device, "hidden-ap-found",
G_CALLBACK (manager_hidden_ap_found),
self);
/* Hook up rfkill handling for ipw-based cards until they get converted
* to use the kernel's rfkill subsystem in 2.6.33.
*/
g_signal_connect (device, "notify::" NM_DEVICE_WIFI_IPW_RFKILL_STATE,
G_CALLBACK (manager_ipw_rfkill_state_changed),
self);
}
/* Update global rfkill state for this device type with the device's
......@@ -4100,14 +4054,13 @@ nm_manager_start (NMManager *self)
/* Set initial radio enabled/disabled state */
for (i = 0; i < RFKILL_TYPE_MAX; i++) {
RadioState *rstate = &priv->radio_states[i];
RfKillState udev_state;
gboolean enabled;
if (!rstate->desc)
continue;
udev_state = nm_rfkill_manager_get_rfkill_state (priv->rfkill_mgr, i);
update_rstate_from_rfkill (rstate, udev_state);
/* recheck kernel rfkill state */
update_rstate_from_rfkill (priv->rfkill_mgr, rstate);
if (rstate->desc) {
nm_log_info (LOGD_RFKILL, "%s %s by radio killswitch; %s by state file",
......@@ -4730,7 +4683,6 @@ nm_manager_init (NMManager *manager)
priv->radio_states[RFKILL_TYPE_WLAN].prop = NM_MANAGER_WIRELESS_ENABLED;
priv->radio_states[RFKILL_TYPE_WLAN].hw_prop = NM_MANAGER_WIRELESS_HARDWARE_ENABLED;
priv->radio_states[RFKILL_TYPE_WLAN].desc = "WiFi";
priv->radio_states[RFKILL_TYPE_WLAN].other_enabled_func = nm_manager_get_ipw_rfkill_state;
priv->radio_states[RFKILL_TYPE_WLAN].rtype = RFKILL_TYPE_WLAN;
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = TRUE;
......@@ -4745,7 +4697,6 @@ nm_manager_init (NMManager *manager)
priv->radio_states[RFKILL_TYPE_WIMAX].prop = NM_MANAGER_WIMAX_ENABLED;
priv->radio_states[RFKILL_TYPE_WIMAX].hw_prop = NM_MANAGER_WIMAX_HARDWARE_ENABLED;
priv->radio_states[RFKILL_TYPE_WIMAX].desc = "WiMAX";
priv->radio_states[RFKILL_TYPE_WIMAX].other_enabled_func = NULL;
priv->radio_states[RFKILL_TYPE_WIMAX].rtype = RFKILL_TYPE_WIMAX;
for (i = 0; i < RFKILL_TYPE_MAX; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment