nl80211: read TX power using NL80211_CMD_GET_INTERFACE
With the mac80211 commit d55d0d598e66 ("nl80211: put current TX power in interface info") it is possible now to get TX power using nl80211. As we don't really support any wext-only drivers it doesn't make sense to leave wext as a fallback. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
This commit is contained in:
parent
3d38d1d17e
commit
813f61e48b
2 changed files with 26 additions and 9 deletions
|
@ -37,6 +37,10 @@ int iwinfo_ioctl(int cmd, void *ifr);
|
||||||
|
|
||||||
int iwinfo_dbm2mw(int in);
|
int iwinfo_dbm2mw(int in);
|
||||||
int iwinfo_mw2dbm(int in);
|
int iwinfo_mw2dbm(int in);
|
||||||
|
static inline int iwinfo_mbm2dbm(int gain)
|
||||||
|
{
|
||||||
|
return gain / 100;
|
||||||
|
}
|
||||||
|
|
||||||
int iwinfo_ifup(const char *ifname);
|
int iwinfo_ifup(const char *ifname);
|
||||||
int iwinfo_ifdown(const char *ifname);
|
int iwinfo_ifdown(const char *ifname);
|
||||||
|
|
|
@ -1188,22 +1188,35 @@ static int nl80211_get_channel(const char *ifname, int *buf)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int nl80211_get_txpower_cb(struct nl_msg *msg, void *arg)
|
||||||
|
{
|
||||||
|
int *buf = arg;
|
||||||
|
struct nlattr **tb = nl80211_parse(msg);
|
||||||
|
|
||||||
|
if (tb[NL80211_ATTR_WIPHY_TX_POWER_LEVEL])
|
||||||
|
*buf = iwinfo_mbm2dbm(nla_get_u32(tb[NL80211_ATTR_WIPHY_TX_POWER_LEVEL]));
|
||||||
|
|
||||||
|
return NL_SKIP;
|
||||||
|
}
|
||||||
|
|
||||||
static int nl80211_get_txpower(const char *ifname, int *buf)
|
static int nl80211_get_txpower(const char *ifname, int *buf)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
char *res;
|
char *res;
|
||||||
char path[PATH_MAX];
|
struct nl80211_msg_conveyor *req;
|
||||||
|
|
||||||
res = nl80211_ifname2phy(ifname);
|
res = nl80211_phy2ifname(ifname);
|
||||||
snprintf(path, sizeof(path), "/sys/kernel/debug/ieee80211/%s/power",
|
req = nl80211_msg(res ? res : ifname, NL80211_CMD_GET_INTERFACE, 0);
|
||||||
res ? res : ifname);
|
|
||||||
|
|
||||||
if ((*buf = nl80211_readint(path)) > -1)
|
if (req)
|
||||||
|
{
|
||||||
|
*buf = 0;
|
||||||
|
nl80211_send(req, nl80211_get_txpower_cb, buf);
|
||||||
|
nl80211_free(req);
|
||||||
|
if (*buf)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
return wext_ops.txpower(ifname, buf);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue