netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] allow setting wiphy.perm_addr after driver probe
@ 2014-08-11 18:04 Daniel Gimpelevich
  2014-08-11 20:25 ` Marcel Holtmann
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Gimpelevich @ 2014-08-11 18:04 UTC (permalink / raw)
  To: John W. Linville
  Cc: linux-wireless, Johannes Berg, David S. Miller, netdev,
	linux-kernel

On embedded devices, often the BSSID of an access point must be set from
userspace during the boot process. This provides a relatively clean way
of doing that without major side effects.

Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
--- 
--- a/net/wireless/sysfs.c	2014-04-19 08:36:52.048511623 -0700
+++ b/net/wireless/sysfs.c	2014-04-19 08:38:09.196894176 -0700
@@ -24,18 +24,30 @@
 	return container_of(dev, struct cfg80211_registered_device, wiphy.dev);
 }
 
-#define SHOW_FMT(name, fmt, member)					\
+#define SHOW_FMT(name, fmt, member, perm)				\
 static ssize_t name ## _show(struct device *dev,			\
 			      struct device_attribute *attr,		\
 			      char *buf)				\
 {									\
 	return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member);	\
 }									\
-static DEVICE_ATTR_RO(name)
+static DEVICE_ATTR_ ## perm(name)
 
-SHOW_FMT(index, "%d", wiphy_idx);
-SHOW_FMT(macaddress, "%pM", wiphy.perm_addr);
-SHOW_FMT(address_mask, "%pM", wiphy.addr_mask);
+static ssize_t macaddress_store(struct device *dev,
+			      struct device_attribute *attr,
+			      const char *buf, size_t count)
+{
+	u8 temp[ETH_ALEN];
+
+	if (sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", temp, temp + 1,
+			temp + 2, temp + 3, temp + 4, temp + 5) == ETH_ALEN)
+		memcpy(dev_to_rdev(dev)->wiphy.perm_addr, temp, ETH_ALEN);
+	return count;
+}
+
+SHOW_FMT(index, "%d", wiphy_idx, RO);
+SHOW_FMT(macaddress, "%pM", wiphy.perm_addr, RW);
+SHOW_FMT(address_mask, "%pM", wiphy.addr_mask, RO);
 
 static ssize_t name_show(struct device *dev,
 			 struct device_attribute *attr,

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-08-12  8:43 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-11 18:04 [PATCH] allow setting wiphy.perm_addr after driver probe Daniel Gimpelevich
2014-08-11 20:25 ` Marcel Holtmann
2014-08-11 20:40   ` Daniel Gimpelevich
2014-08-11 20:56     ` Marcel Holtmann
2014-08-11 21:04       ` Daniel Gimpelevich
2014-08-11 22:41         ` Marcel Holtmann
2014-08-11 23:12           ` Daniel Gimpelevich
2014-08-11 23:56             ` Marcel Holtmann
     [not found]               ` <52896C9C-8560-4CE4-A1FB-C896D766EC87-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
2014-08-12  0:01                 ` Daniel Gimpelevich
2014-08-12  7:59                   ` Marcel Holtmann
     [not found]                     ` <70001DBA-E1CE-49D6-9A37-6F7CE31B61E6-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>
2014-08-12  8:43                       ` Jonas Gorski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).