19 #include <linux/slab.h>
20 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/device.h>
28 #define MASTER_SHOW_COMPLEX(name, format_string, args...) \
29 static ssize_t name ## _show(struct device *dev, \
30 struct device_attribute *attr, char *buf) \
32 struct wpan_phy *phy = container_of(dev, struct wpan_phy, dev); \
35 mutex_lock(&phy->pib_lock); \
36 ret = snprintf(buf, PAGE_SIZE, format_string "\n", args); \
37 mutex_unlock(&phy->pib_lock); \
41 #define MASTER_SHOW(field, format_string) \
42 MASTER_SHOW_COMPLEX(field, format_string, phy->field)
47 ((
signed char) (
phy->transmit_power << 2)) >> 2,
48 (
phy->transmit_power >> 6) ? (
phy->transmit_power >> 6) * 3 : 1 );
59 for (i = 0; i < 32; i++) {
79 static void wpan_phy_release(
struct device *
d)
85 static struct class wpan_phy_class = {
87 .dev_release = wpan_phy_release,
88 .dev_attrs = pmib_attrs,
92 static int wpan_phy_idx;
94 static int wpan_phy_match(
struct device *dev,
void *
data)
96 return !
strcmp(dev_name(dev), (
const char *)data);
107 (
void *)str, wpan_phy_match);
120 static int wpan_phy_iter(
struct device *dev,
void *_data)
124 return wpid->
fn(phy, wpid->
data);
136 &wpid, wpan_phy_iter);
140 static int wpan_phy_idx_valid(
int idx)
147 struct wpan_phy *phy = kzalloc(
sizeof(*phy) + priv_size,
153 phy->
idx = wpan_phy_idx++;
167 phy->
dev.class = &wpan_phy_class;
197 static int __init wpan_phy_class_init(
void)
216 static void __exit wpan_phy_class_exit(
void)