dev->priv to netdev_priv(dev), for drivers/net/wireless
Subsystems (2)
PATCH 13/13 dev->priv to netdev_priv(dev), for drivers/net/wireless
Replacing accesses to dev->priv to netdev_priv(dev). The replacment is safe when netdev_priv is used to access a private structure that is right next to the net_device structure in memory. Cf
http://groups.google.com/group/comp.os.linux.development.system/browse_thread/thread/de19321bcd94dbb8/0d74a4adcd6177bd
This is the case when the net_device structure was allocated with a call to alloc_netdev or one of its derivative.
Here is an excerpt of the semantic patch that performs the transformation
@ rule1 @
type T;
struct net_device *dev;
@@
dev =
(
alloc_netdev
|
alloc_etherdev
|
alloc_trdev
)
(sizeof(T), ...)
@ rule1bis @
struct net_device *dev;
expression E;
@@
dev->priv = E
@ rule2 depends on rule1 && !rule1bis @
struct net_device *dev;
type rule1.T;
@@
- (T*) dev->priv
+ netdev_priv(dev)
---
drivers/net/wireless/arlan-proc.c | 14 +++--- drivers/net/wireless/hostap/hostap_cs.c | 2 drivers/net/wireless/hostap/hostap_hw.c | 2 drivers/net/wireless/hostap/hostap_ioctl.c | 14 +++--- drivers/net/wireless/orinoco_tmd.c | 2 drivers/net/wireless/prism54/isl_ioctl.c | 6 +- drivers/net/wireless/ray_cs.c | 66 ++++++++++++++--------------- drivers/net/wireless/strip.c | 2 drivers/net/wireless/wl3501_cs.c | 66 ++++++++++++++--------------- 9 files changed, 87 insertions(+), 87 deletions(-)
drivers/net/wireless/arlan-proc.c +7 -7
@@ -435,7 +435,7 @@ static int arlan_sysctl_info(ctl_table * goto final; }else - priva = arlan_device[devnum]->priv; + priva =netdev_priv (arlan_device[devnum]);if (priva =NULL ) {
@@ -654,7 +654,7 @@ static int arlan_sysctl_info161719(ctl_t goto final; }else - priva = arlan_device[devnum]->priv; + priva =netdev_priv (arlan_device[devnum]);if (priva =NULL ) {printk (KERN_WARNING " Could not find the device private in arlan procsys, bad\n " );
@@ -688,7 +688,7 @@ static int arlan_sysctl_infotxRing(ctl_t goto final; }else - priva = arlan_device[devnum]->priv; + priva =netdev_priv (arlan_device[devnum]);if (priva =NULL ) {printk (KERN_WARNING " Could not find the device private in arlan procsys, bad\n " );
@@ -716,7 +716,7 @@ static int arlan_sysctl_inforxRing(ctl_t pos +=sprintf (arlan_drive_info + pos,"No device found here \n" ); goto final; }else - priva = arlan_device[devnum]->priv; + priva =netdev_priv (arlan_device[devnum]);if (priva =NULL ) {printk (KERN_WARNING " Could not find the device private in arlan procsys, bad\n " );
@@ -745,7 +745,7 @@ static int arlan_sysctl_info18(ctl_table goto final; }else - priva = arlan_device[devnum]->priv; + priva =netdev_priv (arlan_device[devnum]);if (priva =NULL ) {printk (KERN_WARNING " Could not find the device private in arlan procsys, bad\n " );
@@ -780,7 +780,7 @@ static int arlan_configure(ctl_table * c }else if (arlan_device[devnum] !=NULL ) { - priv = arlan_device[devnum]->priv; + priv =netdev_priv (arlan_device[devnum]);arlan_command (arlan_device[devnum],ARLAN_COMMAND_CLEAN_AND_CONF ); }
@@ -805,7 +805,7 @@ static int arlan_sysctl_reset(ctl_table }else if (arlan_device[devnum] !=NULL ) { - priv = arlan_device[devnum]->priv; + priv =netdev_priv (arlan_device[devnum]);arlan_command (arlan_device[devnum],ARLAN_COMMAND_CLEAN_AND_RESET ); }else
drivers/net/wireless/hostap/hostap_cs.c +1 -1
@@ -272,7 +272,7 @@ static int sandisk_enable_wireless(struc {int res, ret =0 ;conf_reg_t reg; -struct hostap_interface *iface = dev->priv; +struct hostap_interface *iface =netdev_priv (dev);local_info_t *local = iface->local;tuple_t tuple;cisparse_t *parse =NULL ;
drivers/net/wireless/hostap/hostap_hw.c +1 -1
@@ -3424,7 +3424,7 @@ static void prism2_suspend(struct net_destruct local_info *local;union iwreq_data wrqu; - iface = dev->priv; + iface =netdev_priv (dev); local = iface->local;/* Send disconnect event, e.g., to trigger reassociation after resume
drivers/net/wireless/hostap/hostap_ioctl.c +7 -7
@@ -3088,7 +3088,7 @@ #endif /* PRISM2_DOWNLOAD_SUPPORT */static int prism2_set_genericelement (struct net_device *dev,u8 *elem,size_t len) { -struct hostap_interface *iface = dev->priv; +struct hostap_interface *iface =netdev_priv (dev);local_info_t *local = iface->local;u8 *buf;
@@ -3116,7 +3116,7 @@ static int prism2_ioctl_siwauth(struct nstruct iw_request_info *info, struct iw_param *data, char *extra) { - struct hostap_interface *iface = dev->priv; + struct hostap_interface *iface = netdev_priv(dev);local_info_t *local = iface->local;switch (data->flags &IW_AUTH_INDEX ) {
@@ -3182,7 +3182,7 @@ static int prism2_ioctl_giwauth(struct nstruct iw_request_info *info, struct iw_param *data, char *extra) { - struct hostap_interface *iface = dev->priv; + struct hostap_interface *iface = netdev_priv(dev);local_info_t *local = iface->local;switch (data->flags &IW_AUTH_INDEX ) {
@@ -3221,7 +3221,7 @@ static int prism2_ioctl_siwencodeext(strstruct iw_request_info *info, struct iw_point *erq, char *extra) { - struct hostap_interface *iface = dev->priv; + struct hostap_interface *iface = netdev_priv(dev);local_info_t *local = iface->local;struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;int i, ret =0 ;
@@ -3395,7 +3395,7 @@ static int prism2_ioctl_giwencodeext(strstruct iw_request_info *info, struct iw_point *erq, char *extra) { - struct hostap_interface *iface = dev->priv; + struct hostap_interface *iface = netdev_priv(dev);local_info_t *local = iface->local;struct ieee80211_crypt_data **crypt;void *sta_ptr;
@@ -3716,7 +3716,7 @@ static int prism2_ioctl_giwgenie(structstruct iw_request_info *info, struct iw_point *data, char *extra) { - struct hostap_interface *iface = dev->priv; + struct hostap_interface *iface = netdev_priv(dev);local_info_t *local = iface->local;int len = local->generic_elem_len -2 ;
@@ -3755,7 +3755,7 @@ static int prism2_ioctl_siwmlme(struct nstruct iw_request_info *info, struct iw_point *data, char *extra) { - struct hostap_interface *iface = dev->priv; + struct hostap_interface *iface = netdev_priv(dev);local_info_t *local = iface->local;struct iw_mlme *mlme = (struct iw_mlme *) extra;u16 reason;
drivers/net/wireless/orinoco_tmd.c +1 -1
@@ -190,7 +190,7 @@ static int orinoco_tmd_init_one(struct p static void __devexit orinoco_tmd_remove_one(struct pci_dev *pdev) {struct net_device *dev =pci_get_drvdata (pdev); -struct orinoco_private *priv = dev->priv; +struct orinoco_private *priv =netdev_priv (dev);struct orinoco_pci_card *card = priv->card;unregister_netdev (dev);
drivers/net/wireless/prism54/isl_ioctl.c +3 -3
@@ -1753,7 +1753,7 @@ prism54_get_oid(struct net_device *ndev,int rvalue;enum oid_num_t n = dwrq->flags; - rvalue =mgt_get_request ((islpci_private *) ndev->priv, n,0 ,NULL , &r); + rvalue =mgt_get_request (netdev_priv (ndev), n,0 ,NULL , &r); dwrq->length =mgt_response_to_str (n, &r, extra);if ((isl_oid[n].flags &OID_FLAG_TYPE ) !=OID_TYPE_U32 )kfree (r.ptr);
@@ -1766,7 +1766,7 @@ prism54_set_u32(struct net_device *ndev, {u32 oid = uwrq[0 ], u = uwrq[1 ]; -return mgt_set_request ((islpci_private *) ndev->priv, oid,0 , &u); +return mgt_set_request (netdev_priv (ndev), oid,0 , &u); } static int
@@ -1775,7 +1775,7 @@ prism54_set_raw(struct net_device *ndev, {u32 oid = dwrq->flags; -return mgt_set_request ((islpci_private *) ndev->priv, oid,0 , extra); +return mgt_set_request (netdev_priv (ndev), oid,0 , extra); }void
drivers/net/wireless/ray_cs.c +33 -33
264 lines not on this page · raw message
drivers/net/wireless/strip.c +1 -1
@@ -2571,7 +2571,7 @@ static struct strip *strip_alloc(void)return NULL ;/* If no more memory, return */ - strip_info = dev->priv; + strip_info =netdev_priv (dev); strip_info->dev = dev; strip_info->magic =STRIP_MAGIC ;
drivers/net/wireless/wl3501_cs.c +33 -33
264 lines not on this page · raw message
Johannes Berg
maintainerQuoted 1 line · Yoann Padioleau
Here is an excerpt of the semantic patch that performs the transformation
Out of curiosity, what is that "semantic patch" stuff? Is there actually a tool that applies changes defined in that way?
johannes
Quoted 8 lines · Johannes Berg
Quoted 2 lines · Yoann Padioleau
Here is an excerpt of the semantic patch that performs the =20 transformation
Out of curiosity, what is that "semantic patch" stuff? Is there =20 actually
a tool that applies changes defined in that way?
Yes there is. See www.emn.fr/x-info/coccinelle
This tool is called spatch.
Quoted 2 lines
johannes
-
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Johannes Berg
maintainerQuoted 2 lines · yoann padioleau
Yes there is. See www.emn.fr/x-info/coccinelle
This tool is called spatch.
Oh neat, thanks for the pointer.
johannes
Johannes Berg
maintainerQuoted 5 lines · Johannes Berg
Quoted 2 lines · yoann padioleau
Yes there is. See www.emn.fr/x-info/coccinelle
This tool is called spatch.Oh neat, thanks for the pointer.
Oh scratch that, not neat. No source code, disappointing. Won't nor can't run x86 binaries on ppc.
johannes