linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] cfg80211: pass netdev to change_virtual_intf
  2009-06-09 19:04 [PATCH] cfg80211: pass netdev to change_virtual_intf Johannes Berg
@ 2009-06-04 17:19 ` Dave
  2009-06-12 20:50   ` Johannes Berg
  2009-06-09 19:11 ` Samuel Ortiz
  1 sibling, 1 reply; 4+ messages in thread
From: Dave @ 2009-06-04 17:19 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, linux-wireless, Samuel Ortiz

Johannes Berg wrote:
> If there was a reason I'm passing the ifidx I cannot
> remember it any more and don't see one now, so let's
> just pass the pointer itself.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> ---
>  drivers/net/wireless/iwmc3200wifi/cfg80211.c |    9 ++-------
>  include/net/cfg80211.h                       |    3 ++-
>  net/mac80211/cfg.c                           |    9 ++-------
>  net/wireless/nl80211.c                       |   12 +++++-------
>  net/wireless/wext-compat.c                   |    2 +-
>  5 files changed, 12 insertions(+), 23 deletions(-)

rndis_wlan.c will need an update for this as well


Dave.
---
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index c254fdf..230962e 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -420,7 +420,8 @@ struct rndis_wext_private {
 /*
  * cfg80211 ops
  */
-static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex,
+static int rndis_change_virtual_intf(struct wiphy *wiphy,
+                                       struct net_device *dev,
                                        enum nl80211_iftype type, u32 *flags,
                                        struct vif_params *params);

@@ -1222,20 +1223,14 @@ static void set_multicast_list(struct usbnet *usbdev)
 /*
  * cfg80211 ops
  */
-static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex,
+static int rndis_change_virtual_intf(struct wiphy *wiphy,
+                                       struct net_device *dev,
                                        enum nl80211_iftype type, u32 *flags,
                                        struct vif_params *params)
 {
-       struct net_device *dev;
-       struct usbnet *usbdev;
+       struct usbnet *usbdev = netdev_priv(dev);
        int mode;

-       /* we're under RTNL */
-       dev = __dev_get_by_index(&init_net, ifindex);
-       if (!dev)
-               return -ENODEV;
-       usbdev = netdev_priv(dev);
-
        switch (type) {
        case NL80211_IFTYPE_ADHOC:
                mode = ndis_80211_infra_adhoc;




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

* [PATCH] cfg80211: pass netdev to change_virtual_intf
@ 2009-06-09 19:04 Johannes Berg
  2009-06-04 17:19 ` Dave
  2009-06-09 19:11 ` Samuel Ortiz
  0 siblings, 2 replies; 4+ messages in thread
From: Johannes Berg @ 2009-06-09 19:04 UTC (permalink / raw)
  To: John Linville; +Cc: linux-wireless, Samuel Ortiz

If there was a reason I'm passing the ifidx I cannot
remember it any more and don't see one now, so let's
just pass the pointer itself.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 drivers/net/wireless/iwmc3200wifi/cfg80211.c |    9 ++-------
 include/net/cfg80211.h                       |    3 ++-
 net/mac80211/cfg.c                           |    9 ++-------
 net/wireless/nl80211.c                       |   12 +++++-------
 net/wireless/wext-compat.c                   |    2 +-
 5 files changed, 12 insertions(+), 23 deletions(-)

--- wireless-testing.orig/include/net/cfg80211.h	2009-06-09 20:56:03.000000000 +0200
+++ wireless-testing/include/net/cfg80211.h	2009-06-09 20:56:47.000000000 +0200
@@ -866,7 +866,8 @@ struct cfg80211_ops {
 				    enum nl80211_iftype type, u32 *flags,
 				    struct vif_params *params);
 	int	(*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
-	int	(*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
+	int	(*change_virtual_intf)(struct wiphy *wiphy,
+				       struct net_device *dev,
 				       enum nl80211_iftype type, u32 *flags,
 				       struct vif_params *params);
 
--- wireless-testing.orig/net/mac80211/cfg.c	2009-06-09 20:56:54.000000000 +0200
+++ wireless-testing/net/mac80211/cfg.c	2009-06-09 20:57:06.000000000 +0200
@@ -74,19 +74,14 @@ static int ieee80211_del_iface(struct wi
 	return 0;
 }
 
-static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,
+static int ieee80211_change_iface(struct wiphy *wiphy,
+				  struct net_device *dev,
 				  enum nl80211_iftype type, u32 *flags,
 				  struct vif_params *params)
 {
-	struct net_device *dev;
 	struct ieee80211_sub_if_data *sdata;
 	int ret;
 
-	/* we're under RTNL */
-	dev = __dev_get_by_index(&init_net, ifindex);
-	if (!dev)
-		return -ENODEV;
-
 	if (!nl80211_type_check(type))
 		return -EINVAL;
 
--- wireless-testing.orig/net/wireless/nl80211.c	2009-06-09 20:57:19.000000000 +0200
+++ wireless-testing/net/wireless/nl80211.c	2009-06-09 21:02:33.000000000 +0200
@@ -766,7 +766,7 @@ static int nl80211_set_interface(struct 
 {
 	struct cfg80211_registered_device *drv;
 	struct vif_params params;
-	int err, ifindex;
+	int err;
 	enum nl80211_iftype otype, ntype;
 	struct net_device *dev;
 	u32 _flags, *flags = NULL;
@@ -780,9 +780,7 @@ static int nl80211_set_interface(struct 
 	if (err)
 		goto unlock_rtnl;
 
-	ifindex = dev->ifindex;
 	otype = ntype = dev->ieee80211_ptr->iftype;
-	dev_put(dev);
 
 	if (info->attrs[NL80211_ATTR_IFTYPE]) {
 		ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
@@ -825,20 +823,20 @@ static int nl80211_set_interface(struct 
 	}
 
 	if (change)
-		err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex,
+		err = drv->ops->change_virtual_intf(&drv->wiphy, dev,
 						    ntype, flags, &params);
 	else
 		err = 0;
 
-	dev = __dev_get_by_index(&init_net, ifindex);
-	WARN_ON(!dev || (!err && dev->ieee80211_ptr->iftype != ntype));
+	WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype);
 
-	if (dev && !err && (ntype != otype)) {
+	if (!err && (ntype != otype)) {
 		if (otype == NL80211_IFTYPE_ADHOC)
 			cfg80211_clear_ibss(dev, false);
 	}
 
  unlock:
+	dev_put(dev);
 	cfg80211_put_dev(drv);
  unlock_rtnl:
 	rtnl_unlock();
--- wireless-testing.orig/net/wireless/wext-compat.c	2009-06-09 20:59:03.000000000 +0200
+++ wireless-testing/net/wireless/wext-compat.c	2009-06-09 20:59:14.000000000 +0200
@@ -103,7 +103,7 @@ int cfg80211_wext_siwmode(struct net_dev
 
 	memset(&vifparams, 0, sizeof(vifparams));
 
-	ret = rdev->ops->change_virtual_intf(wdev->wiphy, dev->ifindex, type,
+	ret = rdev->ops->change_virtual_intf(wdev->wiphy, dev, type,
 					     NULL, &vifparams);
 	WARN_ON(!ret && wdev->iftype != type);
 
--- wireless-testing.orig/drivers/net/wireless/iwmc3200wifi/cfg80211.c	2009-06-09 20:59:44.000000000 +0200
+++ wireless-testing/drivers/net/wireless/iwmc3200wifi/cfg80211.c	2009-06-09 21:00:02.000000000 +0200
@@ -167,20 +167,15 @@ int iwm_cfg80211_inform_bss(struct iwm_p
 	return 0;
 }
 
-static int iwm_cfg80211_change_iface(struct wiphy *wiphy, int ifindex,
+static int iwm_cfg80211_change_iface(struct wiphy *wiphy,
+				     struct net_device *ndev,
 				     enum nl80211_iftype type, u32 *flags,
 				     struct vif_params *params)
 {
-	struct net_device *ndev;
 	struct wireless_dev *wdev;
 	struct iwm_priv *iwm;
 	u32 old_mode;
 
-	/* we're under RTNL */
-	ndev = __dev_get_by_index(&init_net, ifindex);
-	if (!ndev)
-		return -ENODEV;
-
 	wdev = ndev->ieee80211_ptr;
 	iwm = ndev_to_iwm(ndev);
 	old_mode = iwm->conf.mode;



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

* Re: [PATCH] cfg80211: pass netdev to change_virtual_intf
  2009-06-09 19:04 [PATCH] cfg80211: pass netdev to change_virtual_intf Johannes Berg
  2009-06-04 17:19 ` Dave
