1 /* This program is free software; you can redistribute it and/or modify
2 * it under the terms of the GNU General Public License version 2
3 * as published by the Free Software Foundation.
5 * This program is distributed in the hope that it will be useful,
6 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 * GNU General Public License for more details.
13 * Based on: net/wireless/sysfs.c
16 #include <linux/device.h>
18 #include <net/cfg802154.h>
23 static inline struct cfg802154_registered_device *
24 dev_to_rdev(struct device *dev)
26 return container_of(dev, struct cfg802154_registered_device,
30 #define SHOW_FMT(name, fmt, member) \
31 static ssize_t name ## _show(struct device *dev, \
32 struct device_attribute *attr, \
35 return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \
37 static DEVICE_ATTR_RO(name)
39 SHOW_FMT(index, "%d", wpan_phy_idx);
41 static ssize_t name_show(struct device *dev,
42 struct device_attribute *attr,
45 struct wpan_phy *wpan_phy = &dev_to_rdev(dev)->wpan_phy;
47 return sprintf(buf, "%s\n", dev_name(&wpan_phy->dev));
49 static DEVICE_ATTR_RO(name);
51 static void wpan_phy_release(struct device *dev)
53 struct cfg802154_registered_device *rdev = dev_to_rdev(dev);
55 cfg802154_dev_free(rdev);
58 static struct attribute *pmib_attrs[] = {
63 ATTRIBUTE_GROUPS(pmib);
65 struct class wpan_phy_class = {
67 .dev_release = wpan_phy_release,
68 .dev_groups = pmib_groups,
71 int wpan_phy_sysfs_init(void)
73 return class_register(&wpan_phy_class);
76 void wpan_phy_sysfs_exit(void)
78 class_unregister(&wpan_phy_class);