Skip to contentSkip to conversation

d80211: fix build break from netdev class_device -> device changes

RFC PATCH In review John W. Linville 5 participants 8 messages Feb 21, 2007 – Feb 23, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 d80211: fix build break from netdev class_device -> device changes

In preparation for 2.6.21-rc1, I pulled Linus' latest tree into a branch of wireless-dev. I hit a build problem with the sysfs stuff, due to the recent changes from class_device -> device for net_device.

Since I don't count sysfs as a strength, I thought it was worth posting this for some review before I actually pulled Linus' latest into wireless-dev and slapped this on top of it... :-)

Comments?

--

Fix-up the build breakages in d80211 caused by commit 43cb76d91ee85f579a69d42bc8efc08bac560278.

net/d80211/ieee80211_sysfs.c +55 -56
index d7006cc..87e71a7 100644
@@ -23,9 +23,6 @@ static inline struct ieee80211_local *to_ieee80211_local(struct class_device *de
 	return wiphy_priv(wiphy);
 }
 
-#define to_net_dev(class) \
-	container_of(class, struct net_device, class_dev)
-
 static inline int rtnl_lock_local(struct ieee80211_local *local)
 {
 	rtnl_lock();
@@ -356,11 +353,12 @@ static struct attribute_group ieee80211_stats_group = {
 
 /* attributes in /sys/class/net/X/ */
 
-static ssize_t ieee80211_if_show(struct class_device *cd, char *buf,
+static ssize_t ieee80211_if_show(struct device *d,
+			struct device_attribute *attr, char *buf,
 			ssize_t (*format)(const struct ieee80211_sub_if_data *,
 					  char *))
 {
-	struct net_device *dev = to_net_dev(cd);
+	struct net_device *dev = to_net_dev(d);
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	ssize_t ret = -EINVAL;
 
@@ -400,12 +398,13 @@ static ssize_t ieee80211_if_fmt_##name(const struct			\
 }
 
 #define __IEEE80211_IF_SHOW(name)					\
-static ssize_t ieee80211_if_show_##name(struct class_device *cd,	\
+static ssize_t ieee80211_if_show_##name(struct device *d,		\
+					struct device_attribute *attr,	\
 					char *buf)			\
 {									\
-	return ieee80211_if_show(cd, buf, ieee80211_if_fmt_##name);	\
+	return ieee80211_if_show(d, attr, buf, ieee80211_if_fmt_##name);\
 }									\
-static CLASS_DEVICE_ATTR(name, S_IRUGO, ieee80211_if_show_##name, NULL);
+static DEVICE_ATTR(name, S_IRUGO, ieee80211_if_show_##name, NULL);
 
 #define IEEE80211_IF_SHOW(name, field, format)				\
 		IEEE80211_IF_FMT_##format(name, field)			\
@@ -499,64 +498,64 @@ static ssize_t ieee80211_if_fmt_mode(const struct
 __IEEE80211_IF_SHOW(mode);
 
 static struct attribute *ieee80211_sta_attrs[] = {
-	&class_device_attr_channel_use.attr,
-	&class_device_attr_drop_unencrypted.attr,
-	&class_device_attr_eapol.attr,
-	&class_device_attr_ieee8021_x.attr,
-	&class_device_attr_state.attr,
-	&class_device_attr_bssid.attr,
-	&class_device_attr_prev_bssid.attr,
-	&class_device_attr_ssid_len.attr,
-	&class_device_attr_aid.attr,
-	&class_device_attr_ap_capab.attr,
-	&class_device_attr_capab.attr,
-	&class_device_attr_extra_ie_len.attr,
-	&class_device_attr_auth_tries.attr,
-	&class_device_attr_assoc_tries.attr,
-	&class_device_attr_auth_algs.attr,
-	&class_device_attr_auth_alg.attr,
-	&class_device_attr_auth_transaction.attr,
-	&class_device_attr_flags.attr,
+	&dev_attr_channel_use.attr,
+	&dev_attr_drop_unencrypted.attr,
+	&dev_attr_eapol.attr,
+	&dev_attr_ieee8021_x.attr,
+	&dev_attr_state.attr,
+	&dev_attr_bssid.attr,
+	&dev_attr_prev_bssid.attr,
+	&dev_attr_ssid_len.attr,
+	&dev_attr_aid.attr,
+	&dev_attr_ap_capab.attr,
+	&dev_attr_capab.attr,
+	&dev_attr_extra_ie_len.attr,
+	&dev_attr_auth_tries.attr,
+	&dev_attr_assoc_tries.attr,
+	&dev_attr_auth_algs.attr,
+	&dev_attr_auth_alg.attr,
+	&dev_attr_auth_transaction.attr,
+	&dev_attr_flags.attr,
 	NULL
 };
 
 static struct attribute *ieee80211_ap_attrs[] = {
-	&class_device_attr_channel_use.attr,
-	&class_device_attr_drop_unencrypted.attr,
-	&class_device_attr_eapol.attr,
-	&class_device_attr_ieee8021_x.attr,
-	&class_device_attr_num_sta_ps.attr,
-	&class_device_attr_dtim_period.attr,
-	&class_device_attr_dtim_count.attr,
-	&class_device_attr_num_beacons.attr,
-	&class_device_attr_force_unicast_rateidx.attr,
-	&class_device_attr_max_ratectrl_rateidx.attr,
-	&class_device_attr_num_buffered_multicast.attr,
-	&class_device_attr_beacon_head_len.attr,
-	&class_device_attr_beacon_tail_len.attr,
+	&dev_attr_channel_use.attr,
+	&dev_attr_drop_unencrypted.attr,
+	&dev_attr_eapol.attr,
+	&dev_attr_ieee8021_x.attr,
+	&dev_attr_num_sta_ps.attr,
+	&dev_attr_dtim_period.attr,
+	&dev_attr_dtim_count.attr,
+	&dev_attr_num_beacons.attr,
+	&dev_attr_force_unicast_rateidx.attr,
+	&dev_attr_max_ratectrl_rateidx.attr,
+	&dev_attr_num_buffered_multicast.attr,
+	&dev_attr_beacon_head_len.attr,
+	&dev_attr_beacon_tail_len.attr,
 	NULL
 };
 
 static struct attribute *ieee80211_wds_attrs[] = {
-	&class_device_attr_channel_use.attr,
-	&class_device_attr_drop_unencrypted.attr,
-	&class_device_attr_eapol.attr,
-	&class_device_attr_ieee8021_x.attr,
-	&class_device_attr_peer.attr,
+	&dev_attr_channel_use.attr,
+	&dev_attr_drop_unencrypted.attr,
+	&dev_attr_eapol.attr,
+	&dev_attr_ieee8021_x.attr,
+	&dev_attr_peer.attr,
 	NULL
 };
 
 static struct attribute *ieee80211_vlan_attrs[] = {
-	&class_device_attr_channel_use.attr,
-	&class_device_attr_drop_unencrypted.attr,
-	&class_device_attr_eapol.attr,
-	&class_device_attr_ieee8021_x.attr,
-	&class_device_attr_vlan_id.attr,
+	&dev_attr_channel_use.attr,
+	&dev_attr_drop_unencrypted.attr,
+	&dev_attr_eapol.attr,
+	&dev_attr_ieee8021_x.attr,
+	&dev_attr_vlan_id.attr,
 	NULL
 };
 
 static struct attribute *ieee80211_monitor_attrs[] = {
-	&class_device_attr_mode.attr,
+	&dev_attr_mode.attr,
 	NULL
 };
 
@@ -684,7 +683,7 @@ out:
 
 int ieee80211_sysfs_change_if_type(struct net_device *dev)
 {
-	return ieee80211_add_if_group(&dev->class_dev.kobj, dev);
+	return ieee80211_add_if_group(&dev->dev.kobj, dev);
 }
 
 int ieee80211_sysfs_add_netdevice(struct net_device *dev)
@@ -692,19 +691,19 @@ int ieee80211_sysfs_add_netdevice(struct net_device *dev)
 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
 	int res;
 
-	res = sysfs_create_link(&dev->class_dev.kobj,
+	res = sysfs_create_link(&dev->dev.kobj,
 				&local->hw.wiphy->class_dev.kobj,
 				"wiphy");
 	if (res)
 		goto err_out;
-	res = ieee80211_add_if_group(&dev->class_dev.kobj, dev);
+	res = ieee80211_add_if_group(&dev->dev.kobj, dev);
 	if (res)
 		goto err_link;
 	res = ieee80211_key_kset_sysfs_register(IEEE80211_DEV_TO_SUB_IF(dev));
 	return res;
 
 err_link:
-	sysfs_remove_link(&dev->class_dev.kobj, "wiphy");
+	sysfs_remove_link(&dev->dev.kobj, "wiphy");
 err_out:
 	return res;
 }
@@ -712,6 +711,6 @@ err_out:
 void ieee80211_sysfs_remove_netdevice(struct net_device *dev)
 {
 	ieee80211_key_kset_sysfs_unregister(IEEE80211_DEV_TO_SUB_IF(dev));
-	ieee80211_remove_if_group(&dev->class_dev.kobj, dev);
-	sysfs_remove_link(&dev->class_dev.kobj, "wiphy");
+	ieee80211_remove_if_group(&dev->dev.kobj, dev);
+	sysfs_remove_link(&dev->dev.kobj, "wiphy");
 }
net/d80211/ieee80211_sysfs_sta.c +1 -1
index fb0bae0..2f9c837 100644
@@ -387,7 +387,7 @@ int ieee80211_key_kset_sysfs_register(struct ieee80211_sub_if_data *sdata)
 	res = kobject_set_name(&sdata->key_kset.kobj, "keys");
 	if (res)
 		return res;
-	sdata->key_kset.kobj.parent = &sdata->dev->class_dev.kobj;
+	sdata->key_kset.kobj.parent = &sdata->dev->dev.kobj;
 	sdata->key_kset.ktype = &key_ktype;
 	return kset_register(&sdata->key_kset);
 }
Signature · 2 lines
John W. Linville
[email protected]
maintainer
#1 lore raw
Quoted 3 lines · John W. Linville

In preparation for 2.6.21-rc1, I pulled Linus' latest tree into a branch of wireless-dev. I hit a build problem with the sysfs stuff, due to the recent changes from class_device -> device for net_device.

Hmm, need to look up the reason and see if wiphy stuff should follow.

Quoted 5 lines

Since I don't count sysfs as a strength, I thought it was worth posting this for some review before I actually pulled Linus' latest into wireless-dev and slapped this on top of it... :-)

Comments?

Seems fine. Is to_net_dev() defined in netdevice.h now?

OTOH, we might want to take this opportunity and move it all to debugfs ;)

johannes

#2 lore raw
Quoted 6 lines · Johannes Berg
Quoted 3 lines · John W. Linville

In preparation for 2.6.21-rc1, I pulled Linus' latest tree into a branch of wireless-dev. I hit a build problem with the sysfs stuff, due to the recent changes from class_device -> device for net_device.

Hmm, need to look up the reason and see if wiphy stuff should follow.

Exactly what I was thinking, and what made me question the patch's completeness...

Quoted 7 lines
Quoted 5 lines

Since I don't count sysfs as a strength, I thought it was worth posting this for some review before I actually pulled Linus' latest into wireless-dev and slapped this on top of it... :-)

Comments?

Seems fine. Is to_net_dev() defined in netdevice.h now?

Ja.

Quoted 2 lines

OTOH, we might want to take this opportunity and move it all to debugfs ;)

Excellent suggestion. But for now, I just want my tree to build and run... :-)

Thanks for the eyeballs!

John

Signature · 2 lines
John W. Linville
[email protected]
Acked-by on v1 1/1
#6 lore raw
In reply to John W. Linville
Quoted 9 lines · John W. Linville

In preparation for 2.6.21-rc1, I pulled Linus' latest tree into a branch of wireless-dev. I hit a build problem with the sysfs stuff, due to the recent changes from class_device -> device for net_device.

Since I don't count sysfs as a strength, I thought it was worth posting this for some review before I actually pulled Linus' latest into wireless-dev and slapped this on top of it... :-)