@ 2009-06-09 19:11 ` Samuel Ortiz
  1 sibling, 0 replies; 4+ messages in thread
From: Samuel Ortiz @ 2009-06-09 19:11 UTC (permalink / raw)
  To: Johannes Berg; +Cc: John Linville, linux-wireless

On Tue, 2009-06-09 at 21:04 +0200, Johannes Berg wrote:
> If there was a reason I'm passing the ifidx I cannot
> remember it any more and don't see one now, so let's
> just pass the pointer itself.
> 
> Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
For the iwmc part:
Acked-by: Samuel Ortiz <sameo@linux.intel.com>

Cheers,
Samuel.

> ---
>  drivers/net/wireless/iwmc3200wifi/cfg80211.c |    9 ++-------
>  include/net/cfg80211.h                       |    3 ++-
>  net/mac80211/cfg.c                           |    9 ++-------
>  net/wireless/nl80211.c                       |   12 +++++-------
>  net/wireless/wext-compat.c                   |    2 +-
>  5 files changed, 12 insertions(+), 23 deletions(-)
> 
> --- wireless-testing.orig/include/net/cfg80211.h	2009-06-09 20:56:03.000000000 +0200
> +++ wireless-testing/include/net/cfg80211.h	2009-06-09 20:56:47.000000000 +0200
> @@ -866,7 +866,8 @@ struct cfg80211_ops {
>  				    enum nl80211_iftype type, u32 *flags,
>  				    struct vif_params *params);
>  	int	(*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
> -	int	(*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
> +	int	(*change_virtual_intf)(struct wiphy *wiphy,
> +				       struct net_device *dev,
>  				       enum nl80211_iftype type, u32 *flags,
>  				       struct vif_params *params);
>  
> --- wireless-testing.orig/net/mac80211/cfg.c	2009-06-09 20:56:54.000000000 +0200
> +++ wireless-testing/net/mac80211/cfg.c	2009-06-09 20:57:06.000000000 +0200
> @@ -74,19 +74,14 @@ static int ieee80211_del_iface(struct wi
>  	return 0;
>  }
>  
> -static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex,
> +static int ieee80211_change_iface(struct wiphy *wiphy,
> +				  struct net_device *dev,
>  				  enum nl80211_iftype type, u32 *flags,
>  				  struct vif_params *params)
>  {
> -	struct net_device *dev;
>  	struct ieee80211_sub_if_data *sdata;
>  	int ret;
>  
> -	/* we're under RTNL */
> -	dev = __dev_get_by_index(&init_net, ifindex);
> -	if (!dev)
> -		return -ENODEV;
> -
>  	if (!nl80211_type_check(type))
>  		return -EINVAL;
>  
> --- wireless-testing.orig/net/wireless/nl80211.c	2009-06-09 20:57:19.000000000 +0200
> +++ wireless-testing/net/wireless/nl80211.c	2009-06-09 21:02:33.000000000 +0200
> @@ -766,7 +766,7 @@ static int nl80211_set_interface(struct 
>  {
>  	struct cfg80211_registered_device *drv;
>  	struct vif_params params;
> -	int err, ifindex;
> +	int err;
>  	enum nl80211_iftype otype, ntype;
>  	struct net_device *dev;
>  	u32 _flags, *flags = NULL;
> @@ -780,9 +780,7 @@ static int nl80211_set_interface(struct 
>  	if (err)
>  		goto unlock_rtnl;
>  
> -	ifindex = dev->ifindex;
>  	otype = ntype = dev->ieee80211_ptr->iftype;
> -	dev_put(dev);
>  
>  	if (info->attrs[NL80211_ATTR_IFTYPE]) {
>  		ntype = nla_get_u32(info->attrs[NL80211_ATTR_IFTYPE]);
> @@ -825,20 +823,20 @@ static int nl80211_set_interface(struct 
>  	}
>  
>  	if (change)
> -		err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex,
> +		err = drv->ops->change_virtual_intf(&drv->wiphy, dev,
>  						    ntype, flags, &params);
>  	else
>  		err = 0;
>  
> -	dev = __dev_get_by_index(&init_net, ifindex);
> -	WARN_ON(!dev || (!err && dev->ieee80211_ptr->iftype != ntype));
> +	WARN_ON(!err && dev->ieee80211_ptr->iftype != ntype);
>  
> -	if (dev && !err && (ntype != otype)) {
> +	if (!err && (ntype != otype)) {
>  		if (otype == NL80211_IFTYPE_ADHOC)
>  			cfg80211_clear_ibss(dev, false);
>  	}
>  
>   unlock:
> +	dev_put(dev);
>  	cfg80211_put_dev(drv);
>   unlock_rtnl:
>  	rtnl_unlock();
> --- wireless-testing.orig/net/wireless/wext-compat.c	2009-06-09 20:59:03.000000000 +0200
> +++ wireless-testing/net/wireless/wext-compat.c	2009-06-09 20:59:14.000000000 +0200
> @@ -103,7 +103,7 @@ int cfg80211_wext_siwmode(struct net_dev
>  
>  	memset(&vifparams, 0, sizeof(vifparams));
>  
> -	ret = rdev->ops->change_virtual_intf(wdev->wiphy, dev->ifindex, type,
> +	ret = rdev->ops->change_virtual_intf(wdev->wiphy, dev, type,
>  					     NULL, &vifparams);
>  	WARN_ON(!ret && wdev->iftype != type);
>  
> --- wireless-testing.orig/drivers/net/wireless/iwmc3200wifi/cfg80211.c	2009-06-09 20:59:44.000000000 +0200
> +++ wireless-testing/drivers/net/wireless/iwmc3200wifi/cfg80211.c	2009-06-09 21:00:02.000000000 +0200
> @@ -167,20 +167,15 @@ int iwm_cfg80211_inform_bss(struct iwm_p
>  	return 0;
>  }
>  
> -static int iwm_cfg80211_change_iface(struct wiphy *wiphy, int ifindex,
> +static int iwm_cfg80211_change_iface(struct wiphy *wiphy,
> +				     struct net_device *ndev,
>  				     enum nl80211_iftype type, u32 *flags,
>  				     struct vif_params *params)
>  {
> -	struct net_device *ndev;
>  	struct wireless_dev *wdev;
>  	struct iwm_priv *iwm;
>  	u32 old_mode;
>  
> -	/* we're under RTNL */
> -	ndev = __dev_get_by_index(&init_net, ifindex);
> -	if (!ndev)
> -		return -ENODEV;
> -
>  	wdev = ndev->ieee80211_ptr;
>  	iwm = ndev_to_iwm(ndev);
>  	old_mode = iwm->conf.mode;
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

* Re: [PATCH] cfg80211: pass netdev to change_virtual_intf
  2009-06-04 17:19 ` Dave
