debugfs_netdev.c (b89371621e5bedc84498ced2c5c33976bd1b2f64) debugfs_netdev.c (47846c9b0c10808d9337d2e7d09361f3e0a0a71a)
1/*
2 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
3 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */

--- 266 unchanged lines hidden (view full) ---

275 case NL80211_IFTYPE_AP_VLAN:
276 add_vlan_files(sdata);
277 break;
278 default:
279 break;
280 }
281}
282
1/*
2 * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
3 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */

--- 266 unchanged lines hidden (view full) ---

275 case NL80211_IFTYPE_AP_VLAN:
276 add_vlan_files(sdata);
277 break;
278 default:
279 break;
280 }
281}
282
283static int notif_registered;
284
285void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
286{
287 char buf[10+IFNAMSIZ];
288
283void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata)
284{
285 char buf[10+IFNAMSIZ];
286
289 if (!notif_registered)
290 return;
291
292 sprintf(buf, "netdev:%s", sdata->dev->name);
287 sprintf(buf, "netdev:%s", sdata->name);
293 sdata->debugfs.dir = debugfs_create_dir(buf,
294 sdata->local->hw.wiphy->debugfsdir);
295 add_files(sdata);
296}
297
298void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
299{
300 if (!sdata->debugfs.dir)
301 return;
302
303 debugfs_remove_recursive(sdata->debugfs.dir);
304 sdata->debugfs.dir = NULL;
305}
306
288 sdata->debugfs.dir = debugfs_create_dir(buf,
289 sdata->local->hw.wiphy->debugfsdir);
290 add_files(sdata);
291}
292
293void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
294{
295 if (!sdata->debugfs.dir)
296 return;
297
298 debugfs_remove_recursive(sdata->debugfs.dir);
299 sdata->debugfs.dir = NULL;
300}
301
307static int netdev_notify(struct notifier_block *nb,
308 unsigned long state,
309 void *ndev)
302void ieee80211_debugfs_rename_netdev(struct ieee80211_sub_if_data *sdata)
310{
303{
311 struct net_device *dev = ndev;
312 struct dentry *dir;
304 struct dentry *dir;
313 struct ieee80211_sub_if_data *sdata;
314 char buf[10+IFNAMSIZ];
305 char buf[10 + IFNAMSIZ];
315
306
316 if (state != NETDEV_CHANGENAME)
317 return 0;
318
319 if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy)
320 return 0;
321
322 if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
323 return 0;
324
325 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
326
327 dir = sdata->debugfs.dir;
328
329 if (!dir)
307 dir = sdata->debugfs.dir;
308
309 if (!dir)
330 return 0;
310 return;
331
311
332 sprintf(buf, "netdev:%s", dev->name);
312 sprintf(buf, "netdev:%s", sdata->name);
333 if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
334 printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs "
335 "dir to %s\n", buf);
313 if (!debugfs_rename(dir->d_parent, dir, dir->d_parent, buf))
314 printk(KERN_ERR "mac80211: debugfs: failed to rename debugfs "
315 "dir to %s\n", buf);
336
337 return 0;
338}
316}
339
340static struct notifier_block mac80211_debugfs_netdev_notifier = {
341 .notifier_call = netdev_notify,
342};
343
344void ieee80211_debugfs_netdev_init(void)
345{
346 int err;
347
348 err = register_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
349 if (err) {
350 printk(KERN_ERR
351 "mac80211: failed to install netdev notifier,"
352 " disabling per-netdev debugfs!\n");
353 } else
354 notif_registered = 1;
355}
356
357void ieee80211_debugfs_netdev_exit(void)
358{
359 unregister_netdevice_notifier(&mac80211_debugfs_netdev_notifier);
360 notif_registered = 0;
361}