~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/net/ieee802154/sysfs.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  *
  4  * Authors:
  5  * Alexander Aring <aar@pengutronix.de>
  6  *
  7  * Based on: net/wireless/sysfs.c
  8  */
  9 
 10 #include <linux/device.h>
 11 #include <linux/rtnetlink.h>
 12 
 13 #include <net/cfg802154.h>
 14 
 15 #include "core.h"
 16 #include "sysfs.h"
 17 #include "rdev-ops.h"
 18 
 19 static inline struct cfg802154_registered_device *
 20 dev_to_rdev(struct device *dev)
 21 {
 22         return container_of(dev, struct cfg802154_registered_device,
 23                             wpan_phy.dev);
 24 }
 25 
 26 #define SHOW_FMT(name, fmt, member)                                     \
 27 static ssize_t name ## _show(struct device *dev,                        \
 28                              struct device_attribute *attr,             \
 29                              char *buf)                                 \
 30 {                                                                       \
 31         return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member);        \
 32 }                                                                       \
 33 static DEVICE_ATTR_RO(name)
 34 
 35 SHOW_FMT(index, "%d", wpan_phy_idx);
 36 
 37 static ssize_t name_show(struct device *dev,
 38                          struct device_attribute *attr,
 39                          char *buf)
 40 {
 41         struct wpan_phy *wpan_phy = &dev_to_rdev(dev)->wpan_phy;
 42 
 43         return sprintf(buf, "%s\n", dev_name(&wpan_phy->dev));
 44 }
 45 static DEVICE_ATTR_RO(name);
 46 
 47 static void wpan_phy_release(struct device *dev)
 48 {
 49         struct cfg802154_registered_device *rdev = dev_to_rdev(dev);
 50 
 51         cfg802154_dev_free(rdev);
 52 }
 53 
 54 static struct attribute *pmib_attrs[] = {
 55         &dev_attr_index.attr,
 56         &dev_attr_name.attr,
 57         NULL,
 58 };
 59 ATTRIBUTE_GROUPS(pmib);
 60 
 61 #ifdef CONFIG_PM_SLEEP
 62 static int wpan_phy_suspend(struct device *dev)
 63 {
 64         struct cfg802154_registered_device *rdev = dev_to_rdev(dev);
 65         int ret = 0;
 66 
 67         if (rdev->ops->suspend) {
 68                 rtnl_lock();
 69                 ret = rdev_suspend(rdev);
 70                 rtnl_unlock();
 71         }
 72 
 73         return ret;
 74 }
 75 
 76 static int wpan_phy_resume(struct device *dev)
 77 {
 78         struct cfg802154_registered_device *rdev = dev_to_rdev(dev);
 79         int ret = 0;
 80 
 81         if (rdev->ops->resume) {
 82                 rtnl_lock();
 83                 ret = rdev_resume(rdev);
 84                 rtnl_unlock();
 85         }
 86 
 87         return ret;
 88 }
 89 
 90 static SIMPLE_DEV_PM_OPS(wpan_phy_pm_ops, wpan_phy_suspend, wpan_phy_resume);
 91 #define WPAN_PHY_PM_OPS (&wpan_phy_pm_ops)
 92 #else
 93 #define WPAN_PHY_PM_OPS NULL
 94 #endif
 95 
 96 const struct class wpan_phy_class = {
 97         .name = "ieee802154",
 98         .dev_release = wpan_phy_release,
 99         .dev_groups = pmib_groups,
100         .pm = WPAN_PHY_PM_OPS,
101 };
102 
103 int wpan_phy_sysfs_init(void)
104 {
105         return class_register(&wpan_phy_class);
106 }
107 
108 void wpan_phy_sysfs_exit(void)
109 {
110         class_unregister(&wpan_phy_class);
111 }
112 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php