Comments?

Looks correct. Don't know if it's complete, though - I tried to pull from Linus but there are many conflicts caused by the ssb code, I'll leave them to you :-)

I wonder if we can simplify it sometime in the future as we're getting device_attribute in the callbacks now... Probably not. And it's not worth the effort anyway.

Signature · 2 lines
Jiri Benc
SUSE Labs
#7 lore raw
Quoted 2 lines · Jiri Benc

Looks correct. Don't know if it's complete, though - I tried to pull from Linus but there are many conflicts caused by the ssb code,

Uh, which kind of? If you don't know how to resolve this, let me resolve it.

Signature · 1 line
Greetings Michael.
maintainer
#3 lore raw

RFC 1/1 convert wiphy to struct device

In reply to John W. Linville

Ok so I did the wiphy stuff w/o knowing that class devs are apparently deprecated. Below is a patch to convert it.

However, that patch has a problem. As discussed on netdev in the thread "Converting network devices from class devices causes namespace pollution" we'll have the same problem here, currently after the patch this means that wiphys and netdevs will share the same namespace within the device directory.

I think the generic code Greg promised in that thread will fix it by renaming the symlink to "ieee80211:wiphy0" instead of just "wiphy0" but I'd like to have confirmation about that.

johannes

---
 include/net/wireless.h           |   12 +--
 net/d80211/ieee80211.c           |    6 -
 net/d80211/ieee80211_sysfs.c     |  132 ++++++++++++++++++++-------------------
 net/d80211/ieee80211_sysfs_sta.c |    2 
 net/wireless/core.c              |   14 ++--
 net/wireless/sysfs.c             |   44 +++++++------
 6 files changed, 112 insertions(+), 98 deletions(-)
