提交 b5850a7a 编写于 作者: L Luis R. Rodriguez 提交者: John W. Linville

cfg80211: rename cfg80211_registered_device's idx to wiphy_idx

Makes it clearer to read when comparing to ifidx
Signed-off-by: NLuis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 79f6440c
...@@ -37,12 +37,13 @@ DEFINE_MUTEX(cfg80211_drv_mutex); ...@@ -37,12 +37,13 @@ DEFINE_MUTEX(cfg80211_drv_mutex);
static struct dentry *ieee80211_debugfs_dir; static struct dentry *ieee80211_debugfs_dir;
/* requires cfg80211_drv_mutex to be held! */ /* requires cfg80211_drv_mutex to be held! */
static struct cfg80211_registered_device *cfg80211_drv_by_wiphy(int wiphy) static struct cfg80211_registered_device *
cfg80211_drv_by_wiphy_idx(int wiphy_idx)
{ {
struct cfg80211_registered_device *result = NULL, *drv; struct cfg80211_registered_device *result = NULL, *drv;
list_for_each_entry(drv, &cfg80211_drv_list, list) { list_for_each_entry(drv, &cfg80211_drv_list, list) {
if (drv->idx == wiphy) { if (drv->wiphy_idx == wiphy_idx) {
result = drv; result = drv;
break; break;
} }
...@@ -56,12 +57,12 @@ static struct cfg80211_registered_device * ...@@ -56,12 +57,12 @@ static struct cfg80211_registered_device *
__cfg80211_drv_from_info(struct genl_info *info) __cfg80211_drv_from_info(struct genl_info *info)
{ {
int ifindex; int ifindex;
struct cfg80211_registered_device *bywiphy = NULL, *byifidx = NULL; struct cfg80211_registered_device *bywiphyidx = NULL, *byifidx = NULL;
struct net_device *dev; struct net_device *dev;
int err = -EINVAL; int err = -EINVAL;
if (info->attrs[NL80211_ATTR_WIPHY]) { if (info->attrs[NL80211_ATTR_WIPHY]) {
bywiphy = cfg80211_drv_by_wiphy( bywiphyidx = cfg80211_drv_by_wiphy_idx(
nla_get_u32(info->attrs[NL80211_ATTR_WIPHY])); nla_get_u32(info->attrs[NL80211_ATTR_WIPHY]));
err = -ENODEV; err = -ENODEV;
} }
...@@ -78,14 +79,14 @@ __cfg80211_drv_from_info(struct genl_info *info) ...@@ -78,14 +79,14 @@ __cfg80211_drv_from_info(struct genl_info *info)
err = -ENODEV; err = -ENODEV;
} }
if (bywiphy && byifidx) { if (bywiphyidx && byifidx) {
if (bywiphy != byifidx) if (bywiphyidx != byifidx)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
else else
return bywiphy; /* == byifidx */ return bywiphyidx; /* == byifidx */
} }
if (bywiphy) if (bywiphyidx)
return bywiphy; return bywiphyidx;
if (byifidx) if (byifidx)
return byifidx; return byifidx;
...@@ -143,16 +144,16 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev, ...@@ -143,16 +144,16 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
char *newname) char *newname)
{ {
struct cfg80211_registered_device *drv; struct cfg80211_registered_device *drv;
int idx, taken = -1, result, digits; int wiphy_idx, taken = -1, result, digits;
mutex_lock(&cfg80211_drv_mutex); mutex_lock(&cfg80211_drv_mutex);
/* prohibit calling the thing phy%d when %d is not its number */ /* prohibit calling the thing phy%d when %d is not its number */
sscanf(newname, PHY_NAME "%d%n", &idx, &taken); sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
if (taken == strlen(newname) && idx != rdev->idx) { if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
/* count number of places needed to print idx */ /* count number of places needed to print wiphy_idx */
digits = 1; digits = 1;
while (idx /= 10) while (wiphy_idx /= 10)
digits++; digits++;
/* /*
* deny the name if it is phy<idx> where <idx> is printed * deny the name if it is phy<idx> where <idx> is printed
...@@ -222,9 +223,9 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv) ...@@ -222,9 +223,9 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
mutex_lock(&cfg80211_drv_mutex); mutex_lock(&cfg80211_drv_mutex);
drv->idx = wiphy_counter++; drv->wiphy_idx = wiphy_counter++;
if (unlikely(drv->idx < 0)) { if (unlikely(drv->wiphy_idx < 0)) {
wiphy_counter--; wiphy_counter--;
mutex_unlock(&cfg80211_drv_mutex); mutex_unlock(&cfg80211_drv_mutex);
/* ugh, wrapped! */ /* ugh, wrapped! */
...@@ -235,7 +236,7 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv) ...@@ -235,7 +236,7 @@ struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv)
mutex_unlock(&cfg80211_drv_mutex); mutex_unlock(&cfg80211_drv_mutex);
/* give it a proper name */ /* give it a proper name */
dev_set_name(&drv->wiphy.dev, PHY_NAME "%d", drv->idx); dev_set_name(&drv->wiphy.dev, PHY_NAME "%d", drv->wiphy_idx);
mutex_init(&drv->mtx); mutex_init(&drv->mtx);
mutex_init(&drv->devlist_mtx); mutex_init(&drv->devlist_mtx);
......
...@@ -37,7 +37,7 @@ struct cfg80211_registered_device { ...@@ -37,7 +37,7 @@ struct cfg80211_registered_device {
enum environment_cap env; enum environment_cap env;
/* wiphy index, internal only */ /* wiphy index, internal only */
int idx; int wiphy_idx;
/* associate netdev list */ /* associate netdev list */
struct mutex devlist_mtx; struct mutex devlist_mtx;
......
...@@ -142,7 +142,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, ...@@ -142,7 +142,7 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
if (!hdr) if (!hdr)
return -1; return -1;
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx); NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx);
NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy));
NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
dev->wiphy.max_scan_ssids); dev->wiphy.max_scan_ssids);
...@@ -2763,7 +2763,7 @@ static int nl80211_send_scan_donemsg(struct sk_buff *msg, ...@@ -2763,7 +2763,7 @@ static int nl80211_send_scan_donemsg(struct sk_buff *msg,
if (!hdr) if (!hdr)
return -1; return -1;
NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->idx); NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx);
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex);
/* XXX: we should probably bounce back the request? */ /* XXX: we should probably bounce back the request? */
......
...@@ -31,7 +31,7 @@ static ssize_t name ## _show(struct device *dev, \ ...@@ -31,7 +31,7 @@ static ssize_t name ## _show(struct device *dev, \
return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \
} }
SHOW_FMT(index, "%d", idx); SHOW_FMT(index, "%d", wiphy_idx);
SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); SHOW_FMT(macaddress, "%pM", wiphy.perm_addr);
static struct device_attribute ieee80211_dev_attrs[] = { static struct device_attribute ieee80211_dev_attrs[] = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册