aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/main.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-12-11 18:56:42 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:53 -0500
commit23a397ac821ab0aa263bda47131bb0628e49101a (patch)
treea631b5bb2b89885519791b46f712b04407692d6a /drivers/net/wireless/libertas/main.c
parente7240acae372727aa8eb3a67ca7b189dd261136a (diff)
libertas: add lbs_mesh sysfs attribute for enabling mesh
Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/main.c')
-rw-r--r--drivers/net/wireless/libertas/main.c74
1 files changed, 65 insertions, 9 deletions
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index c51d3af131fd..fd76c46225d1 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -254,6 +254,9 @@ static ssize_t lbs_anycast_set(struct device *dev,
254 254
255static int lbs_add_rtap(struct lbs_private *priv); 255static int lbs_add_rtap(struct lbs_private *priv);
256static void lbs_remove_rtap(struct lbs_private *priv); 256static void lbs_remove_rtap(struct lbs_private *priv);
257static int lbs_add_mesh(struct lbs_private *priv);
258static void lbs_remove_mesh(struct lbs_private *priv);
259
257 260
258/** 261/**
259 * Get function for sysfs attribute rtap 262 * Get function for sysfs attribute rtap
@@ -312,11 +315,53 @@ static ssize_t lbs_rtap_set(struct device *dev,
312} 315}
313 316
314/** 317/**
315 * lbs_rtap attribute to be exported per mshX interface 318 * lbs_rtap attribute to be exported per ethX interface
316 * through sysfs (/sys/class/net/mshX/libertas-rtap) 319 * through sysfs (/sys/class/net/ethX/lbs_rtap)
317 */ 320 */
318static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, 321static DEVICE_ATTR(lbs_rtap, 0644, lbs_rtap_get, lbs_rtap_set );
319 lbs_rtap_set ); 322
323/**
324 * Get function for sysfs attribute mesh
325 */
326static ssize_t lbs_mesh_get(struct device *dev,
327 struct device_attribute *attr, char * buf)
328{
329 struct lbs_private *priv = to_net_dev(dev)->priv;
330 return snprintf(buf, 5, "0x%X\n", !!priv->mesh_dev);
331}
332
333/**
334 * Set function for sysfs attribute mesh
335 */
336static ssize_t lbs_mesh_set(struct device *dev,
337 struct device_attribute *attr, const char * buf, size_t count)
338{
339 struct lbs_private *priv = to_net_dev(dev)->priv;
340 int enable;
341 int ret;
342
343 sscanf(buf, "%x", &enable);
344 enable = !!enable;
345 if (enable == !!priv->mesh_dev)
346 return count;
347
348 ret = lbs_mesh_config(priv, enable);
349 if (ret)
350 return ret;
351
352 if (enable)
353 lbs_add_mesh(priv);
354 else
355 lbs_remove_mesh(priv);
356
357 return count;
358}
359
360/**
361 * lbs_mesh attribute to be exported per ethX interface
362 * through sysfs (/sys/class/net/ethX/lbs_mesh)
363 */
364static DEVICE_ATTR(lbs_mesh, 0644, lbs_mesh_get, lbs_mesh_set);
320 365
321/** 366/**
322 * anycast_mask attribute to be exported per mshX interface 367 * anycast_mask attribute to be exported per mshX interface
@@ -867,7 +912,9 @@ static int lbs_setup_firmware(struct lbs_private *priv)
867 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_AUTOSTART_ENABLED, 912 ret = lbs_mesh_access(priv, CMD_ACT_MESH_SET_AUTOSTART_ENABLED,
868 &mesh_access); 913 &mesh_access);
869 if (ret) { 914 if (ret) {
870 ret = -1; 915 printk("Mesh autostart set failed\n");
916 ret = 0;
917 //ret = -1;
871 goto done; 918 goto done;
872 } 919 }
873 priv->mesh_autostart_enabled = 0; 920 priv->mesh_autostart_enabled = 0;
@@ -1059,6 +1106,9 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
1059 INIT_DELAYED_WORK(&priv->scan_work, lbs_scan_worker); 1106 INIT_DELAYED_WORK(&priv->scan_work, lbs_scan_worker);
1060 INIT_WORK(&priv->sync_channel, lbs_sync_channel); 1107 INIT_WORK(&priv->sync_channel, lbs_sync_channel);
1061 1108
1109 sprintf(priv->mesh_ssid, "mesh");
1110 priv->mesh_ssid_len = 4;
1111
1062 goto done; 1112 goto done;
1063 1113
1064err_init_adapter: 1114err_init_adapter:
@@ -1080,6 +1130,7 @@ int lbs_remove_card(struct lbs_private *priv)
1080 1130
1081 lbs_deb_enter(LBS_DEB_MAIN); 1131 lbs_deb_enter(LBS_DEB_MAIN);
1082 1132
1133 lbs_remove_mesh(priv);
1083 lbs_remove_rtap(priv); 1134 lbs_remove_rtap(priv);
1084 1135
1085 dev = priv->dev; 1136 dev = priv->dev;
@@ -1133,6 +1184,8 @@ int lbs_start_card(struct lbs_private *priv)
1133 } 1184 }
1134 if (device_create_file(&dev->dev, &dev_attr_lbs_rtap)) 1185 if (device_create_file(&dev->dev, &dev_attr_lbs_rtap))
1135 lbs_pr_err("cannot register lbs_rtap attribute\n"); 1186 lbs_pr_err("cannot register lbs_rtap attribute\n");
1187 if (device_create_file(&dev->dev, &dev_attr_lbs_mesh))
1188 lbs_pr_err("cannot register lbs_mesh attribute\n");
1136 1189
1137 lbs_debugfs_init_one(priv, dev); 1190 lbs_debugfs_init_one(priv, dev);
1138 1191
@@ -1161,6 +1214,7 @@ int lbs_stop_card(struct lbs_private *priv)
1161 1214
1162 lbs_debugfs_remove_one(priv); 1215 lbs_debugfs_remove_one(priv);
1163 device_remove_file(&dev->dev, &dev_attr_lbs_rtap); 1216 device_remove_file(&dev->dev, &dev_attr_lbs_rtap);
1217 device_remove_file(&dev->dev, &dev_attr_lbs_mesh);
1164 1218
1165 /* Flush pending command nodes */ 1219 /* Flush pending command nodes */
1166 spin_lock_irqsave(&priv->driver_lock, flags); 1220 spin_lock_irqsave(&priv->driver_lock, flags);
@@ -1184,7 +1238,7 @@ EXPORT_SYMBOL_GPL(lbs_stop_card);
1184 * @param priv A pointer to the struct lbs_private structure 1238 * @param priv A pointer to the struct lbs_private structure
1185 * @return 0 if successful, -X otherwise 1239 * @return 0 if successful, -X otherwise
1186 */ 1240 */
1187int lbs_add_mesh(struct lbs_private *priv, struct device *dev) 1241static int lbs_add_mesh(struct lbs_private *priv)
1188{ 1242{
1189 struct net_device *mesh_dev = NULL; 1243 struct net_device *mesh_dev = NULL;
1190 int ret = 0; 1244 int ret = 0;
@@ -1209,7 +1263,7 @@ int lbs_add_mesh(struct lbs_private *priv, struct device *dev)
1209 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr, 1263 memcpy(mesh_dev->dev_addr, priv->dev->dev_addr,
1210 sizeof(priv->dev->dev_addr)); 1264 sizeof(priv->dev->dev_addr));
1211 1265
1212 SET_NETDEV_DEV(priv->mesh_dev, dev); 1266 SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
1213 1267
1214#ifdef WIRELESS_EXT 1268#ifdef WIRELESS_EXT
1215 mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def; 1269 mesh_dev->wireless_handlers = (struct iw_handler_def *)&mesh_handler_def;
@@ -1242,7 +1296,7 @@ done:
1242EXPORT_SYMBOL_GPL(lbs_add_mesh); 1296EXPORT_SYMBOL_GPL(lbs_add_mesh);
1243 1297
1244 1298
1245void lbs_remove_mesh(struct lbs_private *priv) 1299static void lbs_remove_mesh(struct lbs_private *priv)
1246{ 1300{
1247 struct net_device *mesh_dev; 1301 struct net_device *mesh_dev;
1248 1302
@@ -1252,6 +1306,8 @@ void lbs_remove_mesh(struct lbs_private *priv)
1252 goto out; 1306 goto out;
1253 1307
1254 mesh_dev = priv->mesh_dev; 1308 mesh_dev = priv->mesh_dev;
1309 if (!mesh_dev)
1310 goto out;
1255 1311
1256 netif_stop_queue(mesh_dev); 1312 netif_stop_queue(mesh_dev);
1257 netif_carrier_off(priv->mesh_dev); 1313 netif_carrier_off(priv->mesh_dev);
@@ -1259,7 +1315,7 @@ void lbs_remove_mesh(struct lbs_private *priv)
1259 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group); 1315 sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
1260 unregister_netdev(mesh_dev); 1316 unregister_netdev(mesh_dev);
1261 1317
1262 priv->mesh_dev = NULL ; 1318 priv->mesh_dev = NULL;
1263 free_netdev(mesh_dev); 1319 free_netdev(mesh_dev);
1264 1320
1265out: 1321out: