diff options
author | Javier Cardona <javier@cozybit.com> | 2008-05-20 18:18:49 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-21 21:47:41 -0400 |
commit | b679aeb304e3070626750c15e043a40da0e942fc (patch) | |
tree | 03bf98085285006f8a035ae7ac2a03c830381549 /drivers/net/wireless/libertas/persistcfg.c | |
parent | edf5dabfa86163d589041cccf607b41a7033e9b0 (diff) |
libertas: sysfs interface for accessing default mesh channel
This will create the following entry:
/sys/class/net/mshX
-- boot_options
| |-- ...
| `-- channel
...
... which I overlooked on my previous patch.
Signed-off-by: Javier Cardona <javier@cozybit.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/persistcfg.c')
-rw-r--r-- | drivers/net/wireless/libertas/persistcfg.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/net/wireless/libertas/persistcfg.c b/drivers/net/wireless/libertas/persistcfg.c index baa662738895..6cf5e3949af8 100644 --- a/drivers/net/wireless/libertas/persistcfg.c +++ b/drivers/net/wireless/libertas/persistcfg.c | |||
@@ -130,6 +130,49 @@ static ssize_t boottime_set(struct device *dev, | |||
130 | } | 130 | } |
131 | 131 | ||
132 | /** | 132 | /** |
133 | * @brief Get function for sysfs attribute channel | ||
134 | */ | ||
135 | static ssize_t channel_get(struct device *dev, | ||
136 | struct device_attribute *attr, char *buf) | ||
137 | { | ||
138 | struct mrvl_mesh_defaults defs; | ||
139 | int ret; | ||
140 | |||
141 | ret = mesh_get_default_parameters(dev, &defs); | ||
142 | |||
143 | if (ret) | ||
144 | return ret; | ||
145 | |||
146 | return snprintf(buf, 12, "0x%x\n", le16_to_cpu(defs.channel)); | ||
147 | } | ||
148 | |||
149 | /** | ||
150 | * @brief Set function for sysfs attribute channel | ||
151 | */ | ||
152 | static ssize_t channel_set(struct device *dev, struct device_attribute *attr, | ||
153 | const char *buf, size_t count) | ||
154 | { | ||
155 | struct lbs_private *priv = to_net_dev(dev)->priv; | ||
156 | struct cmd_ds_mesh_config cmd; | ||
157 | uint16_t datum; | ||
158 | int ret; | ||
159 | |||
160 | memset(&cmd, 0, sizeof(cmd)); | ||
161 | ret = sscanf(buf, "%hx", &datum); | ||
162 | if (ret != 1 || datum < 1 || datum > 11) | ||
163 | return -EINVAL; | ||
164 | |||
165 | *((__le16 *)&cmd.data[0]) = cpu_to_le16(datum); | ||
166 | cmd.length = cpu_to_le16(sizeof(uint16_t)); | ||
167 | ret = lbs_mesh_config_send(priv, &cmd, CMD_ACT_MESH_CONFIG_SET, | ||
168 | CMD_TYPE_MESH_SET_DEF_CHANNEL); | ||
169 | if (ret) | ||
170 | return ret; | ||
171 | |||
172 | return strlen(buf); | ||
173 | } | ||
174 | |||
175 | /** | ||
133 | * @brief Get function for sysfs attribute mesh_id | 176 | * @brief Get function for sysfs attribute mesh_id |
134 | */ | 177 | */ |
135 | static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr, | 178 | static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr, |
@@ -365,6 +408,7 @@ static ssize_t capability_set(struct device *dev, struct device_attribute *attr, | |||
365 | 408 | ||
366 | static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set); | 409 | static DEVICE_ATTR(bootflag, 0644, bootflag_get, bootflag_set); |
367 | static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set); | 410 | static DEVICE_ATTR(boottime, 0644, boottime_get, boottime_set); |
411 | static DEVICE_ATTR(channel, 0644, channel_get, channel_set); | ||
368 | static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set); | 412 | static DEVICE_ATTR(mesh_id, 0644, mesh_id_get, mesh_id_set); |
369 | static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set); | 413 | static DEVICE_ATTR(protocol_id, 0644, protocol_id_get, protocol_id_set); |
370 | static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set); | 414 | static DEVICE_ATTR(metric_id, 0644, metric_id_get, metric_id_set); |
@@ -373,6 +417,7 @@ static DEVICE_ATTR(capability, 0644, capability_get, capability_set); | |||
373 | static struct attribute *boot_opts_attrs[] = { | 417 | static struct attribute *boot_opts_attrs[] = { |
374 | &dev_attr_bootflag.attr, | 418 | &dev_attr_bootflag.attr, |
375 | &dev_attr_boottime.attr, | 419 | &dev_attr_boottime.attr, |
420 | &dev_attr_channel.attr, | ||
376 | NULL | 421 | NULL |
377 | }; | 422 | }; |
378 | 423 | ||