include/net/wireless.h +6 -6
@@ -24,9 +24,9 @@ struct wiphy {
 
 	/* fields below are read-only, assigned by cfg80211 */
 
-	/* dir in /sys/class/ieee80211/, you need
-	 * to assign its dev pointer */
-	struct class_device class_dev;
+	/* the item in /sys/class/ieee80211/ points to this,
+	 * you need use set_wiphy_dev() (see below) */
+	struct device dev;
 
 	/* dir in debugfs: ieee80211/<wiphyname> */
 	struct dentry *debugfsdir;
@@ -64,7 +64,7 @@ static inline void *wiphy_priv(struct wi
  */
 static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
 {
-	wiphy->class_dev.dev = dev;
+	wiphy->dev.parent = dev;
 }
 
 /**
@@ -72,7 +72,7 @@ static inline void set_wiphy_dev(struct 
  */
 static inline struct device *wiphy_dev(struct wiphy *wiphy)
 {
-	return wiphy->class_dev.dev;
+	return wiphy->dev.parent;
 }
 
 /**
@@ -80,7 +80,7 @@ static inline struct device *wiphy_dev(s
  */
 static inline char *wiphy_name(struct wiphy *wiphy)
 {
-	return wiphy->class_dev.class_id;
+	return wiphy->dev.bus_id;
 }
 
 /**
net/wireless/core.c +7 -7
@@ -164,7 +164,7 @@ struct wiphy *wiphy_new(struct cfg80211_
 	drv->idx = wiphy_counter;
 
 	/* give it a proper name */
-	snprintf(drv->wiphy.class_dev.class_id, BUS_ID_SIZE,
+	snprintf(drv->wiphy.dev.bus_id, BUS_ID_SIZE,
 		 "wiphy%d", drv->idx);
 
 	/* now increase counter for the next time */
@@ -173,9 +173,9 @@ struct wiphy *wiphy_new(struct cfg80211_
 
 	mutex_init(&drv->mtx);
 
-	drv->wiphy.class_dev.class = &ieee80211_class;
-	drv->wiphy.class_dev.class_data = &drv->wiphy;
-	class_device_initialize(&drv->wiphy.class_dev);
+	device_initialize(&drv->wiphy.dev);
+	drv->wiphy.dev.class = &ieee80211_class;
+	drv->wiphy.dev.platform_data = drv;
 
 	return &drv->wiphy;
 }
@@ -189,7 +189,7 @@ int wiphy_register(struct wiphy *wiphy)
 	mutex_lock(&cfg80211_drv_mutex);
 
 
-	res = class_device_add(&drv->wiphy.class_dev);
+	res = device_add(&drv->wiphy.dev);
 	if (res)
 		goto out_unlock;
 
@@ -219,7 +219,7 @@ void wiphy_unregister(struct wiphy *wiph
 	list_del(&drv->list);
 	mutex_unlock(&drv->mtx);
 
-	class_device_del(&drv->wiphy.class_dev);
+	device_del(&drv->wiphy.dev);
 	debugfs_remove(drv->wiphy.debugfsdir);
 
 	mutex_unlock(&cfg80211_drv_mutex);
@@ -234,7 +234,7 @@ void cfg80211_dev_free(struct cfg80211_r
 
 void wiphy_free(struct wiphy *wiphy)
 {
-	class_device_put(&wiphy->class_dev);
+	put_device(&wiphy->dev);
 }
 EXPORT_SYMBOL(wiphy_free);
 
net/wireless/sysfs.c +25 -19

97 lines not on this page · raw message

net/d80211/ieee80211.c +3 -3
@@ -4469,7 +4469,7 @@ int ieee80211_init_rate_ctrl_alg(struct 
 		       "algorithm\n", local->mdev->name);
 		return -ENOENT;
 	}
-	res = rate_control_add_attrs(ref, &local->hw.wiphy->class_dev.kobj);
+	res = rate_control_add_attrs(ref, &local->hw.wiphy->dev.kobj);
 	if (res < 0) {
 		printk(KERN_DEBUG "%s: Failed to register sysfs attributes "
 		       "for rate control\n", local->mdev->name);
@@ -4480,7 +4480,7 @@ int ieee80211_init_rate_ctrl_alg(struct 
 	old = local->rate_ctrl;
 	local->rate_ctrl = ref;
 	if (old) {
-		rate_control_remove_attrs(ref, &local->hw.wiphy->class_dev.kobj);
+		rate_control_remove_attrs(ref, &local->hw.wiphy->dev.kobj);
 		rate_control_put(old);
 		sta_info_flush(local, NULL);
 	}
@@ -4499,7 +4499,7 @@ static void rate_control_deinitialize(st
 
 	ref = local->rate_ctrl;
 	local->rate_ctrl = NULL;
-	rate_control_remove_attrs(ref, &local->hw.wiphy->class_dev.kobj);
+	rate_control_remove_attrs(ref, &local->hw.wiphy->dev.kobj);
 	rate_control_put(ref);
 }
 
net/d80211/ieee80211_sysfs.c +70 -62

233 lines not on this page · raw message

net/d80211/ieee80211_sysfs_sta.c +1 -1
@@ -370,7 +370,7 @@ int ieee80211_sta_kset_sysfs_register(st
 	res = kobject_set_name(&local->sta_kset.kobj, "sta");
 	if (res)
 		return res;
-	local->sta_kset.kobj.parent = &local->hw.wiphy->class_dev.kobj;
+	local->sta_kset.kobj.parent = &local->hw.wiphy->dev.kobj;
 	local->sta_kset.ktype = &sta_ktype;
 	return kset_register(&local->sta_kset);
 }
#4 lore raw

Re: [RFC] convert wiphy to struct device

Quoted 9 lines · Johannes Berg

Ok so I did the wiphy stuff w/o knowing that class devs are apparently deprecated. Below is a patch to convert it.

However, that patch has a problem. As discussed on netdev in the thread "Converting network devices from class devices causes namespace pollution" we'll have the same problem here, currently after the patch this means that wiphys and netdevs will share the same namespace within the device directory.

Quoted 3 lines

I think the generic code Greg promised in that thread will fix it by renaming the symlink to "ieee80211:wiphy0" instead of just "wiphy0" but I'd like to have confirmation about that.

Yes it will, I'm working on that patch right now...

thanks,

greg k-h

maintainer
#5 lore raw

Re: [RFC] convert wiphy to struct device

Quoted 1 line · Greg KH

Yes it will, I'm working on that patch right now...

Alright, thanks. In that case, John, please replace [RFC] with [PATCH] and apply :)

johannes