* [PATCH] wireless: Print wiphy name in sysfs.
@ 2010-10-11 17:28 greearb
2010-10-11 17:58 ` Johannes Berg
0 siblings, 1 reply; 7+ messages in thread
From: greearb @ 2010-10-11 17:28 UTC (permalink / raw)
To: linux-wireless; +Cc: Ben Greear
From: Ben Greear <greearb@candelatech.com>
The index cannot be used to reliably reconstruct a phy
name, so explicitly add the phy name to sysfs so that scripts
can figure out the parent phy device for a particular
wireless interface.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 74a9e3c... 4294fa2... M net/wireless/sysfs.c
net/wireless/sysfs.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c
index 74a9e3c..4294fa2 100644
--- a/net/wireless/sysfs.c
+++ b/net/wireless/sysfs.c
@@ -35,6 +35,14 @@ SHOW_FMT(index, "%d", wiphy_idx);
SHOW_FMT(macaddress, "%pM", wiphy.perm_addr);
SHOW_FMT(address_mask, "%pM", wiphy.addr_mask);
+static ssize_t name_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct wiphy *wiphy = &dev_to_rdev(dev)->wiphy;
+ return sprintf(buf, "%s\n", dev_name(&wiphy->dev));
+}
+
+
static ssize_t addresses_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -57,6 +65,7 @@ static struct device_attribute ieee80211_dev_attrs[] = {
__ATTR_RO(macaddress),
__ATTR_RO(address_mask),
__ATTR_RO(addresses),
+ __ATTR_RO(name),
{}
};
--
1.7.2.2
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] wireless: Print wiphy name in sysfs.
2010-10-11 17:28 [PATCH] wireless: Print wiphy name in sysfs greearb
@ 2010-10-11 17:58 ` Johannes Berg
2010-10-11 18:04 ` Ben Greear
0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2010-10-11 17:58 UTC (permalink / raw)
To: greearb; +Cc: linux-wireless
On Mon, 2010-10-11 at 10:28 -0700, greearb@candelatech.com wrote:
> The index cannot be used to reliably reconstruct a phy
> name, so explicitly add the phy name to sysfs so that scripts
> can figure out the parent phy device for a particular
> wireless interface.
But you still need to know the name to get at this to start with, so
what's the point?
cat /sys/class/ieee80211/<phyname>/name
<phyname>
or
cat /sys/devices/pci0000:00/0000:00:15.0/0000:03:00.0/ssb0:0/ieee80211/phy0/name
phy0
johannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wireless: Print wiphy name in sysfs.
2010-10-11 17:58 ` Johannes Berg
@ 2010-10-11 18:04 ` Ben Greear
2010-10-11 18:10 ` Johannes Berg
0 siblings, 1 reply; 7+ messages in thread
From: Ben Greear @ 2010-10-11 18:04 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
On 10/11/2010 10:58 AM, Johannes Berg wrote:
> On Mon, 2010-10-11 at 10:28 -0700, greearb@candelatech.com wrote:
>
>> The index cannot be used to reliably reconstruct a phy
>> name, so explicitly add the phy name to sysfs so that scripts
>> can figure out the parent phy device for a particular
>> wireless interface.
>
> But you still need to know the name to get at this to start with, so
> what's the point?
>
> cat /sys/class/ieee80211/<phyname>/name
> <phyname>
>
> or
>
> cat /sys/devices/pci0000:00/0000:00:15.0/0000:03:00.0/ssb0:0/ieee80211/phy0/name
> phy0
I use this to determine the phy device for a particular network device:
[root@dx-2u-ath5k lanforge]# cat /sys/class/net/wlan0/phy80211/name
wiphy0
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wireless: Print wiphy name in sysfs.
2010-10-11 18:04 ` Ben Greear
@ 2010-10-11 18:10 ` Johannes Berg
2010-10-11 18:22 ` Ben Greear
0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2010-10-11 18:10 UTC (permalink / raw)
To: Ben Greear; +Cc: linux-wireless
On Mon, 2010-10-11 at 11:04 -0700, Ben Greear wrote:
> I use this to determine the phy device for a particular network device:
>
> [root@dx-2u-ath5k lanforge]# cat /sys/class/net/wlan0/phy80211/name
> wiphy0
What's wrong with
basename $(readlink /sys/class/net/wlan0/phy80211)
?
johannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wireless: Print wiphy name in sysfs.
2010-10-11 18:10 ` Johannes Berg
@ 2010-10-11 18:22 ` Ben Greear
2010-10-11 18:42 ` Johannes Berg
0 siblings, 1 reply; 7+ messages in thread
From: Ben Greear @ 2010-10-11 18:22 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
On 10/11/2010 11:10 AM, Johannes Berg wrote:
> On Mon, 2010-10-11 at 11:04 -0700, Ben Greear wrote:
>
>
>> I use this to determine the phy device for a particular network device:
>>
>> [root@dx-2u-ath5k lanforge]# cat /sys/class/net/wlan0/phy80211/name
>> wiphy0
>
> What's wrong with
>
> basename $(readlink /sys/class/net/wlan0/phy80211)
It looks like that could work, but it seems a lot easier to probe
network devices via normal manner, and then check if I can just
open and read /sys/class/net/[dev-name]/phy80211/name
I can do that easily from within a C/C++ program, where as
doing system calls and grabbing standard output is more of
a pain (and more overhead).
But, if you don't want to add my patch, it's not a big deal.
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wireless: Print wiphy name in sysfs.
2010-10-11 18:22 ` Ben Greear
@ 2010-10-11 18:42 ` Johannes Berg
2010-10-11 18:50 ` Ben Greear
0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2010-10-11 18:42 UTC (permalink / raw)
To: Ben Greear; +Cc: linux-wireless
On Mon, 2010-10-11 at 11:22 -0700, Ben Greear wrote:
> > basename $(readlink /sys/class/net/wlan0/phy80211)
>
> It looks like that could work, but it seems a lot easier to probe
> network devices via normal manner, and then check if I can just
> open and read /sys/class/net/[dev-name]/phy80211/name
>
> I can do that easily from within a C/C++ program, where as
> doing system calls and grabbing standard output is more of
> a pain (and more overhead).
>
> But, if you don't want to add my patch, it's not a big deal.
I don't really mind, it just didn't seem necessary. FWIW, readlink(2) is
also a system call that your C program could use, but if you want the
patch instead I guess that's fine.
johannes
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] wireless: Print wiphy name in sysfs.
2010-10-11 18:42 ` Johannes Berg
@ 2010-10-11 18:50 ` Ben Greear
0 siblings, 0 replies; 7+ messages in thread
From: Ben Greear @ 2010-10-11 18:50 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless
On 10/11/2010 11:42 AM, Johannes Berg wrote:
> On Mon, 2010-10-11 at 11:22 -0700, Ben Greear wrote:
>
>>> basename $(readlink /sys/class/net/wlan0/phy80211)
>>
>> It looks like that could work, but it seems a lot easier to probe
>> network devices via normal manner, and then check if I can just
>> open and read /sys/class/net/[dev-name]/phy80211/name
>>
>> I can do that easily from within a C/C++ program, where as
>> doing system calls and grabbing standard output is more of
>> a pain (and more overhead).
>>
>> But, if you don't want to add my patch, it's not a big deal.
>
> I don't really mind, it just didn't seem necessary. FWIW, readlink(2) is
> also a system call that your C program could use, but if you want the
> patch instead I guess that's fine.
I think it offers a bit of use at a small cost, but certainly
it's not a critical improvement.
If the maintainer picks it up, I'll happily use it..if not,
I can carry it in my own tree or use readdir or something.
Thanks,
Ben
--
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-10-11 18:50 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-11 17:28 [PATCH] wireless: Print wiphy name in sysfs greearb
2010-10-11 17:58 ` Johannes Berg
2010-10-11 18:04 ` Ben Greear
2010-10-11 18:10 ` Johannes Berg
2010-10-11 18:22 ` Ben Greear
2010-10-11 18:42 ` Johannes Berg
2010-10-11 18:50 ` Ben Greear
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).