@ 2009-06-12 20:50   ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2009-06-12 20:50 UTC (permalink / raw)
  To: Dave; +Cc: John Linville, linux-wireless, Samuel Ortiz

[-- Attachment #1: Type: text/plain, Size: 2489 bytes --]

On Thu, 2009-06-04 at 18:19 +0100, Dave wrote:
> Johannes Berg wrote:
> > If there was a reason I'm passing the ifidx I cannot
> > remember it any more and don't see one now, so let's
> > just pass the pointer itself.
> > 
> > Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
> > ---
> >  drivers/net/wireless/iwmc3200wifi/cfg80211.c |    9 ++-------
> >  include/net/cfg80211.h                       |    3 ++-
> >  net/mac80211/cfg.c                           |    9 ++-------
> >  net/wireless/nl80211.c                       |   12 +++++-------
> >  net/wireless/wext-compat.c                   |    2 +-
> >  5 files changed, 12 insertions(+), 23 deletions(-)
> 
> rndis_wlan.c will need an update for this as well

Sorry! I totally missed that. Thanks for the patch, John can you roll
that in and properly credit Dave for it?

johannes

> 
> Dave.
> ---
> diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
> index c254fdf..230962e 100644
> --- a/drivers/net/wireless/rndis_wlan.c
> +++ b/drivers/net/wireless/rndis_wlan.c
> @@ -420,7 +420,8 @@ struct rndis_wext_private {
>  /*
>   * cfg80211 ops
>   */
> -static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex,
> +static int rndis_change_virtual_intf(struct wiphy *wiphy,
> +                                       struct net_device *dev,
>                                         enum nl80211_iftype type, u32 *flags,
>                                         struct vif_params *params);
> 
> @@ -1222,20 +1223,14 @@ static void set_multicast_list(struct usbnet *usbdev)
>  /*
>   * cfg80211 ops
>   */
> -static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex,
> +static int rndis_change_virtual_intf(struct wiphy *wiphy,
> +                                       struct net_device *dev,
>                                         enum nl80211_iftype type, u32 *flags,
>                                         struct vif_params *params)
>  {
> -       struct net_device *dev;
> -       struct usbnet *usbdev;
> +       struct usbnet *usbdev = netdev_priv(dev);
>         int mode;
> 
> -       /* we're under RTNL */
> -       dev = __dev_get_by_index(&init_net, ifindex);
> -       if (!dev)
> -               return -ENODEV;
> -       usbdev = netdev_priv(dev);
> -
>         switch (type) {
>         case NL80211_IFTYPE_ADHOC:
>                 mode = ndis_80211_infra_adhoc;
> 
> 
> 
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2009-06-12 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-09 19:04 [PATCH] cfg80211: pass netdev to change_virtual_intf Johannes Berg
2009-06-04 17:19 ` Dave
2009-06-12 20:50   ` Johannes Berg
2009-06-09 19:11 ` Samuel Ortiz

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).